diff --git a/sys/boot/defs.mk b/sys/boot/defs.mk index 4fbc83966dc6..75c354c6254a 100644 --- a/sys/boot/defs.mk +++ b/sys/boot/defs.mk @@ -96,6 +96,16 @@ CFLAGS+= -DLOADER_GELI_SUPPORT 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} diff --git a/sys/boot/fdt/Makefile b/sys/boot/fdt/Makefile index 467e424c2baf..a725499d2f78 100644 --- a/sys/boot/fdt/Makefile +++ b/sys/boot/fdt/Makefile @@ -22,10 +22,6 @@ CFLAGS+= -ffreestanding CFLAGS+= -msoft-float .endif -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -.endif - CFLAGS+= -Wformat -Wall .include diff --git a/sys/boot/ficl.mk b/sys/boot/ficl.mk index b6ac8d9096b0..a0a13206b495 100644 --- a/sys/boot/ficl.mk +++ b/sys/boot/ficl.mk @@ -14,17 +14,9 @@ FICL_CPUARCH= ${MACHINE_CPUARCH} .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 diff --git a/sys/boot/ficl/Makefile b/sys/boot/ficl/Makefile index 19c2da8eb197..e32e3909687d 100644 --- a/sys/boot/ficl/Makefile +++ b/sys/boot/ficl/Makefile @@ -9,13 +9,6 @@ BASE_SRCS= dict.c ficl.c fileaccess.c float.c loader.c math64.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 diff --git a/sys/boot/geli/Makefile b/sys/boot/geli/Makefile index 84ac9bdf6698..b16f7a8c5ab3 100644 --- a/sys/boot/geli/Makefile +++ b/sys/boot/geli/Makefile @@ -14,7 +14,7 @@ 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 diff --git a/sys/boot/i386/Makefile.inc b/sys/boot/i386/Makefile.inc index 941a8c49ab9b..b324d1adfef5 100644 --- a/sys/boot/i386/Makefile.inc +++ b/sys/boot/i386/Makefile.inc @@ -25,11 +25,6 @@ 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 diff --git a/sys/boot/libsa32/Makefile b/sys/boot/libsa32/Makefile index 862f8868beab..f09811b62128 100644 --- a/sys/boot/libsa32/Makefile +++ b/sys/boot/libsa32/Makefile @@ -5,15 +5,9 @@ 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" diff --git a/sys/boot/ofw/Makefile.inc b/sys/boot/ofw/Makefile.inc index e67c0dc904eb..265f86d1ed55 100644 --- a/sys/boot/ofw/Makefile.inc +++ b/sys/boot/ofw/Makefile.inc @@ -1,8 +1,3 @@ # $FreeBSD$ -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc -LDFLAGS+= -m elf32ppc_fbsd -.endif - .include "../Makefile.inc" diff --git a/sys/boot/uboot/Makefile.inc b/sys/boot/uboot/Makefile.inc index e67c0dc904eb..265f86d1ed55 100644 --- a/sys/boot/uboot/Makefile.inc +++ b/sys/boot/uboot/Makefile.inc @@ -1,8 +1,3 @@ # $FreeBSD$ -.if ${MACHINE_ARCH} == "powerpc64" -CFLAGS+= -m32 -mcpu=powerpc -LDFLAGS+= -m elf32ppc_fbsd -.endif - .include "../Makefile.inc" diff --git a/sys/boot/zfs/Makefile b/sys/boot/zfs/Makefile index 478e168ef368..7575aa9207eb 100644 --- a/sys/boot/zfs/Makefile +++ b/sys/boot/zfs/Makefile @@ -16,14 +16,6 @@ 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