From 6889c8c0a48e2b9f7252e4627bad3c310d3e2f64 Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Sat, 10 Jan 2026 02:07:14 +0100 Subject: [PATCH] drop `find_toolchains`, `SKIP_EXTERNAL_TOOLCHAINS` and all `$toolchain` `PATH` injections - we've had SKIP_EXTERNAL_TOOLCHAINS=yes for ~5 years now - drop all usages, mostly through `find_toolchains()` - drop all manual PATH env injections (we've centralized if ever needed) --- config/sources/amd64.conf | 1 - config/sources/arm64.conf | 4 +- config/sources/armhf.conf | 4 +- config/sources/families/jethub.conf | 24 ++---- config/sources/families/mvebu64.conf | 6 +- config/sources/loong64.conf | 1 - config/sources/riscv64.conf | 1 - lib/functions/compilation/atf.sh | 22 +---- lib/functions/compilation/crust.sh | 16 +--- lib/functions/compilation/kernel-make.sh | 4 +- lib/functions/compilation/uboot.sh | 32 ++----- .../compilation/utils-compilation.sh | 83 ------------------- lib/functions/configuration/main-config.sh | 1 - lib/functions/host/external-toolchains.sh | 77 ----------------- lib/functions/host/prepare-host.sh | 5 -- 15 files changed, 27 insertions(+), 254 deletions(-) delete mode 100644 lib/functions/host/external-toolchains.sh diff --git a/config/sources/amd64.conf b/config/sources/amd64.conf index de31b4c0a3..568fb68667 100644 --- a/config/sources/amd64.conf +++ b/config/sources/amd64.conf @@ -32,7 +32,6 @@ declare -g KERNEL_INSTALL_TYPE="${KERNEL_INSTALL_TYPE:-"install"}" if [[ "$(uname -m)" == "aarch64" ]]; then # Allow building amd64 on aarch64, but using system toolchain only declare -g KERNEL_COMPILER="x86_64-linux-gnu-" - declare -g SKIP_EXTERNAL_TOOLCHAINS=yes declare -g UBOOT_COMPILER='x86_64-linux-gnu-' fi diff --git a/config/sources/arm64.conf b/config/sources/arm64.conf index d6ff527ed6..d0989a150d 100644 --- a/config/sources/arm64.conf +++ b/config/sources/arm64.conf @@ -47,7 +47,7 @@ fi [[ $ATF_COMPILE != "no" && -z $ATF_USE_GCC ]] && ATF_USE_GCC='> 8.0' # System toolchains don't have the -none- variant, remove it -[[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]] && UBOOT_COMPILER="${UBOOT_COMPILER//-none-/-}" -[[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]] && ATF_COMPILER="${ATF_COMPILER//-none-/-}" +UBOOT_COMPILER="${UBOOT_COMPILER//-none-/-}" +ATF_COMPILER="${ATF_COMPILER//-none-/-}" true # make sure to exit with 0 status; this protects against shortcircuits etc above. diff --git a/config/sources/armhf.conf b/config/sources/armhf.conf index 37e630fdb2..2798e22fe9 100644 --- a/config/sources/armhf.conf +++ b/config/sources/armhf.conf @@ -38,7 +38,7 @@ else fi # System toolchains don't have the -none- variant, remove it -[[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]] && UBOOT_COMPILER="${UBOOT_COMPILER//-none-/-}" -[[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]] && ATF_COMPILER="${ATF_COMPILER//-none-/-}" +UBOOT_COMPILER="${UBOOT_COMPILER//-none-/-}" +ATF_COMPILER="${ATF_COMPILER//-none-/-}" true # make sure to exit with 0 status; this protects against shortcircuits etc above. diff --git a/config/sources/families/jethub.conf b/config/sources/families/jethub.conf index 481ae65f06..60835d3b3a 100644 --- a/config/sources/families/jethub.conf +++ b/config/sources/families/jethub.conf @@ -140,21 +140,15 @@ comment_default_rsyslog_rules() { buildjethomecmds() { local toolchain - # build aarch64 in amd64 - if [[ $(dpkg --print-architecture) == amd64 ]]; then - toolchain=$(find_toolchain "$UBOOT_COMPILER" "$UBOOT_USE_GCC") - [[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${UBOOT_COMPILER}gcc $UBOOT_USE_GCC" - fi - - display_alert "Compiler version" "${UBOOT_COMPILER}gcc $(eval env PATH="${toolchain}:${PATH}" "${UBOOT_COMPILER}gcc" -dumpversion)" "info" + display_alert "Compiler version" "${UBOOT_COMPILER}gcc $(eval env "${UBOOT_COMPILER}gcc" -dumpversion)" "info" local gpp="${UBOOT_COMPILER}g++" local gpp_options="-Os -s -Wall -Wextra -std=c++17 -I$SRC/packages/bsp/jethub" local gcc="${UBOOT_COMPILER}gcc" - run_host_command_logged env PATH="${toolchain}:${PATH}" "$gpp" $gpp_options "$SRC/packages/bsp/jethub/jethub_get_cmdline_key.cpp" -o "$destination/usr/bin/jethub_get_cmdline_key" || exit_with_error "Unable to compile jethub_get_cmdline_key.cpp" - run_host_command_logged env PATH="${toolchain}:${PATH}" "$gpp" $gpp_options "$SRC/packages/bsp/jethub/jethub_get_cmdline_key_cpuid.cpp" -o "$destination/usr/bin/jethub_get_cpuid" || exit_with_error "Unable to compile jethub_get_cmdline_key_cpuid.cpp" + run_host_command_logged env "$gpp" $gpp_options "$SRC/packages/bsp/jethub/jethub_get_cmdline_key.cpp" -o "$destination/usr/bin/jethub_get_cmdline_key" || exit_with_error "Unable to compile jethub_get_cmdline_key.cpp" + run_host_command_logged env "$gpp" $gpp_options "$SRC/packages/bsp/jethub/jethub_get_cmdline_key_cpuid.cpp" -o "$destination/usr/bin/jethub_get_cpuid" || exit_with_error "Unable to compile jethub_get_cmdline_key_cpuid.cpp" if [[ "$BOARD" == "jethubj80" ]]; then # Bluetooth @@ -165,15 +159,15 @@ buildjethomecmds() { run_host_command_logged install -m 755 "$SRC/packages/bsp/jethub/$BOARD/bluetooth/jethub-rtk-hciattach-starter" "$destination/usr/lib/armbian/" || exit_with_error "Unable to install jethub-rtk-hciattach-starter" # Board eth led setup - run_host_command_logged env PATH="${toolchain}:${PATH}" "$gcc" "$SRC/packages/bsp/jethub/$BOARD/jethub_set_eth_leds.c" -o "$destination/usr/sbin/jethub_set-eth_leds" || exit_with_error "Unable to compile jethub_set_eth_leds.c" + run_host_command_logged "$gcc" "$SRC/packages/bsp/jethub/$BOARD/jethub_set_eth_leds.c" -o "$destination/usr/sbin/jethub_set-eth_leds" || exit_with_error "Unable to compile jethub_set_eth_leds.c" # Board identifiers - run_host_command_logged env PATH="${toolchain}:${PATH}" "$gpp" $gpp_options "$SRC/packages/bsp/jethub/$BOARD/jethub_get_efuse_raw_key.cpp" -o "$destination/usr/bin/jethub_get_efuse_raw_key" || exit_with_error "Unable to compile jethub_get_efuse_raw_key.cpp" - run_host_command_logged env PATH="${toolchain}:${PATH}" "$gpp" $gpp_options "$SRC/packages/bsp/jethub/$BOARD/jethub_get_efuse_key_mac.cpp" -o "$destination/usr/bin/jethub_get_mac" || exit_with_error "Unable to compile jethub_get_efuse_key_mac.cpp" - run_host_command_logged env PATH="${toolchain}:${PATH}" "$gpp" $gpp_options "$SRC/packages/bsp/jethub/$BOARD/jethub_get_efuse_key_serial.cpp" -o "$destination/usr/bin/jethub_get_serial" || exit_with_error "Unable to compile jethub_get_efuse_key_serial.cpp" - run_host_command_logged env PATH="${toolchain}:${PATH}" "$gpp" $gpp_options "$SRC/packages/bsp/jethub/$BOARD/jethub_get_efuse_key_usid.cpp" -o "$destination/usr/bin/jethub_get_usid" || exit_with_error "Unable to compile jethub_get_efuse_key_usid.cpp" + run_host_command_logged "$gpp" $gpp_options "$SRC/packages/bsp/jethub/$BOARD/jethub_get_efuse_raw_key.cpp" -o "$destination/usr/bin/jethub_get_efuse_raw_key" || exit_with_error "Unable to compile jethub_get_efuse_raw_key.cpp" + run_host_command_logged "$gpp" $gpp_options "$SRC/packages/bsp/jethub/$BOARD/jethub_get_efuse_key_mac.cpp" -o "$destination/usr/bin/jethub_get_mac" || exit_with_error "Unable to compile jethub_get_efuse_key_mac.cpp" + run_host_command_logged "$gpp" $gpp_options "$SRC/packages/bsp/jethub/$BOARD/jethub_get_efuse_key_serial.cpp" -o "$destination/usr/bin/jethub_get_serial" || exit_with_error "Unable to compile jethub_get_efuse_key_serial.cpp" + run_host_command_logged "$gpp" $gpp_options "$SRC/packages/bsp/jethub/$BOARD/jethub_get_efuse_key_usid.cpp" -o "$destination/usr/bin/jethub_get_usid" || exit_with_error "Unable to compile jethub_get_efuse_key_usid.cpp" elif [[ "$BOARD" == "jethubj100" ]]; then # Board identifiers - run_host_command_logged env PATH="${toolchain}:${PATH}" "$gpp" $gpp_options "$SRC/packages/bsp/jethub/$BOARD/jethub_get_cmdline_key_mac.cpp" -o "$destination/usr/bin/jethub_get_mac" || exit_with_error "Unable to compile jethub_get_cmdline_key_mac.cpp" + run_host_command_logged "$gpp" $gpp_options "$SRC/packages/bsp/jethub/$BOARD/jethub_get_cmdline_key_mac.cpp" -o "$destination/usr/bin/jethub_get_mac" || exit_with_error "Unable to compile jethub_get_cmdline_key_mac.cpp" # Wifi & Bluetooth run_host_command_logged mkdir -pv --mode=755 "$destination/lib/firmware/" || exit_with_error "Unable to mkdir firmware" diff --git a/config/sources/families/mvebu64.conf b/config/sources/families/mvebu64.conf index df6356609d..5818c9437e 100644 --- a/config/sources/families/mvebu64.conf +++ b/config/sources/families/mvebu64.conf @@ -31,11 +31,7 @@ declare -g ATFDIR='arm-trusted-firmware-espressobin' declare -g ATFBRANCH='tag:lts-v2.12.8' declare -g ATF_USE_GCC='> 7.2' -if [[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]]; then - ATF_COMPILER='aarch64-linux-gnu-' -else - ATF_COMPILER='aarch64-none-linux-gnu-' -fi +ATF_COMPILER='aarch64-linux-gnu-' if [[ $BOARD = macchiatobin-doubleshot ]]; then export SCP_BL2=$SRC/cache/sources/marvell-binaries/mrvl_scp_bl2.img # ATTENTION! This is actually a required 'export', since it's picked up by ATF's make. diff --git a/config/sources/loong64.conf b/config/sources/loong64.conf index abdf51ff95..3a2381bf3c 100644 --- a/config/sources/loong64.conf +++ b/config/sources/loong64.conf @@ -12,7 +12,6 @@ declare -g ARCH='loong64' declare -g ARCHITECTURE='loongarch' declare -g QEMU_BINARY='qemu-loongarch64-static' declare -g IMAGE_PARTITION_TABLE='gpt' -declare -g SKIP_EXTERNAL_TOOLCHAINS='yes' declare -g KERNEL_SRC_ARCH='loongarch' # Linux root has a different Type-UUID for every architecture diff --git a/config/sources/riscv64.conf b/config/sources/riscv64.conf index 636db2a1ed..63a1e36845 100644 --- a/config/sources/riscv64.conf +++ b/config/sources/riscv64.conf @@ -13,7 +13,6 @@ declare -g ARCHITECTURE='riscv' declare -g KERNEL_SRC_ARCH='riscv' declare -g QEMU_BINARY='qemu-riscv64-static' declare -g IMAGE_PARTITION_TABLE='gpt' -declare -g SKIP_EXTERNAL_TOOLCHAINS='yes' # Linux root has a different Type-UUID for every architecture # See https://uapi-group.org/specifications/specs/discoverable_partitions_specification/ diff --git a/lib/functions/compilation/atf.sh b/lib/functions/compilation/atf.sh index 850d783d65..c8184037f7 100644 --- a/lib/functions/compilation/atf.sh +++ b/lib/functions/compilation/atf.sh @@ -31,25 +31,7 @@ compile_atf() { display_alert "Compiling ATF" "" "info" - # build aarch64 - if [[ $(dpkg --print-architecture) == amd64 ]]; then - - local toolchain - toolchain=$(find_toolchain "$ATF_COMPILER" "$ATF_USE_GCC") - [[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${ATF_COMPILER}gcc $ATF_USE_GCC" - - if [[ -n $ATF_TOOLCHAIN2 ]]; then - local toolchain2_type toolchain2_ver toolchain2 - toolchain2_type=$(cut -d':' -f1 <<< "${ATF_TOOLCHAIN2}") - toolchain2_ver=$(cut -d':' -f2 <<< "${ATF_TOOLCHAIN2}") - toolchain2=$(find_toolchain "$toolchain2_type" "$toolchain2_ver") - [[ -z $toolchain2 ]] && exit_with_error "Could not find required toolchain" "${toolchain2_type}gcc $toolchain2_ver" - fi - - # build aarch64 - fi - - display_alert "Compiler version" "${ATF_COMPILER}gcc $(eval env PATH="${toolchain}:${PATH}" "${ATF_COMPILER}gcc" -dumpfullversion -dumpversion)" "info" + display_alert "Compiler version" "${ATF_COMPILER}gcc $(eval env "${ATF_COMPILER}gcc" -dumpfullversion -dumpversion)" "info" local target_make target_patchdir target_files target_make=$(cut -d';' -f1 <<< "${ATF_TARGET_MAP}") @@ -101,7 +83,7 @@ compile_atf() { # - ENABLE_BACKTRACE="0" has been added to workaround a regression in ATF. Check: https://github.com/armbian/build/issues/1157 - run_host_command_logged "CROSS_COMPILE='ccache ${ATF_COMPILER}'" CCACHE_BASEDIR="$(pwd)" "CC='ccache ${ATF_COMPILER}gcc'" PATH="${toolchain}:${toolchain2}:${PATH}" \ + run_host_command_logged "CROSS_COMPILE='ccache ${ATF_COMPILER}'" CCACHE_BASEDIR="$(pwd)" "CC='ccache ${ATF_COMPILER}gcc'" \ "CFLAGS='-fdiagnostics-color=always -Wno-error=attributes -Wno-error=incompatible-pointer-types'" \ "TF_LDFLAGS='${binutils_flags_atf}'" \ make ENABLE_BACKTRACE="0" LOG_LEVEL="40" BUILD_STRING="armbian" $target_make "${CTHREADS}" diff --git a/lib/functions/compilation/crust.sh b/lib/functions/compilation/crust.sh index 16a03db895..d88a1dbeb7 100644 --- a/lib/functions/compilation/crust.sh +++ b/lib/functions/compilation/crust.sh @@ -31,15 +31,7 @@ compile_crust() { display_alert "Compiling Crust" "" "info" - # build aarch64 - if [[ $(dpkg --print-architecture) == amd64 ]]; then - - local toolchain - toolchain=$(find_toolchain "$CRUST_COMPILER" "$CRUST_USE_GCC") - [[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${CRUST_COMPILER}gcc $CRUST_USE_GCC" - fi - - display_alert "Compiler version" "${CRUST_COMPILER}gcc $(eval env PATH="${toolchain}:${PATH}" "${CRUST_COMPILER}gcc" -dumpfullversion -dumpversion)" "info" + display_alert "Compiler version" "${CRUST_COMPILER}gcc $(eval env "${CRUST_COMPILER}gcc" -dumpfullversion -dumpversion)" "info" local target_make target_patchdir target_files target_make=$(cut -d';' -f1 <<< "${CRUST_TARGET_MAP}") @@ -55,14 +47,14 @@ compile_crust() { fi declare binutils_version binutils_flags_crust="" - binutils_version=$(env PATH="${toolchain}:${PATH}" or1k-elf-ld.bfd --version | head -1 | cut -d ")" -f 2 | xargs echo -n) + binutils_version=$(env or1k-elf-ld.bfd --version | head -1 | cut -d ")" -f 2 | xargs echo -n) display_alert "Binutils version for Crust" "${binutils_version}" "info" - run_host_command_logged CCACHE_BASEDIR="$(pwd)" PATH="${toolchain}:${toolchain2}:${PATH}" \ + run_host_command_logged CCACHE_BASEDIR="$(pwd)" \ "CFLAGS='-fdiagnostics-color=always -Wno-error=attributes -Wno-error=incompatible-pointer-types'" \ make ${CRUSTCONFIG} "${CTHREADS}" "CROSS_COMPILE='$CCACHE $CRUST_COMPILER'" - run_host_command_logged CCACHE_BASEDIR="$(pwd)" PATH="${toolchain}:${toolchain2}:${PATH}" \ + run_host_command_logged CCACHE_BASEDIR="$(pwd)" \ "CFLAGS='-fdiagnostics-color=always -Wno-error=attributes -Wno-error=incompatible-pointer-types'" \ make $target_make "${CTHREADS}" "CROSS_COMPILE='$CCACHE $CRUST_COMPILER'" diff --git a/lib/functions/compilation/kernel-make.sh b/lib/functions/compilation/kernel-make.sh index 383afae85b..e7da5ad15a 100644 --- a/lib/functions/compilation/kernel-make.sh +++ b/lib/functions/compilation/kernel-make.sh @@ -101,8 +101,6 @@ function kernel_determine_toolchain() { display_alert "Native compilation" "target ${ARCH} on host $(dpkg --print-architecture)" else display_alert "Cross compilation" "target ${ARCH} on host $(dpkg --print-architecture)" - toolchain=$(find_toolchain "$KERNEL_COMPILER" "$KERNEL_USE_GCC") - [[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${KERNEL_COMPILER}gcc $KERNEL_USE_GCC" fi if [[ "${KERNEL_COMPILER}" == "clang" ]]; then @@ -110,6 +108,6 @@ function kernel_determine_toolchain() { else KERNEL_COMPILER_FULL="${KERNEL_COMPILER}gcc" fi - kernel_compiler_version="$(eval env PATH="${toolchain}:${PATH}" "${KERNEL_COMPILER_FULL}" -dumpfullversion -dumpversion)" + kernel_compiler_version="$(eval env "${KERNEL_COMPILER_FULL}" -dumpfullversion -dumpversion)" display_alert "Compiler version" "${KERNEL_COMPILER_FULL} ${kernel_compiler_version}" "info" } diff --git a/lib/functions/compilation/uboot.sh b/lib/functions/compilation/uboot.sh index 4731c68a3d..6bc9ded9e3 100644 --- a/lib/functions/compilation/uboot.sh +++ b/lib/functions/compilation/uboot.sh @@ -47,7 +47,7 @@ function patch_uboot_target() { fi } -# this receives version target uboot_name uboottempdir uboot_target_counter toolchain as variables. +# this receives version target uboot_name uboottempdir uboot_target_counter as variables. # also receives uboot_prefix, target_make, target_patchdir, target_files as input function compile_uboot_target() { : "${artifact_version:?artifact_version is not set}" @@ -90,7 +90,7 @@ function compile_uboot_target() { display_alert "${uboot_prefix}Preparing u-boot config '${BOOTCONFIG}'" "${version} ${target_make}" "info" declare -g if_error_detail_message="${uboot_prefix}Failed to configure u-boot ${version} $BOOTCONFIG ${target_make}" - run_host_command_logged CCACHE_BASEDIR="$(pwd)" PATH="${toolchain}:${toolchain2}:${PATH}" \ + run_host_command_logged CCACHE_BASEDIR="$(pwd)" \ "KCFLAGS=-fdiagnostics-color=always" \ pipetty make "${CTHREADS}" "${BOOTCONFIG}" "CROSS_COMPILE=\"${CCACHE} ${UBOOT_COMPILER}\"" @@ -174,7 +174,7 @@ function compile_uboot_target() { # CONFIG_ERRNO_STR is not set EXTRA_UBOOT_DEBUG_CONFIGS - run_host_command_logged CCACHE_BASEDIR="$(pwd)" PATH="${toolchain}:${toolchain2}:${PATH}" \ + run_host_command_logged CCACHE_BASEDIR="$(pwd)" \ "KCFLAGS=-fdiagnostics-color=always" \ pipetty make "olddefconfig" "CROSS_COMPILE=\"$CCACHE $UBOOT_COMPILER\"" @@ -205,7 +205,7 @@ function compile_uboot_target() { # make olddefconfig, so changes made in hook above are consolidated display_alert "${uboot_prefix}Updating u-boot config with olddefconfig" "${version} ${target_make}" "info" - run_host_command_logged CCACHE_BASEDIR="$(pwd)" PATH="${toolchain}:${toolchain2}:${PATH}" \ + run_host_command_logged CCACHE_BASEDIR="$(pwd)" \ "KCFLAGS=-fdiagnostics-color=always" \ pipetty make "${CTHREADS}" "olddefconfig" "CROSS_COMPILE=\"${CCACHE} ${UBOOT_COMPILER}\"" @@ -240,13 +240,10 @@ function compile_uboot_target() { "CFLAGS='${uboot_cflags}'" "KCFLAGS='${uboot_cflags}'" "CCACHE_BASEDIR=$(pwd)" - "PATH=${toolchain}:${toolchain2}:${PATH}" "PYTHONPATH=\"${PYTHON3_INFO[MODULES_PATH]}:${PYTHONPATH}\"" # Insert the pip modules downloaded by Armbian into PYTHONPATH (needed e.g. for pyelftools) ) - # workaround when two compilers are needed cross_compile="CROSS_COMPILE=\"$CCACHE $UBOOT_COMPILER\"" - [[ -n $UBOOT_TOOLCHAIN2 ]] && cross_compile="ARMBIAN=foe" # empty parameter is not allowed display_alert "${uboot_prefix}Compiling u-boot" "${version} ${target_make} with gcc '${gcc_version_main}'" "info" declare -g if_error_detail_message="${uboot_prefix}Failed to build u-boot ${version} ${target_make}" @@ -334,7 +331,7 @@ function loop_over_uboot_targets_and_do() { eval "${_old_nullglob}" IFS="${_old_ifs}" # restore for the body of loop - declare -g target uboot_name uboottempdir toolchain version + declare -g target uboot_name uboottempdir version declare -g uboot_prefix="{u-boot:${uboot_target_counter}} " declare -g target_make target_patchdir target_files target_make=$(cut -d';' -f1 <<< "${target}") @@ -409,26 +406,9 @@ function compile_uboot() { display_alert "Compiling u-boot" "$version ${ubootdir}" "info" - # build aarch64 - if [[ $(dpkg --print-architecture) == amd64 ]]; then - local toolchain - toolchain=$(find_toolchain "$UBOOT_COMPILER" "$UBOOT_USE_GCC") - [[ -z $toolchain ]] && exit_with_error "Could not find required toolchain" "${UBOOT_COMPILER}gcc $UBOOT_USE_GCC" - - if [[ -n $UBOOT_TOOLCHAIN2 ]]; then - local toolchain2_type toolchain2_ver toolchain2 - toolchain2_type=$(cut -d':' -f1 <<< "${UBOOT_TOOLCHAIN2}") - toolchain2_ver=$(cut -d':' -f2 <<< "${UBOOT_TOOLCHAIN2}") - toolchain2=$(find_toolchain "$toolchain2_type" "$toolchain2_ver") - [[ -z $toolchain2 ]] && exit_with_error "Could not find required toolchain" "${toolchain2_type}gcc $toolchain2_ver" - fi - # build aarch64 - fi - declare gcc_version_main - gcc_version_main="$(eval env PATH="${toolchain}:${toolchain2}:${PATH}" "${UBOOT_COMPILER}gcc" -dumpfullversion -dumpversion)" + gcc_version_main="$(eval env "${UBOOT_COMPILER}gcc" -dumpfullversion -dumpversion)" display_alert "Compiler version" "${UBOOT_COMPILER}gcc '${gcc_version_main}'" "info" - [[ -n $toolchain2 ]] && display_alert "Additional compiler version" "${toolchain2_type}gcc $(eval env PATH="${toolchain}:${toolchain2}:${PATH}" "${toolchain2_type}gcc" -dumpfullversion -dumpversion)" "info" local uboot_name="linux-u-boot-${BRANCH}-${BOARD}" diff --git a/lib/functions/compilation/utils-compilation.sh b/lib/functions/compilation/utils-compilation.sh index 96477dea1b..a01b2368db 100644 --- a/lib/functions/compilation/utils-compilation.sh +++ b/lib/functions/compilation/utils-compilation.sh @@ -15,7 +15,6 @@ # compile_firmware # compile_xilinx_bootgen # grab_version -# find_toolchain # advanced_patch # process_patch_file # overlayfs_wrapper @@ -31,88 +30,6 @@ grab_version() { return 0 } -# find_toolchain -# -# returns path to toolchain that satisfies -# -find_toolchain() { - [[ "${SKIP_EXTERNAL_TOOLCHAINS}" == "yes" ]] && { - echo "/usr/bin" - return - } - - local compiler=$1 - local expression=$2 - local dist=10 - - display_alert "SKIP_EXTERNAL_TOOLCHAINS=no, Searching for toolchain" "'${compiler}' '${expression}'" "warn" - - local toolchain="" - - # extract target major.minor version from expression - local target_ver - target_ver=$(grep -oE "[[:digit:]]+\.[[:digit:]]" <<< "$expression") - display_alert "Searching for toolchain" "'${compiler}' '${expression}': target_ver: '${target_ver}'" "debug" - - for dir in "${SRC}"/cache/toolchain/*/; do - display_alert "Checking toolchain" "${dir}" "debug" - local gcc_bin="${dir}bin/${compiler}gcc" - # check if is a toolchain for current $ARCH - if [[ ! -f "${gcc_bin}" ]]; then - display_alert "Can't find compiler" "'${dir}' :: '${gcc_bin}" "debug" - continue - else - display_alert "Found compiler" "'${dir}' :: '${gcc_bin}" "debug" - fi - - declare gcc_bin_info - gcc_bin_info="$(file "${gcc_bin}" || true)" - - display_alert "Testing toolchain" "'${gcc_bin}': '${gcc_bin_info}'" "debug" - - # get toolchain major.minor version - declare gcc_ver_simple - gcc_ver_simple="$("${gcc_bin}" -dumpversion 2>&1 || true)" # this might fail: toolchain can't run on current host - - display_alert "Checking version" "'${gcc_ver_simple}' for '${gcc_bin}'" "debug" - if [[ "x${gcc_ver_simple}x" == "xx" ]]; then - display_alert "Can't obtain version" "'${gcc_bin}' for '${gcc_bin}': '${gcc_ver_simple}'" "debug" - continue - fi - - declare gcc_ver - gcc_ver="$(echo "${gcc_ver_simple}" | grep -oE "^[[:digit:]]+\.[[:digit:]]" || true)" # this might fail to parse - if [[ "x${gcc_ver}x" == "xx" ]]; then - display_alert "Can't parse version" "'${gcc_bin}' for '${gcc_bin}': '${gcc_ver_simple}': '${gcc_ver}'" "debug" - continue - fi - - display_alert "Found working toolchain" "'${gcc_bin}' gcc_ver_simple:'${gcc_ver_simple}' gcc_ver:'${gcc_ver}'" "debug" - - # check if toolchain version satisfies requirement - if ! awk "BEGIN{exit ! ($gcc_ver $expression)}" > /dev/null; then - display_alert "Toolchain version" "'${gcc_bin}' '${gcc_ver}' doesn't satisfy '${expression}'" "debug" - continue - fi - - # check if found version is the closest to target - # may need different logic here with more than 1 digit minor version numbers - # numbers: 3.9 > 3.10; versions: 3.9 < 3.10 - # dpkg --compare-versions can be used here if operators are changed - declare d - d=$(awk '{x = $1 - $2}{printf "%.1f\n", (x > 0) ? x : -x}' <<< "$target_ver $gcc_ver") - if awk "BEGIN{exit ! ($d < $dist)}" > /dev/null; then - dist="$d" - toolchain="${dir}bin" - display_alert "Found toolchain" "'${gcc_bin}' ver:'${gcc_ver}' expression:'${expression}' dist:'${dist}'" "debug" - fi - done - - display_alert "Using toolchain" "${toolchain}" "info" - - echo "$toolchain" -} - # overlayfs_wrapper # # : wrap|cleanup diff --git a/lib/functions/configuration/main-config.sh b/lib/functions/configuration/main-config.sh index 758646bb6e..63b579f3db 100644 --- a/lib/functions/configuration/main-config.sh +++ b/lib/functions/configuration/main-config.sh @@ -60,7 +60,6 @@ function do_main_configuration() { DEST_LANG="${DEST_LANG:-"en_US.UTF-8"}" # en_US.UTF-8 is default locale for target display_alert "DEST_LANG..." "DEST_LANG: ${DEST_LANG}" "debug" - declare -g SKIP_EXTERNAL_TOOLCHAINS="${SKIP_EXTERNAL_TOOLCHAINS:-yes}" # don't use any external toolchains, by default. declare -g USE_CCACHE="${USE_CCACHE:-no}" # stop using ccache as our worktree is more effective # Armbian config is central tool used in all builds. As its build externally, we have moved it to extension. Enable it here. diff --git a/lib/functions/host/external-toolchains.sh b/lib/functions/host/external-toolchains.sh deleted file mode 100644 index 638e699bd8..0000000000 --- a/lib/functions/host/external-toolchains.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash -# -# SPDX-License-Identifier: GPL-2.0 -# -# Copyright (c) 2013-2026 Igor Pecovnik, igor@armbian.com -# -# This file is a part of the Armbian Build Framework -# https://github.com/armbian/build/ - -# This is mostly deprecated, since SKIP_EXTERNAL_TOOLCHAINS=yes by default. - -function download_external_toolchains() { - # build aarch64 - if [[ $(dpkg --print-architecture) == amd64 ]]; then - if [[ "${SKIP_EXTERNAL_TOOLCHAINS}" != "yes" ]]; then - - # bind mount toolchain if defined - if [[ -d "${ARMBIAN_CACHE_TOOLCHAIN_PATH}" ]]; then - mountpoint -q "${SRC}"/cache/toolchain && umount -l "${SRC}"/cache/toolchain - mount --bind "${ARMBIAN_CACHE_TOOLCHAIN_PATH}" "${SRC}"/cache/toolchain - fi - - display_alert "Checking for external GCC compilers" "" "info" - # download external Linaro compiler and missing special dependencies since they are needed for certain sources - - local toolchains=( - "gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabi.tar.xz" - "gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz" - "gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf.tar.xz" - "gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu.tar.xz" - "gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf.tar.xz" - "gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu.tar.xz" - "gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf.tar.xz" - "gcc-arm-11.2-2022.02-x86_64-aarch64-none-linux-gnu.tar.xz" - ) - - USE_TORRENT_STATUS=${USE_TORRENT} - USE_TORRENT="no" - for toolchain in "${toolchains[@]}"; do - local toolchain_zip="${SRC}/cache/toolchain/${toolchain}" - local toolchain_dir="${toolchain_zip%.tar.*}" - if [[ ! -f "${toolchain_dir}/.download-complete" ]]; then - download_and_verify "toolchain" "${toolchain}" || - exit_with_error "Failed to download toolchain" "${toolchain}" - - display_alert "decompressing" - pv -p -b -r -c -N "[ .... ] ${toolchain}" "${toolchain_zip}" | - xz -dc | - tar xp --xattrs --no-same-owner --overwrite -C "${SRC}/cache/toolchain/" - if [[ $? -ne 0 ]]; then - rm -rf "${toolchain_dir}" - exit_with_error "Failed to decompress toolchain" "${toolchain}" - fi - - touch "${toolchain_dir}/.download-complete" - rm -rf "${toolchain_zip}"* # Also delete asc file - fi - done - USE_TORRENT=${USE_TORRENT_STATUS} - - local existing_dirs=($(ls -1 "${SRC}"/cache/toolchain)) - for dir in "${existing_dirs[@]}"; do - local found=no - for toolchain in "${toolchains[@]}"; do - # shellcheck disable=SC2053 # legacy code, won't fix - [[ $dir == ${toolchain%.tar.*} ]] && found=yes - done - if [[ $found == no ]]; then - display_alert "Removing obsolete toolchain" "$dir" - rm -rf "${SRC}/cache/toolchain/${dir}" - fi - done - else - display_alert "Ignoring toolchains" "SKIP_EXTERNAL_TOOLCHAINS: ${SKIP_EXTERNAL_TOOLCHAINS}" "info" - fi - fi -} diff --git a/lib/functions/host/prepare-host.sh b/lib/functions/host/prepare-host.sh index c785fdd3e8..865a7e7f4d 100644 --- a/lib/functions/host/prepare-host.sh +++ b/lib/functions/host/prepare-host.sh @@ -97,11 +97,6 @@ function prepare_host_noninteractive() { # @TODO: original: mkdir -p "${DEST}"/debs-beta/extra "${DEST}"/debs/extra "${DEST}"/{config,debug,patch} "${USERPATCHES_PATH}"/overlay "${SRC}"/cache/{sources,hash,hash-beta,toolchain,utility,rootfs} "${SRC}"/.tmp mkdir -p "${USERPATCHES_PATH}"/overlay "${SRC}"/cache/{sources,rootfs} "${SRC}"/.tmp - # If offline, do not try to download/install toolchains. - if ! $offline; then - download_external_toolchains # Mostly deprecated, since SKIP_EXTERNAL_TOOLCHAINS=yes is the default - fi - prepare_host_binfmt_qemu # in qemu-static.sh as most binfmt/qemu logic is there now # @TODO: rpardini: this does not belong here, instead with the other templates, pre-configuration.