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
This commit is contained in:
John Baldwin 2020-08-17 20:11:43 +00:00
parent d3fd812ca9
commit 7d0c2b1131

View File

@ -513,14 +513,20 @@ TARGET_ARCHES_riscv?= riscv64 riscv64sf
TARGET_ARCHES_${target}?= ${target} TARGET_ARCHES_${target}?= ${target}
.endfor .endfor
# Remove architectures only supported by external toolchain from .if defined(USE_GCC_TOOLCHAINS)
# universe if required toolchain packages are missing. TOOLCHAINS_amd64= amd64-gcc6
# Note: We no longer have targets that require an external toolchain, but for TOOLCHAINS_arm64= aarch64-gcc6
# now keep this block in case a new non-LLVM architecture is added and to reuse TOOLCHAINS_i386= i386-gcc6
# it for a future extenal GCC make universe variant. TOOLCHAINS_mips= mips-gcc6
_external_toolchain_targets= TOOLCHAINS_powerpc= powerpc-gcc6 powerpc64-gcc6
.for target in ${_external_toolchain_targets} TOOLCHAIN_powerpc64= powerpc64-gcc6
.if ${_UNIVERSE_TARGETS:M${target}} .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}} .for toolchain in ${TOOLCHAINS_${target}}
.if !exists(/usr/local/share/toolchains/${toolchain}.mk) .if !exists(/usr/local/share/toolchains/${toolchain}.mk)
_UNIVERSE_TARGETS:= ${_UNIVERSE_TARGETS:N${target}} _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" @echo ">> ${target} skipped - install ${toolchain} port or package to build"
.endif .endif
.endfor .endfor
.for arch in ${TARGET_ARCHES_${target}}
TOOLCHAIN_${arch}?= ${TOOLCHAINS_${target}:[1]}
MAKE_PARAMS_${arch}?= CROSS_TOOLCHAIN=${TOOLCHAIN_${arch}}
.endfor
.endif .endif
.endfor .endfor
@ -604,7 +614,7 @@ universe_${target}_worlds: .PHONY
_need_clang_${target}_${target_arch} != \ _need_clang_${target}_${target_arch} != \
env TARGET=${target} TARGET_ARCH=${target_arch} \ env TARGET=${target} TARGET_ARCH=${target_arch} \
${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-compiler \ ${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 echo unknown
.export _need_clang_${target}_${target_arch} .export _need_clang_${target}_${target_arch}
.endif .endif
@ -612,7 +622,7 @@ _need_clang_${target}_${target_arch} != \
_need_lld_${target}_${target_arch} != \ _need_lld_${target}_${target_arch} != \
env TARGET=${target} TARGET_ARCH=${target_arch} \ env TARGET=${target} TARGET_ARCH=${target_arch} \
${SUB_MAKE} -C ${.CURDIR} -f Makefile.inc1 test-system-linker \ ${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 echo unknown
.export _need_lld_${target}_${target_arch} .export _need_lld_${target}_${target_arch}
.endif .endif
@ -628,7 +638,7 @@ _need_lld_${target}_${target_arch} != \
# supports all TARGETS though. # supports all TARGETS though.
# For now we only pass UNIVERSE_TOOLCHAIN_PATH which will be added at the end # 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. # 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" \ XCC="${HOST_OBJTOP}/tmp/usr/bin/cc" \
XCXX="${HOST_OBJTOP}/tmp/usr/bin/c++" \ XCXX="${HOST_OBJTOP}/tmp/usr/bin/c++" \
XCPP="${HOST_OBJTOP}/tmp/usr/bin/cpp" \ XCPP="${HOST_OBJTOP}/tmp/usr/bin/cpp" \
@ -636,7 +646,7 @@ MAKE_PARAMS_${target}+= \
.endif .endif
.if defined(_need_lld_${target}_${target_arch}) && \ .if defined(_need_lld_${target}_${target_arch}) && \
${_need_lld_${target}_${target_arch}} == "yes" ${_need_lld_${target}_${target_arch}} == "yes"
MAKE_PARAMS_${target}+= \ MAKE_PARAMS_${target_arch}+= \
XLD="${HOST_OBJTOP}/tmp/usr/bin/ld" XLD="${HOST_OBJTOP}/tmp/usr/bin/ld"
.endif .endif
.endfor .endfor
@ -659,7 +669,7 @@ universe_${target}_${target_arch}: universe_${target}_prologue .MAKE .PHONY
${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \ ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
TARGET=${target} \ TARGET=${target} \
TARGET_ARCH=${target_arch} \ TARGET_ARCH=${target_arch} \
${MAKE_PARAMS_${target}} \ ${MAKE_PARAMS_${target_arch}} \
> _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \ > _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
(echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \ (echo "${target}.${target_arch} ${UNIVERSE_TARGET} failed," \
"check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \ "check _.${target}.${target_arch}.${UNIVERSE_TARGET} for details" | \
@ -724,7 +734,7 @@ universe_kernconf_${TARGET}_${kernel}: .MAKE
${SUB_MAKE} ${JFLAG} buildkernel \ ${SUB_MAKE} ${JFLAG} buildkernel \
TARGET=${TARGET} \ TARGET=${TARGET} \
TARGET_ARCH=${TARGET_ARCH_${kernel}} \ TARGET_ARCH=${TARGET_ARCH_${kernel}} \
${MAKE_PARAMS_${TARGET}} \ ${MAKE_PARAMS_${TARGET_ARCH}} \
KERNCONF=${kernel} \ KERNCONF=${kernel} \
> _.${TARGET}.${kernel} 2>&1 || \ > _.${TARGET}.${kernel} 2>&1 || \
(echo "${TARGET} ${kernel} kernel failed," \ (echo "${TARGET} ${kernel} kernel failed," \