Index: head/sys/boot/defs.mk =================================================================== --- head/sys/boot/defs.mk (revision 325484) +++ head/sys/boot/defs.mk (revision 325485) @@ -1,138 +1,148 @@ # $FreeBSD$ .include .if !defined(__BOOT_DEFS_MK__) __BOOT_DEFS_MK__=${MFILE} BOOTSRC= ${SRCTOP}/sys/boot EFISRC= ${BOOTSRC}/efi EFIINC= ${EFISRC}/include EFIINCMD= ${EFIINC}/${MACHINE} FDTSRC= ${BOOTSRC}/fdt FICLSRC= ${BOOTSRC}/ficl LDRSRC= ${BOOTSRC}/common SASRC= ${BOOTSRC}/libsa SYSDIR= ${SRCTOP}/sys UBOOTSRC= ${BOOTSRC}/uboot ZFSSRC= ${BOOTSRC}/zfs BOOTOBJ= ${OBJTOP}/sys/boot # BINDIR is where we install BINDIR?= /boot # NB: The makefiles depend on these being empty when we don't build forth. .if ${MK_FORTH} != "no" LIBFICL= ${BOOTOBJ}/ficl/libficl.a .if ${MACHINE} == "i386" LIBFICL32= ${LIBFICL} .else LIBFICL32= ${BOOTOBJ}/ficl32/libficl.a .endif .endif LIBSA= ${BOOTOBJ}/libsa/libsa.a .if ${MACHINE} == "i386" LIBSA32= ${LIBSA} .else LIBSA32= ${BOOTOBJ}/libsa32/libsa32.a .endif # Standard options: # Filesystem support .if ${LOADER_CD9660_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_CD9660_SUPPORT .endif .if ${LOADER_EXT2FS_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_EXT2FS_SUPPORT .endif .if ${LOADER_MSDOS_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_MSDOS_SUPPORT .endif .if ${LOADER_NANDFS_SUPPORT:U${MK_NAND}} == "yes" CFLAGS+= -DLOADER_NANDFS_SUPPORT .endif .if ${LOADER_UFS_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_UFS_SUPPORT .endif # Compression .if ${LOADER_GZIP_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_GZIP_SUPPORT .endif .if ${LOADER_BZIP2_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_BZIP2_SUPPORT .endif # Network related things .if ${LOADER_NET_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_NET_SUPPORT .endif .if ${LOADER_NFS_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_NFS_SUPPORT .endif .if ${LOADER_TFTP_SUPPORT:Uno} == "yes" CFLAGS+= -DLOADER_TFTP_SUPPORT .endif # Disk and partition support .if ${LOADER_DISK_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_DISK_SUPPORT .if ${LOADER_GPT_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_GPT_SUPPORT .endif .if ${LOADER_MBR_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_MBR_SUPPORT .endif .if ${LOADER_GELI_SUPPORT:Uyes} == "yes" CFLAGS+= -DLOADER_GELI_SUPPORT .endif .endif # All PowerPC builds are 32 bit. We have no 64-bit loaders on powerpc # or powerpc64. .if ${MACHINE_ARCH} == "powerpc64" CFLAGS+= -m32 -mcpu=powerpc .endif +# For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is +# build 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here +# and activate it when DO32 is explicitly defined to be 1. +.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1 +CFLAGS+= -m32 -mcpu=i386 +# LD_FLAGS is passed directly to ${LD}, not via ${CC}: +LD_FLAGS+= -m elf_i386_fbsd +AFLAGS+= --32 +.endif + _ILINKS=machine .if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" _ILINKS+=${MACHINE_CPUARCH} .endif .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" _ILINKS+=x86 .endif CLEANFILES+=${_ILINKS} all: ${PROG} beforedepend: ${_ILINKS} beforebuild: ${_ILINKS} # Ensure that the links exist without depending on it when it exists which # causes all the modules to be rebuilt when the directory pointed to changes. .for _link in ${_ILINKS} .if !exists(${.OBJDIR}/${_link}) ${OBJS}: ${_link} .endif .endfor .NOPATH: ${_ILINKS} ${_ILINKS}: @case ${.TARGET} in \ machine) \ if [ ${DO32:U0} -eq 0 ]; then \ path=${SYSDIR}/${MACHINE}/include ; \ else \ path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \ fi ;; \ *) \ path=${SYSDIR}/${.TARGET:T}/include ;; \ esac ; \ path=`(cd $$path && /bin/pwd)` ; \ ${ECHO} ${.TARGET:T} "->" $$path ; \ ln -fhs $$path ${.TARGET:T} .endif # __BOOT_DEFS_MK__ Index: head/sys/boot/fdt/Makefile =================================================================== --- head/sys/boot/fdt/Makefile (revision 325484) +++ head/sys/boot/fdt/Makefile (revision 325485) @@ -1,32 +1,28 @@ # $FreeBSD$ .include .PATH: ${SYSDIR}/contrib/libfdt/ LIB= fdt INTERNALLIB= # Vendor sources of libfdt. SRCS+= fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c \ fdt_empty_tree.c # Loader's fdt commands extension sources. SRCS+= fdt_loader_cmd.c fdt_overlay.c CFLAGS+= -I${SYSDIR}/contrib/libfdt/ -I${LDRSRC} CFLAGS+= -ffreestanding .if ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" CFLAGS+= -msoft-float .endif -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -.endif - CFLAGS+= -Wformat -Wall .include .include Index: head/sys/boot/ficl/Makefile =================================================================== --- head/sys/boot/ficl/Makefile (revision 325484) +++ head/sys/boot/ficl/Makefile (revision 325485) @@ -1,42 +1,35 @@ # $FreeBSD$ # .include .include "${BOOTSRC}/ficl.mk" BASE_SRCS= dict.c ficl.c fileaccess.c float.c loader.c math64.c \ prefix.c search.c stack.c tools.c vm.c words.c SRCS= ${BASE_SRCS} sysdep.c softcore.c CLEANFILES= softcore.c testmain testmain.o -.if ${MACHINE_CPUARCH} == "i386" || \ - (${MACHINE_CPUARCH} == "amd64" && defined(DO32)) -CFLAGS+= -march=i386 -.endif -.if ${MACHINE_CPUARCH} == "amd64" && defined(DO32) -CFLAGS+= -m32 -.endif .if defined(HAVE_PNP) CFLAGS+= -DHAVE_PNP .endif .include .ifmake testmain CFLAGS+= -DTESTMAIN -D_TESTMAIN SRCS+= testmain.c PROG= testmain .include .else LIB= ficl INTERNALLIB= .include .endif # Standard softwords .PATH: ${FICLSRC}/softwords SOFTWORDS= softcore.fr jhlocal.fr marker.fr freebsd.fr ficllocal.fr \ ifbrack.fr softcore.c: ${SOFTWORDS} softcore.awk (cd ${FICLSRC}/softwords; cat ${SOFTWORDS} \ | awk -f softcore.awk -v datestamp="`LC_ALL=C date`") > ${.TARGET} Index: head/sys/boot/ficl.mk =================================================================== --- head/sys/boot/ficl.mk (revision 325484) +++ head/sys/boot/ficl.mk (revision 325485) @@ -1,31 +1,23 @@ # $FreeBSD$ # Common flags to build FICL related files .include "defs.mk" .if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1 FICL_CPUARCH= i386 .elif ${MACHINE_ARCH:Mmips64*} != "" FICL_CPUARCH= mips64 .else FICL_CPUARCH= ${MACHINE_CPUARCH} .endif .PATH: ${FICLSRC} ${FICLSRC}/${FICL_CPUARCH} -.if ${MACHINE_CPUARCH} == "amd64" -.if ${DO32:U0} == 1 -CFLAGS+= -m32 -I. -.else +.if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 0 CFLAGS+= -fPIC -.endif -.endif - -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc -I. .endif CFLAGS+= -I${FICLSRC} -I${FICLSRC}/${FICL_CPUARCH} -I${LDRSRC} CFLAGS+= -DBOOT_FORTH CFLAGS+= -DBF_DICTSIZE=15000 Index: head/sys/boot/geli/Makefile =================================================================== --- head/sys/boot/geli/Makefile (revision 325484) +++ head/sys/boot/geli/Makefile (revision 325485) @@ -1,53 +1,53 @@ # $FreeBSD$ # libgeliboot MAN= .include MK_SSP= no LIB= geliboot INTERNALLIB= MK_PROFILE= no NO_PIC= .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -march=i386 .endif -.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64" +.if ${MACHINE_ARCH} == "amd64" CFLAGS+= -m32 .endif WARNS?= 0 # string functions from libc .PATH: ${SRCTOP}/lib/libc/string SRCS+= bcmp.c bcopy.c bzero.c # Our password input method SRCS+= pwgets.c # sha256 and sha512 from sys/crypto .PATH: ${SYSDIR}/crypto/sha2 CFLAGS+= -DWEAK_REFS SRCS+= sha256c.c sha512c.c # md5 from libmd .PATH: ${SRCTOP}/lib/libmd SRCS+= md5c.c # AES implementation from sys/crypto .PATH: ${SYSDIR}/crypto/rijndael CFLAGS+= -I${SYSDIR} CFLAGS+= -I${LDRSRC} # Remove asserts CFLAGS+= -DNDEBUG SRCS+= rijndael-alg-fst.c rijndael-api-fst.c rijndael-api.c # local GELI Implementation .PATH: ${SYSDIR}/geom/eli CFLAGS+= -D_STAND SRCS+= geliboot_crypto.c g_eli_hmac.c g_eli_key.c g_eli_key_cache.c pkcs5v2.c .include .include Index: head/sys/boot/i386/Makefile.inc =================================================================== --- head/sys/boot/i386/Makefile.inc (revision 325484) +++ head/sys/boot/i386/Makefile.inc (revision 325485) @@ -1,36 +1,31 @@ # Common defines for all of /sys/boot/i386/ # # $FreeBSD$ LOADER_ADDRESS?=0x200000 CFLAGS+= -march=i386 -ffreestanding CFLAGS.gcc+= -mpreferred-stack-boundary=2 CFLAGS+= ${CFLAGS_NO_SIMD} -msoft-float LDFLAGS+= -nostdlib # BTX components BTXDIR= ${BOOTOBJ}/i386/btx BTXLDR= ${BTXDIR}/btxldr/btxldr BTXKERN= ${BTXDIR}/btx/btx BTXCRT= ${BTXDIR}/lib/crt0.o BTXSRC= ${BOOTSRC}/i386/btx BTXLIB= ${BTXSRC}/lib # compact binary with no padding between text, data, bss LDSCRIPT= ${BOOTSRC}/i386/boot.ldscript # LDFLAGS_BIN=-e start -Ttext ${ORG} -Wl,-T,${LDSCRIPT},-S,--oformat,binary # LD_FLAGS_BIN=-static -T ${LDSCRIPT} --gc-sections LDFLAGS_BIN=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary LD_FLAGS_BIN=-static -N --gc-sections .if ${MACHINE_CPUARCH} == "amd64" -CFLAGS+= -m32 -ACFLAGS+= -m32 -# LD_FLAGS is passed directly to ${LD}, not via ${CC}: -LD_FLAGS+= -m elf_i386_fbsd -AFLAGS+= --32 DO32=1 .endif .include "../Makefile.inc" Index: head/sys/boot/libsa32/Makefile =================================================================== --- head/sys/boot/libsa32/Makefile (revision 325484) +++ head/sys/boot/libsa32/Makefile (revision 325485) @@ -1,19 +1,13 @@ # $FreeBSD$ DO32=1 .include LIB=sa32 -.if ${MACHINE_CPUARCH} == "amd64" -LIBSA_CPUARCH=i386 -.else -LIBSA_CPUARCH=${MACHINE_CPUARCH} -.endif +LIBSA_CPUARCH=${MACHINE_CPUARCH:C/amd64/i386/} -.if ${MACHINE_ARCH} == "amd64" -CFLAGS+= -m32 -I. -.endif +CFLAGS+= -I. .PATH: ${SASRC} .include "${SASRC}/Makefile" Index: head/sys/boot/ofw/Makefile.inc =================================================================== --- head/sys/boot/ofw/Makefile.inc (revision 325484) +++ head/sys/boot/ofw/Makefile.inc (revision 325485) @@ -1,8 +1,3 @@ # $FreeBSD$ -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc -LDFLAGS+= -m elf32ppc_fbsd -.endif - .include "../Makefile.inc" Index: head/sys/boot/uboot/Makefile.inc =================================================================== --- head/sys/boot/uboot/Makefile.inc (revision 325484) +++ head/sys/boot/uboot/Makefile.inc (revision 325485) @@ -1,8 +1,3 @@ # $FreeBSD$ -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc -LDFLAGS+= -m elf32ppc_fbsd -.endif - .include "../Makefile.inc" Index: head/sys/boot/zfs/Makefile =================================================================== --- head/sys/boot/zfs/Makefile (revision 325484) +++ head/sys/boot/zfs/Makefile (revision 325485) @@ -1,30 +1,22 @@ # $FreeBSD$ .include LIB= zfsboot INTERNALLIB= .PATH: ${ZFSSRC} SRCS+= zfs.c skein.c skein_block.c # Do not unroll skein loops, reduce code size CFLAGS+= -DSKEIN_LOOP=111 .PATH: ${SYSDIR}/crypto/skein CFLAGS+= -DBOOTPROG=\"zfsloader\" CFLAGS+= -I${LDRSRC} -I${SYSDIR} -I. CFLAGS+= -I${SYSDIR}/cddl/boot/zfs CFLAGS+= -I${SYSDIR}/crypto/skein -.if ${MACHINE_CPUARCH} == "i386" || \ - (${MACHINE_CPUARCH} == "amd64" && defined(DO32)) -CFLAGS+= -march=i386 -.endif -.if ${MACHINE_CPUARCH} == "amd64" && defined(DO32) -CFLAGS+= -m32 -.endif - CFLAGS+= -Wformat -Wall .include .include