freebsd-dev/sys/boot/i386/gptboot/Makefile
Andriy Gapon 918314631b gpt/zfs boot blocks: reduce optimizing CFLAGS to -O1
gpt and zfs boot blocks are not nearly as size-constrained as boot2
from which they inherited their current optimization and anti-optimization
options.  As such the current options do not provide any benefit, but
make debugging of the code much harder.
Also, it has been demonstrated that combination of -mrtd and
-fno-unit-at-a-time may result in mis-compilation of the boot code
with the current base gcc.

Additionally, intermediate assembly file filtering is removed for
zfsboot.

The new boot blocks are all compile- and boot- tested using qemu.
gptzfsboot is tested with real hardware.

Reported by:	Peter Jeremy <peterjeremy@acm.org> [miscompilation]
Discussed with:	bde, jhb
Tested by:	Sebastian Chmielewski <chmielsster@gmail.com> [gptzfsboot]
Approved by:	re (kib)
MFC after:	3 weeks
2011-09-13 14:03:55 +00:00

82 lines
2.0 KiB
Makefile

# $FreeBSD$
.PATH: ${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common
FILES= gptboot
NM?= nm
BOOT_COMCONSOLE_PORT?= 0x3f8
BOOT_COMCONSOLE_SPEED?= 9600
B2SIOFMT?= 0x3
REL1= 0x700
ORG1= 0x7c00
ORG2= 0x0
# Decide level of UFS support.
GPTBOOT_UFS?= UFS1_AND_UFS2
#GPTBOOT_UFS?= UFS2_ONLY
#GPTBOOT_UFS?= UFS1_ONLY
CFLAGS= -DBOOTPROG=\"gptboot\" \
-O1 \
-DGPT \
-D${GPTBOOT_UFS} \
-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
-DSIOFMT=${B2SIOFMT} \
-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
-I${.CURDIR}/../../common \
-I${.CURDIR}/../common \
-I${.CURDIR}/../btx/lib -I. \
-I${.CURDIR}/../boot2 \
-I${.CURDIR}/../../.. \
-Wall -Waggregate-return -Wbad-function-cast -Wcast-align \
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
-Winline --param max-inline-insns-single=100
.if ${CC:T:Mclang} == "clang"
# XXX: clang integrated-as doesn't grok .codeNN directives yet
CFLAGS+= ${.IMPSRC:T:Mgptldr.S:C/^.+$/-no-integrated-as/}
.endif
LDFLAGS=-static -N --gc-sections
# Pick up ../Makefile.inc early.
.include <bsd.init.mk>
CLEANFILES= gptboot
gptboot: gptldr.bin gptboot.bin ${BTXKERN}
btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l gptldr.bin \
-o ${.TARGET} gptboot.bin
CLEANFILES+= gptldr.bin gptldr.out gptldr.o
gptldr.bin: gptldr.out
objcopy -S -O binary gptldr.out ${.TARGET}
gptldr.out: gptldr.o
${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
CLEANFILES+= gptboot.bin gptboot.out gptboot.o sio.o gpt.o crc32.o drv.o \
cons.o util.o
gptboot.bin: gptboot.out
objcopy -S -O binary gptboot.out ${.TARGET}
gptboot.out: ${BTXCRT} gptboot.o sio.o gpt.o crc32.o drv.o cons.o util.o
${LD} ${LDFLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}
gptboot.o: ${.CURDIR}/../../common/ufsread.c
.if ${MACHINE_CPUARCH} == "amd64"
beforedepend gptboot.o: machine
CLEANFILES+= machine
machine:
ln -sf ${.CURDIR}/../../../i386/include machine
.endif
.include <bsd.prog.mk>