From 7d0c2b1131b68f5b120b2df0784cb9da5688f8d9 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 17 Aug 2020 20:11:43 +0000 Subject: [PATCH] Add a USE_GCC_TOOLCHAINS knob to make universe. This uses GCC toolchains instead of LLVM on architectures supported by GCC. Currently this uses GCC 6 on aarch64, amd64, i386, and mips. Although this does also try to use GCC 6 on powerpc, it is always skipped for now since a powerpc-gcc6 package is not available and the structure of make universe makes it hard to skip a subset of arches for a target. This should be short-lived as freebsd-gcc9 does include a powerpc-gcc9 package so powerpc should work once this switches to GCC 9. Discussed with: emaste Differential Revision: https://reviews.freebsd.org/D25732 --- Makefile | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 8e9c95eb783d..fa863432e1e7 100644 --- a/Makefile +++ b/Makefile @@ -513,14 +513,20 @@ TARGET_ARCHES_riscv?= riscv64 riscv64sf TARGET_ARCHES_${target}?= ${target} .endfor -# Remove architectures only supported by external toolchain from -# universe if required toolchain packages are missing. -# Note: We no longer have targets that require an external toolchain, but for -# now keep this block in case a new non-LLVM architecture is added and to reuse -# it for a future extenal GCC make universe variant. -_external_toolchain_targets= -.for target in ${_external_toolchain_targets} -.if ${_UNIVERSE_TARGETS:M${target}} +.if defined(USE_GCC_TOOLCHAINS) +TOOLCHAINS_amd64= amd64-gcc6 +TOOLCHAINS_arm64= aarch64-gcc6 +TOOLCHAINS_i386= i386-gcc6 +TOOLCHAINS_mips= mips-gcc6 +TOOLCHAINS_powerpc= powerpc-gcc6 powerpc64-gcc6 +TOOLCHAIN_powerpc64= powerpc64-gcc6 +.endif + +# If a target is using an external toolchain, set MAKE_PARAMS to enable use +# of the toolchain. If the external toolchain is missing, exclude the target +# from universe. +.for target in ${_UNIVERSE_TARGETS} +.if !empty(TOOLCHAINS_${target}) .for toolchain in ${TOOLCHAINS_${target}} .if !exists(/usr/local/share/toolchains/${toolchain}.mk) _UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:N${target}} @@ -530,6 +536,10 @@ universe_${toolchain}_skip: universe_prologue .PHONY @echo ">> ${target} skipped - install ${toolchain} port or package to build" .endif .endfor +.for arch in ${TARGET_ARCHES_${target}} +TOOLCHAIN_${arch}?= ${TOOLCHAINS_${target}:[1]} +MAKE_PARAMS_${arch}?= CROSS_TOOLCHAIN=${TOOLCHAIN_${arch}} +.endfor .endif .endfor @@ -604,7 +614,7 @@ universe_${target}_worlds: .PHONY _need_clang_${target}_${target_arch} != \ env TARGET=${target} TARGET_ARCH=${target_arch} \ ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-compiler \ - ${MAKE_PARAMS_${target}} -V MK_CLANG_BOOTSTRAP 2>/dev/null || \ + ${MAKE_PARAMS_${target_arch}} -V MK_CLANG_BOOTSTRAP 2>/dev/null || \ echo unknown .export _need_clang_${target}_${target_arch} .endif @@ -612,7 +622,7 @@ _need_clang_${target}_${target_arch} != \ _need_lld_${target}_${target_arch} != \ env TARGET=${target} TARGET_ARCH=${target_arch} \ ${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-linker \ - ${MAKE_PARAMS_${target}} -V MK_LLD_BOOTSTRAP 2>/dev/null || \ + ${MAKE_PARAMS_${target_arch}} -V MK_LLD_BOOTSTRAP 2>/dev/null || \ echo unknown .export _need_lld_${target}_${target_arch} .endif @@ -628,7 +638,7 @@ _need_lld_${target}_${target_arch} != \ # supports all TARGETS though. # For now we only pass UNIVERSE_TOOLCHAIN_PATH which will be added at the end # of STRICTTMPPATH to ensure that the target-specific binaries come first. -MAKE_PARAMS_${target}+= \ +MAKE_PARAMS_${target_arch}+= \ XCC="${HOST_OBJTOP}/tmp/usr/bin/cc" \ XCXX="${HOST_OBJTOP}/tmp/usr/bin/c++" \ XCPP="${HOST_OBJTOP}/tmp/usr/bin/cpp" \ @@ -636,7 +646,7 @@ MAKE_PARAMS_${target}+= \ .endif .if defined(_need_lld_${target}_${target_arch}) && \ ${_need_lld_${target}_${target_arch}} == "yes" -MAKE_PARAMS_${target}+= \ +MAKE_PARAMS_${target_arch}+= \ XLD="${HOST_OBJTOP}/tmp/usr/bin/ld" .endif .endfor @@ -659,7 +669,7 @@ universe_${target}_${target_arch}: universe_${target}_prologue .MAKE .PHONY ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \ TARGET=${target} \ TARGET_ARCH=${target_arch} \ - ${MAKE_PARAMS_${target}} \ + ${MAKE_PARAMS_${target_arch}} \ > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \ (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \ "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \ @@ -724,7 +734,7 @@ universe_kernconf_${TARGET}_${kernel}: .MAKE ${SUB_MAKE} ${JFLAG} buildkernel \ TARGET=${TARGET} \ TARGET_ARCH=${TARGET_ARCH_${kernel}} \ - ${MAKE_PARAMS_${TARGET}} \ + ${MAKE_PARAMS_${TARGET_ARCH}} \ KERNCONF=${kernel} \ > _.${TARGET}.${kernel} 2>&1 || \ (echo "${TARGET} ${kernel} kernel failed," \