While working on cc -m32 support I added the following to all headers in sys/amd64/include to make sure none of my changes have an effect on building world+kernel:
#ifndef __x86_64__ #error bla #endif This exposed some problems in sys/boot. The Makefiles there create a symlink .OBJDIR/machine -> sys/i386/includes and add -I. to the CFLAGS such that including <machine/header.h> includes the i386 header. The problem is that <stdarg.h> is also included and is a symlink in WORLDTMP/usr/include to the machine/stdarg.h there, which is for amd64. There should be a symlink .OBJDIR/stdarg.h -> machine/stdarg.h to fix this. Another case is sys/boot/i386/kgzldr which includes <sys/types.h> and that in turn includes headers from machine, so it needs the machine symlink. Could somebody review the attached patch to make sure it does the right thing?
diff --git a/sys/boot/ficl/Makefile b/sys/boot/ficl/Makefile
index cdc8f7e..bb9c04c 100644
--- a/sys/boot/ficl/Makefile
+++ b/sys/boot/ficl/Makefile
@@ -57,12 +57,15 @@ softcore.c: ${SOFTWORDS} softcore.awk
| awk -f softcore.awk -v datestamp="`LC_ALL=C date`") > ${.TARGET}
.if ${MACHINE_ARCH} == "amd64"
-${SRCS:M*.c:R:S/$/.o/g}: machine
+${SRCS:M*.c:R:S/$/.o/g}: machine stdarg.h
-beforedepend ${OBJS}: machine
+beforedepend ${OBJS}: machine stdarg.h
machine:
ln -sf ${.CURDIR}/../../i386/include machine
-CLEANFILES+= machine
+stdarg.h:
+ ln -sf machine/stdarg.h stdarg.h
+
+CLEANFILES+= machine stdarg.h
.endif
diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
index ab5a69a..4196115 100644
--- a/sys/boot/i386/boot2/Makefile
+++ b/sys/boot/i386/boot2/Makefile
@@ -95,10 +95,12 @@ boot2.h: boot1.out
REL1=`printf "%d" ${REL1}` > ${.TARGET}
.if ${MACHINE_ARCH} == "amd64"
-beforedepend boot2.s: machine
-CLEANFILES+= machine
+beforedepend boot2.s: machine stdarg.h
+CLEANFILES+= machine stdarg.h
machine:
ln -sf ${.CURDIR}/../../../i386/include machine
+stdarg.h:
+ ln -sf machine/stdarg.h stdarg.h
.endif
.include <bsd.prog.mk>
diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile
index cc71b35..4532035 100644
--- a/sys/boot/i386/gptboot/Makefile
+++ b/sys/boot/i386/gptboot/Makefile
@@ -68,10 +68,12 @@ gptboot.out: ${BTXCRT} gptboot.o sio.o
gptboot.o: ${.CURDIR}/../../common/ufsread.c
.if ${MACHINE_ARCH} == "amd64"
-beforedepend gptboot.o: machine
-CLEANFILES+= machine
+beforedepend gptboot.o: machine stdarg.h
+CLEANFILES+= machine stdarg.h
machine:
ln -sf ${.CURDIR}/../../../i386/include machine
+stdarg.h:
+ ln -sf machine/stdarg.h stdarg.h
.endif
.include <bsd.prog.mk>
diff --git a/sys/boot/i386/kgzldr/Makefile b/sys/boot/i386/kgzldr/Makefile
index a124474..54e8482 100644
--- a/sys/boot/i386/kgzldr/Makefile
+++ b/sys/boot/i386/kgzldr/Makefile
@@ -7,7 +7,7 @@ BINDIR= ${LIBDIR}
NO_MAN=
SRCS= start.s boot.c inflate.c lib.c crt.s sio.s
-CFLAGS= -Os
+CFLAGS= -Os -I.
CFLAGS+=-DKZIP
NO_SHARED=
LDFLAGS=-Wl,-r
@@ -16,4 +16,11 @@ LDFLAGS=-Wl,-r
BOOT_COMCONSOLE_PORT?= 0x3f8
AFLAGS+=--defsym SIO_PRT=${BOOT_COMCONSOLE_PORT}
+.if ${MACHINE_ARCH} == "amd64"
+beforedepend boot.o lib.o: machine
+CLEANFILES+= machine
+machine:
+ ln -sf ${.CURDIR}/../../../i386/include machine
+.endif
+
.include <bsd.prog.mk>
diff --git a/sys/boot/i386/libfirewire/Makefile
b/sys/boot/i386/libfirewire/Makefile
index 28f7630..785d282 100644
--- a/sys/boot/i386/libfirewire/Makefile
+++ b/sys/boot/i386/libfirewire/Makefile
@@ -17,14 +17,16 @@ CFLAGS+= -I${.CURDIR}/../libi386
CFLAGS+= -Wformat -Wall
.if ${MACHINE_ARCH} == "amd64"
-CLEANFILES+= machine
+CLEANFILES+= machine stdarg.h
machine:
ln -sf ${.CURDIR}/../../../i386/include machine
+stdarg.h:
+ ln -sf machine/stdarg.h stdarg.h
.endif
.include <bsd.lib.mk>
.if ${MACHINE_ARCH} == "amd64"
-beforedepend ${OBJS}: machine
+beforedepend ${OBJS}: machine stdarg.h
.endif
diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile
index f1a461a..b43cec7 100644
--- a/sys/boot/i386/libi386/Makefile
+++ b/sys/boot/i386/libi386/Makefile
@@ -54,13 +54,15 @@ CFLAGS+= -I${.CURDIR}/../../common
-I${.CURDIR}/../btx/lib \
CFLAGS+= -I${.CURDIR}/../../../../lib/libstand/
.if ${MACHINE_ARCH} == "amd64"
-CLEANFILES+= machine
+CLEANFILES+= machine stdarg.h
machine:
ln -sf ${.CURDIR}/../../../i386/include machine
+stdarg.h:
+ ln -sf machine/stdarg.h stdarg.h
.endif
.include <bsd.lib.mk>
.if ${MACHINE_ARCH} == "amd64"
-beforedepend ${OBJS}: machine
+beforedepend ${OBJS}: machine stdarg.h
.endif
diff --git a/sys/boot/zfs/Makefile b/sys/boot/zfs/Makefile
index b48804b..31794c7 100644
--- a/sys/boot/zfs/Makefile
+++ b/sys/boot/zfs/Makefile
@@ -27,13 +27,15 @@ CFLAGS+= -m32 -march=i386
CFLAGS+= -Wformat -Wall
.if ${MACHINE_ARCH} == "amd64"
-CLEANFILES+= machine
+CLEANFILES+= machine stdarg.h
machine:
ln -sf ${.CURDIR}/../../i386/include machine
+stdarg.h:
+ ln -sf machine/stdarg.h stdarg.h
.endif
.include <bsd.lib.mk>
.if ${MACHINE_ARCH} == "amd64"
-beforedepend ${OBJS}: machine
+beforedepend ${OBJS}: machine stdarg.h
.endif
signature.asc
Description: This is a digitally signed message part.
