Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Dec 2017 21:38:19 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326593 - in head/stand: . libsa
Message-ID:  <201712052138.vB5LcJEH024287@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Tue Dec  5 21:38:19 2017
New Revision: 326593
URL: https://svnweb.freebsd.org/changeset/base/326593

Log:
  Stop building with the standard system headers.
  
  Building with the standard system headers isn't a perfect match to the
  stand environment. Instead, copy over the files we know are safe to
  use and constrain what else is used. We use -nostdinc to achieve this.
  
  This also fixes issues with building 32-bit libraries on amd64
  sometimes pulling in the wrong cpufunc.h giving an error now that we
  stop on errors. It will also enable an easier transition to lua boot.
  
  Sponsored by: Netflix

Modified:
  head/stand/defs.mk
  head/stand/libsa/Makefile

Modified: head/stand/defs.mk
==============================================================================
--- head/stand/defs.mk	Tue Dec  5 21:38:14 2017	(r326592)
+++ head/stand/defs.mk	Tue Dec  5 21:38:19 2017	(r326593)
@@ -41,6 +41,12 @@ LIBSA32=	${BOOTOBJ}/libsa32/libsa32.a
 .endif
 
 # Standard options:
+CFLAGS+=	-nostdinc
+.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
+CFLAGS+=	-I${BOOTOBJ}/libsa32
+.else
+CFLAGS+=	-I${BOOTOBJ}/libsa
+.endif
 CFLAGS+=	-I${SASRC} -D_STANDALONE
 CFLAGS+=	-I${SYSDIR}
 

Modified: head/stand/libsa/Makefile
==============================================================================
--- head/stand/libsa/Makefile	Tue Dec  5 21:38:14 2017	(r326592)
+++ head/stand/libsa/Makefile	Tue Dec  5 21:38:19 2017	(r326593)
@@ -91,6 +91,7 @@ SRCS+=	libsa_bzlib_private.h
 .for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
 SRCS+=	_${file}
 CLEANFILES+=	_${file}
+CFLAGS._${file}+=-I${SRCTOP}/contrib/bzip2
 
 _${file}: ${file}
 	sed "s|bzlib_private\.h|libsa_bzlib_private.h|" \
@@ -129,6 +130,26 @@ libsa_${file}: ${file}
 	    ${.ALLSRC} > ${.TARGET}
 .endfor
 
+# Create a subset of includes that are safe, as well as adjusting those that aren't
+# The lists may drive people nuts, but they are explicitly opt-in
+beforedepend:
+	echo beforedepend; \
+	mkdir -p xlocale arpa; \
+	for i in a.out.h assert.h elf.h limits.h nlist.h setjmp.h stddef.h stdbool.h string.h strings.h time.h unistd.h uuid.h; do \
+		ln -sf ${SRCTOP}/include/$$i $$i; \
+	done; \
+	ln -sf ${SYSDIR}/${MACHINE}/include/stdarg.h stdarg.h; \
+	ln -sf ${SYSDIR}/sys/errno.h errno.h; \
+	ln -sf ${SYSDIR}/sys/stdint.h stdint.h; \
+	ln -sf ${SRCTOP}/include/arpa/inet.h arpa/inet.h; \
+	ln -sf ${SRCTOP}/include/arpa/tftp.h arpa/tftp.h; \
+	for i in _time.h _strings.h _string.h; do \
+		[ -f xlocale/$$i ] || cp /dev/null xlocale/$$i; \
+	done; \
+	for i in ctype.h stdio.h stdlib.h; do \
+		ln -sf ${SASRC}/stand.h $$i; \
+	done
+
 # io routines
 SRCS+=	closeall.c dev.c ioctl.c nullfs.c stat.c \
 	fstat.c close.c lseek.c open.c read.c write.c readdir.c
@@ -147,6 +168,8 @@ SRCS+=	pkgfs.c
 .if ${MK_NAND} != "no"
 SRCS+=	nandfs.c
 .endif
+
+CFLAGS.bzipfs.c+= -I${SRCTOP}/contrib/bzip2
 
 # explicit_bzero
 .PATH: ${SYSDIR}/libkern



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712052138.vB5LcJEH024287>