commit dd37c0873cd911b7bbd0e77ad52a1276aadadc90 Author: Bryan Drewery Date: Tue Oct 24 15:04:39 2017 -0700 Fix native-xtools build to use a proper sysroot. This takes longer but should reliably produce working binaries. The old version linked against system libraries and headers which would be a problem if building a native-xtools against a newer source than the host system. With a proper sysroot made first this is not a problem. This change also allows the NXBDIRS list to be built in parallel. NXBDESTDIR can be specified for where to install or queried with `make -f Makefile.inc1 TARGET=... TARGET_ARCH=... -V NXBDESTDIR` This could be improved to reuse an existing sysroot. The problem is with building the SUBDIR_OVERRIDE list it needs to use a different OBJDIR since it is building all statically. We don't want to pollute the existing 'buildworld' OBJDIR and cause confusion on the next build. Using a separate OBJDIR for the 'everything' phase mostly works except for some things like linking in INTERNALLIBS that exist in the other OBJDIR. Sponsored by: Dell EMC Isilon diff --git Makefile.inc1 Makefile.inc1 index 285718c77a76..e658eb76c840 100644 --- Makefile.inc1 +++ Makefile.inc1 @@ -2111,47 +2111,20 @@ cross-tools: .MAKE .PHONY ${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install .endfor -NXBDESTDIR= ${OBJTREE}/nxb-bin -NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \ - TOOLS_PREFIX= \ - INSTALL="sh ${.CURDIR}/tools/install.sh" \ - PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin -NXBMAKE= ${NXBENV} ${MAKE} \ - LLVM_TBLGEN=${NXBDESTDIR}/usr/bin/llvm-tblgen \ - CLANG_TBLGEN=${NXBDESTDIR}/usr/bin/clang-tblgen \ - MACHINE=${TARGET} MACHINE_ARCH=${TARGET_ARCH} \ - MK_GDB=no MK_TESTS=no \ - SSP_CFLAGS= \ - MK_HTML=no NO_LINT=yes MK_MAN=no MK_MAN_UTILS=yes \ - -DNO_PIC MK_PROFILE=no -DNO_SHARED \ - -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ - MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \ - MK_LLDB=no MK_DEBUG_FILES=no - +# # native-xtools is the current target for qemu-user cross builds of ports # via poudriere and the imgact_binmisc kernel module. -# For non-clang enabled targets that are still using the in tree gcc -# we must build a gperf binary for one instance of its Makefiles. On -# clang-enabled systems, the gperf binary is obsolete. -native-xtools: .PHONY -.if ${MK_GCC_BOOTSTRAP} != "no" - mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin - ${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \ - cd ${.CURDIR}/${_gperf}; \ - if [ -z "${NO_OBJ}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ obj; fi; \ - ${NXBMAKE} DIRPRFX=${_gperf}/ all; \ - ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install -.endif - mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr - mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ - -p ${NXBDESTDIR}/usr >/dev/null - mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ - -p ${NXBDESTDIR}/usr/include >/dev/null -.if ${MK_DEBUG_FILES} != "no" - mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ - -p ${NXBDESTDIR}/usr/lib >/dev/null -.endif -.for _tool in \ +# This target merely builds a toolchan/sysroot, then builds the tools it wants +# with the options it wants in a special MAKEOBJDIRPREFIX, using the toolchain +# already built. It then installs the static tools to NXBDESTDIR for Poudriere +# to pickup. +# +NXBOBJDIR= ${OBJTREE}/nxb +NXBDESTDIR= ${NXBOBJDIR}${.CURDIR}/nxb-bin + +# This is the list of tools to be built/installed as static and where +# appropriate to build for the given TARGET.TARGET_ARCH. +NXBDIRS+= \ bin/cat \ bin/chmod \ bin/cp \ @@ -2169,24 +2142,17 @@ native-xtools: .PHONY bin/rmdir \ bin/sh \ bin/sleep \ - ${_clang_tblgen} \ - usr.bin/ar \ - ${_binutils} \ - ${_elftctools} \ - ${_gcc} \ - ${_gcc_tools} \ - ${_clang_libs} \ - ${_clang} \ - ${_lld} \ sbin/md5 \ sbin/sysctl \ - usr.bin/diff \ + usr.bin/ar \ usr.bin/awk \ usr.bin/basename \ usr.bin/bmake \ usr.bin/bzip2 \ usr.bin/cmp \ + usr.bin/diff \ usr.bin/dirname \ + usr.bin/elfcopy \ usr.bin/env \ usr.bin/fetch \ usr.bin/find \ @@ -2196,14 +2162,16 @@ native-xtools: .PHONY usr.bin/lex \ usr.bin/limits \ usr.bin/lorder \ - ${_libopenbsd} \ - ${_makewhatis} \ + usr.bin/mandoc \ usr.bin/mktemp \ usr.bin/mt \ + usr.bin/nm \ usr.bin/patch \ usr.bin/readelf \ usr.bin/sed \ + usr.bin/size \ usr.bin/sort \ + usr.bin/strings \ usr.bin/tar \ usr.bin/touch \ usr.bin/tr \ @@ -2215,12 +2183,57 @@ native-xtools: .PHONY usr.bin/xz \ usr.bin/yacc \ usr.sbin/chown - ${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \ - cd ${.CURDIR}/${_tool}; \ - if [ -z "${NO_OBJ}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ obj; fi; \ - ${NXBMAKE} DIRPRFX=${_tool}/ all; \ - ${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install -.endfor + +.if ${MK_CLANG} != "no" +NXBDIRS+= usr.bin/clang +.elif ${MK_GCC} != "no" +NXBDIRS+= gnu/usr.bin/cc +.endif +.if ${MK_BINUTILS} != "no" +NXBDIRS+= gnu/usr.bin/binutils +.endif + +NXBMAKEENV+= \ + MAKEOBJDIRPREFIX=${NXBOBJDIR:Q} + +NXBMAKEARGS+= \ + OBJTREE=${NXBOBJDIR:Q} \ + -DNO_SHARED \ + MK_GDB=no \ + MK_TESTS=no \ + SSP_CFLAGS= \ + MK_HTML=no \ + NO_LINT=yes \ + MK_MAN=no \ + MK_MAN_UTILS=yes \ + -DNO_PIC \ + MK_PROFILE=no \ + -DNO_CPU_CFLAGS \ + MK_CTF=no \ + MK_CLANG_EXTRAS=no \ + MK_CLANG_FULL=no \ + MK_LLDB=no \ + MK_DEBUG_FILES=no \ + MK_WARNS=no + + +NXBMAKE= ${NXBMAKEENV} ${MAKE} ${NXBMAKEARGS} +native-xtools: .PHONY + ${_+_}cd ${.CURDIR}; ${NXBMAKE} toolchain +.if !defined(NO_OBJ) + ${_+_}cd ${.CURDIR}; ${NXBMAKE} SUBDIR_OVERRIDE="${NXBDIRS:M*}" _obj +.endif + ${_+_}cd ${.CURDIR}; ${NXBMAKE} SUBDIR_OVERRIDE="${NXBDIRS:M*}" \ + everything + mkdir -p ${NXBDESTDIR}/bin ${NXBDESTDIR}/sbin ${NXBDESTDIR}/usr + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ + -p ${NXBDESTDIR}/usr >/dev/null + mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ + -p ${NXBDESTDIR}/usr/include >/dev/null + ${_+_}cd ${.CURDIR}; ${NXBMAKE} -f Makefile.inc1 \ + DESTDIR=${NXBDESTDIR} \ + SUBDIR_OVERRIDE="${NXBDIRS:M*}" \ + install # # hierarchy - ensure that all the needed directories are present