diff --git a/scripts/build/arch.sh b/scripts/build/arch.sh new file mode 100644 index 00000000..48da2d6d --- /dev/null +++ b/scripts/build/arch.sh @@ -0,0 +1,24 @@ +# This file provides the default implementations of arch-specific functions. + +# Set up the target tuple +CT_DoArchTupleValues() { + :; +} + +# Multilib: change the target triplet according to CFLAGS +CT_DoArchMultilibTarget() { + local multi_flags="${1}" + local target="${2}" + + echo "${target}" +} + +# Multilib: Adjust target tuple for GLIBC +CT_DoArchGlibcAdjustTuple() { + local target="${1}" + + echo "${target}" +} + +# Override from the actual arch implementation as needed. +. "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh" diff --git a/scripts/build/arch/alpha.sh b/scripts/build/arch/alpha.sh index ffceae3d..cf6d40d9 100644 --- a/scripts/build/arch/alpha.sh +++ b/scripts/build/arch/alpha.sh @@ -4,14 +4,3 @@ CT_DoArchTupleValues () { # The architecture part of the tuple: CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX:-${CT_ARCH_ALPHA_VARIANT}}" } - -#------------------------------------------------------------------------------ -# Get multilib architecture-specific target -# Usage: CT_DoArchMultilibTarget "multilib flags" "target tuple" -CT_DoArchMultilibTarget () -{ - local target="${1}"; shift - local -a multi_flags=( "$@" ) - - echo "${target}" -} diff --git a/scripts/build/arch/arm.sh b/scripts/build/arch/arm.sh index 338392c3..5f6ce2fc 100644 --- a/scripts/build/arch/arm.sh +++ b/scripts/build/arch/arm.sh @@ -39,14 +39,3 @@ CT_DoArchTupleValues() { CT_TARGET_SYS="${CT_TARGET_SYS}hf" fi } - -#------------------------------------------------------------------------------ -# Get multilib architecture-specific target -# Usage: CT_DoArchMultilibTarget "multilib flags" "target tuple" -CT_DoArchMultilibTarget () -{ - local target="${1}"; shift - local -a multi_flags=( "$@" ) - - echo "${target}" -} diff --git a/scripts/build/arch/m68k.sh b/scripts/build/arch/m68k.sh index a6eb010e..052e4a7c 100644 --- a/scripts/build/arch/m68k.sh +++ b/scripts/build/arch/m68k.sh @@ -1,16 +1 @@ # Compute M68k-specific values - -CT_DoArchTupleValues() { - : -} - -#------------------------------------------------------------------------------ -# Get multilib architecture-specific target -# Usage: CT_DoArchMultilibTarget "multilib flags" "target tuple" -CT_DoArchMultilibTarget () -{ - local target="${1}"; shift - local -a multi_flags=( "$@" ) - - echo "${target}" -} diff --git a/scripts/build/arch/microblaze.sh b/scripts/build/arch/microblaze.sh index 93ecc9a2..456a6e3a 100644 --- a/scripts/build/arch/microblaze.sh +++ b/scripts/build/arch/microblaze.sh @@ -19,14 +19,3 @@ CT_DoArchTupleValues () { esac } - -#------------------------------------------------------------------------------ -# Get multilib architecture-specific target -# Usage: CT_DoArchMultilibTarget "multilib flags" "target tuple" -CT_DoArchMultilibTarget () -{ - local target="${1}"; shift - local -a multi_flags=( "$@" ) - - echo "${target}" -} diff --git a/scripts/build/arch/mips.sh b/scripts/build/arch/mips.sh index 68ad4faa..4d732be9 100644 --- a/scripts/build/arch/mips.sh +++ b/scripts/build/arch/mips.sh @@ -14,14 +14,3 @@ CT_DoArchTupleValues() { CT_ARCH_ABI_CFLAG="-mabi=${CT_ARCH_mips_ABI}" CT_ARCH_WITH_ABI="--with-abi=${CT_ARCH_mips_ABI}" } - -#------------------------------------------------------------------------------ -# Get multilib architecture-specific target -# Usage: CT_DoArchMultilibTarget "multilib flags" "target tuple" -CT_DoArchMultilibTarget () -{ - local target="${1}"; shift - local -a multi_flags=( "$@" ) - - echo "${target}" -} diff --git a/scripts/build/arch/nios2.sh b/scripts/build/arch/nios2.sh index 8c7d4451..24c556bf 100644 --- a/scripts/build/arch/nios2.sh +++ b/scripts/build/arch/nios2.sh @@ -9,5 +9,4 @@ CT_DoArchTupleValues() { CT_ARCH_WITH_FPU= CT_ARCH_WITH_FLOAT= CT_TARGET_SYS=elf - } diff --git a/scripts/build/arch/powerpc.sh b/scripts/build/arch/powerpc.sh index 77bbc8a2..964dd25e 100644 --- a/scripts/build/arch/powerpc.sh +++ b/scripts/build/arch/powerpc.sh @@ -26,6 +26,7 @@ CT_DoArchTupleValues () { CT_ARCH_CC_EXTRA_CONFIG="--enable-e500_double" fi } + #------------------------------------------------------------------------------ # Get multilib architecture-specific target # Usage: CT_DoArchMultilibTarget "multilib flags" "target tuple" diff --git a/scripts/build/arch/sh.sh b/scripts/build/arch/sh.sh index e7f4f1a4..7780e40f 100644 --- a/scripts/build/arch/sh.sh +++ b/scripts/build/arch/sh.sh @@ -35,14 +35,3 @@ CT_DoArchTupleValues () { esac CT_ARCH_FLOAT_CFLAG= } - -#------------------------------------------------------------------------------ -# Get multilib architecture-specific target -# Usage: CT_DoArchMultilibTarget "multilib flags" "target tuple" -CT_DoArchMultilibTarget () -{ - local target="${1}"; shift - local -a multi_flags=( "$@" ) - - echo "${target}" -} diff --git a/scripts/build/arch/sparc.sh b/scripts/build/arch/sparc.sh index 2d3baa35..189cebe2 100644 --- a/scripts/build/arch/sparc.sh +++ b/scripts/build/arch/sparc.sh @@ -25,5 +25,39 @@ CT_DoArchMultilibTarget () local target="${1}"; shift local -a multi_flags=( "$@" ) + local m32=false + local m64=false + + for m in "${multi_flags[@]}"; do + case "$m" in + -m32) m32=true ;; + -m64) m64=true ;; + esac + done + + # Fix up bitness + case "${target}" in + sparc-*) $m64 && target=${target/#sparc-/sparc64-} ;; + sparc64-*) $m32 && target=${target/#sparc64-/sparc-} ;; + esac + + echo "${target}" +} + +# Special tuple adjustment for glibc. +CT_DoArchGlibcAdjustTuple() { + local target="${1}" + + case "${target}" in + # SPARC quirk: glibc 2.23 and newer dropped support for SPARCv8 and + # earlier (corresponding pthread barrier code is missing). Until this + # support is reintroduced, configure as sparcv9. + sparc-*) + if [ "${CT_LIBC_GLIBC_2_23_or_later}" = y ]; then + target=${target/#sparc-/sparcv9-} + fi + ;; + esac + echo "${target}" } diff --git a/scripts/build/arch/x86.sh b/scripts/build/arch/x86.sh index ca0f08bf..0e41d67f 100644 --- a/scripts/build/arch/x86.sh +++ b/scripts/build/arch/x86.sh @@ -68,3 +68,27 @@ CT_DoArchMultilibTarget () echo "${target}" } + +# Adjust target tuple for GLIBC +CT_DoArchGlibcAdjustTuple() { + local target="${1}" + + case "${target}" in + # x86 quirk: architecture name is i386, but glibc expects i[4567]86 - to + # indicate the desired optimization. If it was a multilib variant of x86_64, + # then it targets at least NetBurst a.k.a. i786, but we'll follow the model + # above # and set the optimization to i686. Otherwise, replace with the most + # conservative choice, i486. + i386-*) + if [ "${CT_TARGET_ARCH}" = "x86_64" ]; then + target=${target/#i386-/i686-} + elif [ "${CT_TARGET_ARCH}" != "i386" ]; then + target=${target/#i386-/${CT_TARGET_ARCH}-} + else + target=${target/#i386-/i486-} + fi + ;; + esac + + echo "${target}" +} diff --git a/scripts/build/libc/avr-libc.sh b/scripts/build/libc/avr-libc.sh index b73f990b..3dc91a42 100644 --- a/scripts/build/libc/avr-libc.sh +++ b/scripts/build/libc/avr-libc.sh @@ -18,10 +18,6 @@ do_libc_extract() { CT_Patch "avr-libc" "${CT_LIBC_VERSION}" } -do_libc_check_config() { - : -} - do_libc_configure() { CT_DoLog EXTRA "Configuring C library" diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index dcd9e159..a08ed973 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -41,10 +41,6 @@ do_libc_extract() { CT_Popd } -do_libc_check_config() { - : -} - # Build and install headers and start files do_libc_start_files() { # Start files and Headers should be configured the same way as the @@ -123,30 +119,9 @@ do_libc_backend() { multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ${multi_flags} ) multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ${multi_flags} ) + # Adjust target tuple according to CFLAGS + any GLIBC quirks target=$( CT_DoMultilibTarget "${CT_TARGET}" ${extra_flags} ) - case "${target}" in - # SPARC quirk: glibc 2.23 and newer dropped support for SPARCv8 and - # earlier (corresponding pthread barrier code is missing). Until this - # support is reintroduced, configure as sparcv9. - sparc-*) - if [ "${CT_LIBC_GLIBC_2_23_or_later}" = y ]; then - target=${target/#sparc-/sparcv9-} - fi - ;; - # x86 quirk: architecture name is i386, but glibc expects i[4567]86 - to - # indicate the desired optimization. If it was a multilib variant of x86_64, - # then it targets at least NetBurst a.k.a. i786, but we'll follow arch/x86.sh - # and set the optimization to i686. Otherwise, replace with the most - # conservative choice, i486. - i386-*) - if [ "${CT_TARGET_ARCH}" = "x86_64" ]; then - target=${target/#i386-/i686-} - else - target=${target/#i386-/i486-} - fi - ;; - esac - + target=$( CT_DoArchGlibcAdjustTuple "${target}" ) CT_DoStep INFO "Building for multilib '${multi_flags}'" # Ensure sysroot (with suffix, if applicable) exists diff --git a/scripts/build/libc/mingw.sh b/scripts/build/libc/mingw.sh index 964a11d9..44ca008e 100644 --- a/scripts/build/libc/mingw.sh +++ b/scripts/build/libc/mingw.sh @@ -23,10 +23,6 @@ do_libc_extract() { CT_Popd } -do_libc_check_config() { - : -} - do_set_mingw_install_prefix(){ MINGW_INSTALL_PREFIX=/usr/${CT_TARGET} if [[ ${CT_WINAPI_VERSION} == 2* ]]; then diff --git a/scripts/build/libc/musl.sh b/scripts/build/libc/musl.sh index e0e9c63b..e31d1101 100644 --- a/scripts/build/libc/musl.sh +++ b/scripts/build/libc/musl.sh @@ -16,10 +16,6 @@ do_libc_extract() { CT_Patch "musl" "${CT_LIBC_VERSION}" } -do_libc_check_config() { - : -} - # Build and install headers and start files do_libc_start_files() { # Start files and Headers should be configured the same way as the diff --git a/scripts/build/libc/newlib.sh b/scripts/build/libc/newlib.sh index e70b6690..d9bda06f 100644 --- a/scripts/build/libc/newlib.sh +++ b/scripts/build/libc/newlib.sh @@ -38,10 +38,6 @@ do_libc_extract() { fi } -do_libc_check_config() { - : -} - do_libc_start_files() { CT_DoStep INFO "Installing C library headers & start files" CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib-${CT_LIBC_VERSION}/newlib/libc/include/." \ diff --git a/scripts/build/libc/none.sh b/scripts/build/libc/none.sh index d4bf7dcb..8537a8ea 100644 --- a/scripts/build/libc/none.sh +++ b/scripts/build/libc/none.sh @@ -10,10 +10,6 @@ do_libc_extract() { : } -do_libc_check_config() { - : -} - do_libc_start_files() { : } diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh index edd82f6a..c59d5fa2 100644 --- a/scripts/build/libc/uClibc.sh +++ b/scripts/build/libc/uClibc.sh @@ -51,26 +51,6 @@ do_libc_extract() { return 0 } -# Check that uClibc has been previously configured -do_libc_check_config() { - CT_DoStep INFO "Checking C library configuration" - - # Use the default config if the user did not provide one. - if [ -z "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then - CT_LIBC_UCLIBC_CONFIG_FILE="${CT_LIB_DIR}/contrib/uClibc-defconfigs/${uclibc_name}.config" - fi - - if ${grep} -E '^KERNEL_SOURCE=' "${CT_LIBC_UCLIBC_CONFIG_FILE}" >/dev/null 2>&1; then - CT_DoLog WARN "Your uClibc version refers to the kernel _sources_, which is bad." - CT_DoLog WARN "I can't guarantee that our little hack will work. Please try to upgrade." - fi - - CT_DoLog EXTRA "Manage uClibc configuration" - manage_uClibc_config "${CT_LIBC_UCLIBC_CONFIG_FILE}" "${CT_CONFIG_DIR}/uClibc.config" - - CT_EndStep -} - # Build and install headers and start files do_libc_start_files() { # Start files and Headers should be configured the same way as the @@ -131,12 +111,17 @@ do_libc_backend() { ${CT_LIBC_UCLIBC_VERBOSITY} \ ) - # Retrieve the config file - CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/uClibc.config" .config - # Force the date of the pregen locale data, as the # newer ones that are referenced are not available CT_DoLog EXTRA "Applying configuration" + + # Use the default config if the user did not provide one. + if [ -z "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then + CT_LIBC_UCLIBC_CONFIG_FILE="${CT_LIB_DIR}/contrib/uClibc-defconfigs/${uclibc_name}.config" + fi + + manage_uClibc_config "${CT_LIBC_UCLIBC_CONFIG_FILE}" .config + CT_DoYes | CT_DoExecLog ALL ${make} "${make_args[@]}" oldconfig if [ "${libc_mode}" = "startfiles" ]; then @@ -347,7 +332,6 @@ manage_uClibc_config() { # which is the correct value of ${PREFIX}/${TARGET}. CT_KconfigSetOption "DEVEL_PREFIX" "\"/usr/\"" "${dst}" CT_KconfigSetOption "RUNTIME_PREFIX" "\"/\"" "${dst}" - CT_KconfigSetOption "SHARED_LIB_LOADER_PREFIX" "\"/lib/\"" "${dst}" CT_KconfigSetOption "KERNEL_HEADERS" "\"${CT_HEADERS_DIR}\"" "${dst}" # Locales support diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in index b49c68e5..01fe07cf 100644 --- a/scripts/crosstool-NG.sh.in +++ b/scripts/crosstool-NG.sh.in @@ -141,7 +141,7 @@ CT_DoLog INFO "Building environment variables" # Include sub-scripts instead of calling them: that way, we do not have to # export any variable, nor re-parse the configuration and functions files. . "${CT_LIB_DIR}/scripts/build/internals.sh" -. "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh" +. "${CT_LIB_DIR}/scripts/build/arch.sh" . "${CT_LIB_DIR}/scripts/build/companion_tools.sh" . "${CT_LIB_DIR}/scripts/build/kernel/${CT_KERNEL}.sh" . "${CT_LIB_DIR}/scripts/build/companion_libs.sh" @@ -181,7 +181,6 @@ CT_SRC_DIR="${CT_WORK_DIR}/src" CT_BUILD_DIR="${CT_WORK_DIR}/${CT_TARGET}/build" CT_BUILDTOOLS_PREFIX_DIR="${CT_WORK_DIR}/${CT_TARGET}/buildtools" CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state" -CT_CONFIG_DIR="${CT_BUILD_DIR}/configs" # Note about HOST_COMPLIBS_DIR: it's always gonna be in the buildtools dir, or a # sub-dir. So we won't have to save/restore it, not even create it. # In case of cross or native, host-complibs are used for build-complibs; @@ -266,7 +265,6 @@ CT_DoExecLog ALL mkdir -p "${CT_TARBALLS_DIR}" CT_DoExecLog ALL mkdir -p "${CT_SRC_DIR}" CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}" CT_DoExecLog ALL mkdir -p "${CT_BUILDTOOLS_PREFIX_DIR}/bin" -CT_DoExecLog ALL mkdir -p "${CT_CONFIG_DIR}" CT_DoExecLog ALL mkdir -p "${CT_INSTALL_DIR}" CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}" CT_DoExecLog ALL mkdir -p "${CT_HOST_COMPLIBS_DIR}" diff --git a/scripts/functions b/scripts/functions index 2331557b..49b06869 100644 --- a/scripts/functions +++ b/scripts/functions @@ -1474,7 +1474,6 @@ CT_DoSaveState() { /^(FUNCNAME|GROUPS|PPID|SHELLOPTS)=/d;' >"${state_dir}/env.sh" CT_DoTarballIfExists "${CT_BUILDTOOLS_PREFIX_DIR}" "${state_dir}/buildtools_dir" - CT_DoTarballIfExists "${CT_CONFIG_DIR}" "${state_dir}/config_dir" CT_DoTarballIfExists "${CT_PREFIX_DIR}" "${state_dir}/prefix_dir" --exclude '*.log' CT_DoLog STATE " Saving log file" @@ -1504,7 +1503,6 @@ CT_DoLoadState(){ CT_DoLog INFO "Restoring state at step '${state_name}', as requested." CT_DoExtractTarballIfExists "${state_dir}/prefix_dir" "${CT_PREFIX_DIR}" - CT_DoExtractTarballIfExists "${state_dir}/config_dir" "${CT_CONFIG_DIR}" CT_DoExtractTarballIfExists "${state_dir}/buildtools_dir" "${CT_BUILDTOOLS_PREFIX_DIR}" # Restore the environment, discarding any error message diff --git a/steps.mk b/steps.mk index b7e3b02e..15b9a01b 100644 --- a/steps.mk +++ b/steps.mk @@ -16,9 +16,9 @@ help-env:: # The _for_build steps are noop for native and cross, # but are actual steps for canadian and cross-native. -# Please keep the last line with a '\' and keep the following empy line: +# Please keep the last line with a '\' and keep the following empty line: # it helps when diffing and merging. -CT_STEPS := libc_check_config \ +CT_STEPS := \ companion_libs_for_build \ binutils_for_build \ companion_libs_for_host \