Index: lib/libnv/Makefile =================================================================== --- lib/libnv/Makefile +++ lib/libnv/Makefile @@ -9,7 +9,10 @@ SHLIB_MAJOR= 0 .PATH: ${SRCTOP}/sys/contrib/libnv ${SRCTOP}/sys/sys -CFLAGS+=-I${SRCTOP}/sys -I${.CURDIR} +.ifndef BOOTSTRAPPING +CFLAGS+=-I${SRCTOP}/sys +.endif +CFLAGS+=-I${.CURDIR} SRCS= cnvlist.c SRCS+= dnvlist.c Index: tools/build/mk/Makefile.boot =================================================================== --- tools/build/mk/Makefile.boot +++ tools/build/mk/Makefile.boot @@ -7,3 +7,19 @@ # 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 exception to this is sys/cddl which is needed by various dtrace tools. +.if !empty(CFLAGS:N*${SRCTOP}/sys/cddl/compat*:M*${SRCTOP}/sys*) +.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