From 2bf36e7e089fedc7bb1ef22bb22211e6ed88a1ee Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Fri, 18 Apr 2014 17:03:58 +0000 Subject: [PATCH] Separate out enabling building clang and/or gcc for the system and building clang and/or gcc as the bootstrap compiler. Normally, the default compiler is used. WITH_CLANG_BOOTSTRAP and/or WITH_GCC_BOOTSTRAP will enable building these compilers as part bootstrap phase. WITH/WITHOUT_CLANG_IS_CC controls which compiler is used by default for the bootstrap phase, as well as which compiler is installed as cc. buildworld now successfully completes building the cross compiler with WITHOUT_CLANG=t and WITHOUT_GCC=t and produces a built system with neither of these included. Similarlly, MK_BINUTILS_BOOTSTRAP controls whether binutils is built during this phase. WITHOUT_CROSS_COMPILER will now force MK_BINUTILS_BOOTSTRAP=no, MK_CLANG_BOOTSTRAP=no and MK_GCC_BOOTSTRAP=no. BOOTSTRAP_COMPILER was considered, but rejected, since pc98 needs both clang and gcc to bootstrap still. It should be revisisted in the future if this requirement goes away. Values should be gcc, clang or none. It could also be a list. The odd interaction with Xfoo cross/external tools needs work, but is beyond the scope of this change as well. --- Makefile.inc1 | 15 +++++++------ share/mk/bsd.own.mk | 21 ++++++++++++------- tools/build/options/WITHOUT_BINUTILS | 12 +++++------ .../build/options/WITHOUT_BINUTILS_BOOTSTRAP | 8 +++++++ tools/build/options/WITHOUT_CLANG | 2 +- tools/build/options/WITHOUT_CLANG_BOOTSTRAP | 5 +++++ tools/build/options/WITHOUT_CROSS_COMPILER | 14 +++++++++++-- tools/build/options/WITHOUT_GCC | 2 +- tools/build/options/WITHOUT_GCC_BOOTSTRAP | 5 +++++ tools/build/options/WITH_CLANG | 2 +- tools/build/options/WITH_CLANG_BOOTSTRAP | 2 ++ tools/build/options/WITH_GCC_BOOTSTRAP | 2 ++ 12 files changed, 64 insertions(+), 26 deletions(-) create mode 100644 tools/build/options/WITHOUT_BINUTILS_BOOTSTRAP create mode 100644 tools/build/options/WITHOUT_CLANG_BOOTSTRAP create mode 100644 tools/build/options/WITHOUT_GCC_BOOTSTRAP create mode 100644 tools/build/options/WITH_CLANG_BOOTSTRAP create mode 100644 tools/build/options/WITH_GCC_BOOTSTRAP diff --git a/Makefile.inc1 b/Makefile.inc1 index 592cddaff564..c15a2bad7bd5 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1226,7 +1226,9 @@ _awk= usr.bin/awk _gensnmptree= usr.sbin/bsnmpd/gensnmptree .endif -.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang" || ${MK_CLANG} != "no" +# We need to build tlbgen when we're building clang either as +# the bootstrap compiler, or as the part of the normal build. +.if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" _clang_tblgen= \ lib/clang/libllvmsupport \ lib/clang/libllvmtablegen \ @@ -1366,22 +1368,19 @@ _kgzip= usr.sbin/kgzip .endif .endif -.if ${XAS:M/*} == "" && ${MK_BINUTILS} != "no" +# If we're given an XAS, don't build binutils. +.if ${XAS:M/*} == "" && ${MK_BINUTILS_BOOTSTRAP} != "no" _binutils= gnu/usr.bin/binutils .endif # If an full path to an external cross compiler is given, don't build # a cross compiler. .if ${XCC:M/*} == "" && ${MK_CROSS_COMPILER} != "no" -.if ${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang" +.if ${MK_CLANG_BOOTSTRAP} != "no" _clang= usr.bin/clang _clang_libs= lib/clang -.else -_cc= gnu/usr.bin/cc .endif - -# The boot2 for pc98 requires gcc. -.if ${TARGET} == "pc98" +.if ${MK_GCC_BOOTSTRAP} != "no" _cc= gnu/usr.bin/cc .endif .endif diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index c3bf33b2f7a1..b2ce1005bc3e 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -237,6 +237,7 @@ __DEFAULT_YES_OPTIONS = \ AUDIT \ AUTHPF \ BINUTILS \ + BINUTILS_BOOTSTRAP \ BLUETOOTH \ BMAKE \ BOOT \ @@ -387,13 +388,13 @@ __TT=${MACHINE} .endif # Clang is only for x86, powerpc and little-endian arm right now, by default. .if ${__T} == "amd64" || ${__T} == "i386" || ${__T:Mpowerpc*} -__DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL +__DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL CLANG_BOOTSTRAP .elif ${__T} == "arm" || ${__T} == "armv6" || ${__T} == "armv6hf" -__DEFAULT_YES_OPTIONS+=CLANG +__DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP # GCC is unable to build the full clang on arm, disable it by default. __DEFAULT_NO_OPTIONS+=CLANG_FULL .else -__DEFAULT_NO_OPTIONS+=CLANG CLANG_FULL +__DEFAULT_NO_OPTIONS+=CLANG CLANG_FULL CLANG_BOOTSTRAP .endif # Clang the default system compiler only on little-endian arm and x86. .if ${__T} == "amd64" || ${__T} == "arm" || ${__T} == "armv6" || \ @@ -403,14 +404,14 @@ __DEFAULT_NO_OPTIONS+=GNUCXX # The pc98 bootloader requires gcc to build and so we must leave gcc enabled # for pc98 for now. .if ${__TT} == "pc98" -__DEFAULT_YES_OPTIONS+=GCC +__DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP .else -__DEFAULT_NO_OPTIONS+=GCC +__DEFAULT_NO_OPTIONS+=GCC GCC_BOOTSTRAP .endif .else # If clang is not cc, then build gcc by default -__DEFAULT_NO_OPTIONS+=CLANG_IS_CC -__DEFAULT_YES_OPTIONS+=GCC GNUCXX +__DEFAULT_NO_OPTIONS+=CLANG_IS_CC CLANG CLANG_BOOTSTRAP +__DEFAULT_YES_OPTIONS+=GCC GNUCXX GCC_BOOTSTRAP .endif # @@ -531,6 +532,12 @@ MK_AUTHPF:= no MK_GROFF:= no .endif +.if ${MK_CROSS_COMPILER} == "no" +MK_BINUTILS_BOOTSTRAP:= no +MK_CLANG_BOOTSTRAP:= no +MK_GCC_BOOTSTRAP:= no +.endif + .if ${MK_TOOLCHAIN} == "no" MK_BINUTILS:= no MK_CLANG:= no diff --git a/tools/build/options/WITHOUT_BINUTILS b/tools/build/options/WITHOUT_BINUTILS index 62a614e94d0e..5270bd7fd851 100644 --- a/tools/build/options/WITHOUT_BINUTILS +++ b/tools/build/options/WITHOUT_BINUTILS @@ -1,7 +1,7 @@ .\" $FreeBSD$ -Set to not install binutils (as, c++-filt, gconv, -ld, nm, objcopy, objdump, readelf, size and strip). -.Bf -symbolic -The option does not generally work for build targets, unless some alternative -toolchain is enabled. -.Ef +Set to not build or install binutils (as, c++-filt, gconv, +ld, nm, objcopy, objdump, readelf, size and strip) as part +of the normal system build. +The resulting system cannot build programs from source. + + diff --git a/tools/build/options/WITHOUT_BINUTILS_BOOTSTRAP b/tools/build/options/WITHOUT_BINUTILS_BOOTSTRAP new file mode 100644 index 000000000000..84ae1a1706f2 --- /dev/null +++ b/tools/build/options/WITHOUT_BINUTILS_BOOTSTRAP @@ -0,0 +1,8 @@ +.\" $FreeBSD$ +Set to not build binutils (as, c++-filt, gconv, +ld, nm, objcopy, objdump, readelf, size and strip) +as part of the bootstrap process. +.Bf -symbolic +The option does not work for build targets unless some alternative +toolchain is provided. +.Ef diff --git a/tools/build/options/WITHOUT_CLANG b/tools/build/options/WITHOUT_CLANG index 62a90bab215e..51c9c514e68b 100644 --- a/tools/build/options/WITHOUT_CLANG +++ b/tools/build/options/WITHOUT_CLANG @@ -1,2 +1,2 @@ .\" $FreeBSD$ -Set to not build the Clang C/C++ compiler. +Set to not build the Clang C/C++ compiler during the regular phase of the build. diff --git a/tools/build/options/WITHOUT_CLANG_BOOTSTRAP b/tools/build/options/WITHOUT_CLANG_BOOTSTRAP new file mode 100644 index 000000000000..a22046d19248 --- /dev/null +++ b/tools/build/options/WITHOUT_CLANG_BOOTSTRAP @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Set to not build the Clang C/C++ compiler during the bootstrap phase of the build. +You must enable wither gcc or clang bootstrap to be able to build the system, +unless an alternative compiiler is provided via +XCC. diff --git a/tools/build/options/WITHOUT_CROSS_COMPILER b/tools/build/options/WITHOUT_CROSS_COMPILER index 1ded25b06573..ab1bd235bb05 100644 --- a/tools/build/options/WITHOUT_CROSS_COMPILER +++ b/tools/build/options/WITHOUT_CROSS_COMPILER @@ -1,3 +1,13 @@ .\" $FreeBSD$ -Set to not build a cross compiler in the cross-tools stage of -buildworld, buildkernel, etc. +Set to not build any cross compiler in the cross-tools stage of buildworld. +If you are compiling a different version of +.Fx +than what is installed on the system, you will need to provide an alternate +compiler with XCC to ensure success. +If you are compiling with an identical version of +.Fx +to the host, this option may be safely used. +This option may also be safe when the host version of +.Fx +is close to the sources being built, but all bets are off if there have +been any changes to the toolchain between the versions. diff --git a/tools/build/options/WITHOUT_GCC b/tools/build/options/WITHOUT_GCC index 7bb21f8b8375..c746d16dc076 100644 --- a/tools/build/options/WITHOUT_GCC +++ b/tools/build/options/WITHOUT_GCC @@ -1,2 +1,2 @@ .\" $FreeBSD$ -Set to not build and install gcc and g++. +Set to not build and install gcc and g++ as part of the normal build process. diff --git a/tools/build/options/WITHOUT_GCC_BOOTSTRAP b/tools/build/options/WITHOUT_GCC_BOOTSTRAP new file mode 100644 index 000000000000..668ff14496a0 --- /dev/null +++ b/tools/build/options/WITHOUT_GCC_BOOTSTRAP @@ -0,0 +1,5 @@ +.\" $FreeBSD$ +Set to not build gcc and g++ as part of the bootstrap process. +You must enable wither gcc or clang bootstrap to be able to build the system, +unless an alternative compiiler is provided via +XCC. diff --git a/tools/build/options/WITH_CLANG b/tools/build/options/WITH_CLANG index b0e300a488b1..0174b4db4e38 100644 --- a/tools/build/options/WITH_CLANG +++ b/tools/build/options/WITH_CLANG @@ -1,2 +1,2 @@ .\" $FreeBSD$ -Set to build the Clang C/C++ compiler. +Set to build the Clang C/C++ compiler during the normal phase of the build. diff --git a/tools/build/options/WITH_CLANG_BOOTSTRAP b/tools/build/options/WITH_CLANG_BOOTSTRAP new file mode 100644 index 000000000000..792512d57e93 --- /dev/null +++ b/tools/build/options/WITH_CLANG_BOOTSTRAP @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to build the Clang C/C++ compiler during the bootstrap phase of the build. diff --git a/tools/build/options/WITH_GCC_BOOTSTRAP b/tools/build/options/WITH_GCC_BOOTSTRAP new file mode 100644 index 000000000000..8e04b11fb483 --- /dev/null +++ b/tools/build/options/WITH_GCC_BOOTSTRAP @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to build gcc and g++ as part of the bootstrap process.