Avoid depending on system headers from the source tree during bootstrap

This can cause surprising errors if the build tools is built against
headers that don't match the host system. It is also required in order
to allow building on non-FreeBSD systems where the headers in
/usr/include/sys are usually completely incompatible with those in the
source tree.

I added an error to Makefile.boot if this is done and found this was
only the case in libnv. With this error in the Makefile ABI breakages
such as r336019 should no longer be possible.

Reviewed By:	bdrewery, kevans
Approved By:	jhb (mentor)
Differential Revision: https://reviews.freebsd.org/D16186
This commit is contained in:
Alex Richardson 2018-08-20 10:39:42 +00:00
parent ec45ce6222
commit 958dc017a7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=338096

View File

@ -7,3 +7,20 @@ LDFLAGS+= -L${WORLDTMP}/legacy/usr/lib
# we do not want to capture dependencies referring to the above
UPDATE_DEPENDFILE= no
# When building host tools we should never pull in headers from the source sys
# directory to avoid any ABI issues that might cause the built binary to crash.
# The only exceptions to this are sys/cddl/compat for dtrace bootstrap tools and
# sys/crypto for libmd bootstrap.
.if !empty(CFLAGS:M*${SRCTOP}/sys*:N*${SRCTOP}/sys/cddl/compat*:N*${SRCTOP}/sys/crypto*)
.error Do not include $${SRCTOP}/sys when building bootstrap tools. \
Copy the header to $${WORLDTMP}/legacy in tools/build/Makefile instead. \
Error was caused by Makefile in ${.CURDIR}
.endif
# ${SRCTOP}/include should also never be used to avoid ABI issues
.if !empty(CFLAGS:M*${SRCTOP}/include*)
.error Do not include $${SRCTOP}/include when building bootstrap tools. \
Copy the header to $${WORLDTMP}/legacy in tools/build/Makefile instead. \
Error was caused by Makefile in ${.CURDIR}
.endif