From 3ebc5d0c1e72e95f05a02818a3e2c642663d4b74 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 2 Apr 2016 00:12:41 -0700 Subject: libc/*.sh: Deprecate libc_check_config step. This step was only used in uClibc. However, with upcoming multilib, the config management will have to be done for each variant differently, anyway. uClibc was the only user of libc_check_config step, as well as CT_CONFIG_DIR directory. Retire these. Two other clean-ups in uClibc.sh: - KERNEL_HEADERS check seems to be bogus, this config option is not present even in 0.9.30 - which is not supported already. - SHARED_LIB_LOADER_PREFIX was renamed to MULTILIB_DIR in 0.9.31, according to ChangeLog - and MULTILIB_DIR is passed from command line instead. Signed-off-by: Alexey Neyman --- scripts/build/arch/alpha.sh | 11 ----------- scripts/build/arch/arm.sh | 11 ----------- scripts/build/arch/m68k.sh | 15 --------------- scripts/build/arch/microblaze.sh | 11 ----------- scripts/build/arch/mips.sh | 11 ----------- scripts/build/arch/nios2.sh | 1 - scripts/build/arch/powerpc.sh | 1 + scripts/build/arch/sh.sh | 11 ----------- scripts/build/arch/sparc.sh | 34 ++++++++++++++++++++++++++++++++++ scripts/build/arch/x86.sh | 24 ++++++++++++++++++++++++ 10 files changed, 59 insertions(+), 71 deletions(-) (limited to 'scripts/build/arch') 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}" +} -- cgit v1.2.3 From 0fdc1887a7426bf7974f0ca6bb24815dff4a2997 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sun, 3 Apr 2016 10:26:24 -0700 Subject: Change multilib functions to set the variable. Rather than echo-ing the new value, set the value into the variable with the name passed as an argument (similar to CT_SanitizeVarDir). This allows to use CT_DoLog in these functions. Signed-off-by: Alexey Neyman --- scripts/build/arch.sh | 11 ++++------- scripts/build/arch/powerpc.sh | 31 +++++++++++++++++-------------- scripts/build/arch/s390.sh | 16 ++++++++++------ scripts/build/arch/sparc.sh | 29 +++++++++++++++++++---------- scripts/build/arch/x86.sh | 38 +++++++++++++++++++++++--------------- scripts/build/libc/glibc.sh | 5 +++-- scripts/functions | 6 +++--- 7 files changed, 79 insertions(+), 57 deletions(-) (limited to 'scripts/build/arch') diff --git a/scripts/build/arch.sh b/scripts/build/arch.sh index 48da2d6d..2199a17f 100644 --- a/scripts/build/arch.sh +++ b/scripts/build/arch.sh @@ -6,18 +6,15 @@ CT_DoArchTupleValues() { } # Multilib: change the target triplet according to CFLAGS +# Usage: CT_DoArchGlibcAdjustTuple CT_DoArchMultilibTarget() { - local multi_flags="${1}" - local target="${2}" - - echo "${target}" + :; } # Multilib: Adjust target tuple for GLIBC +# Usage: CT_DoArchGlibcAdjustTuple CT_DoArchGlibcAdjustTuple() { - local target="${1}" - - echo "${target}" + :; } # Override from the actual arch implementation as needed. diff --git a/scripts/build/arch/powerpc.sh b/scripts/build/arch/powerpc.sh index 964dd25e..80157241 100644 --- a/scripts/build/arch/powerpc.sh +++ b/scripts/build/arch/powerpc.sh @@ -29,11 +29,12 @@ CT_DoArchTupleValues () { #------------------------------------------------------------------------------ # Get multilib architecture-specific target -# Usage: CT_DoArchMultilibTarget "multilib flags" "target tuple" +# Usage: CT_DoArchMultilibTarget "target variable" "multilib flags" CT_DoArchMultilibTarget () { - local target="${1}"; shift + local target_var="${1}"; shift local -a multi_flags=( "$@" ) + local target_ local m32=false local m64=false @@ -49,22 +50,24 @@ CT_DoArchMultilibTarget () esac done + eval target_=\"\${${target_var}}\" + # Fix up bitness - case "${target}" in - powerpc-*) $m64 && target=${target/#powerpc-/powerpc64-} ;; - powerpcle-*) $m64 && target=${target/#powerpcle-/powerpc64le-} ;; - powerpc64-*) $m32 && target=${target/#powerpc64-/powerpc-} ;; - powerpc64le-*) $m32 && target=${target/#powerpc64le-/powerpcle-} ;; + case "${target_}" in + powerpc-*) $m64 && target_=${target_/#powerpc-/powerpc64-} ;; + powerpcle-*) $m64 && target_=${target_/#powerpcle-/powerpc64le-} ;; + powerpc64-*) $m32 && target_=${target_/#powerpc64-/powerpc-} ;; + powerpc64le-*) $m32 && target_=${target_/#powerpc64le-/powerpcle-} ;; esac # Fix up endianness - case "${target}" in - powerpc-*) $mlittle && target=${target/#powerpc-/powerpcle-} ;; - powerpcle-*) $mbig && target=${target/#powerpcle-/powerpc-} ;; - powerpc64-*) $mlittle && target=${target/#powerpc64-/powerpc64le-} ;; - powerpc64le-*) $mbig && target=${target/#powerpc64le-/powerpc64-} ;; + case "${target_}" in + powerpc-*) $mlittle && target_=${target_/#powerpc-/powerpcle-} ;; + powerpcle-*) $mbig && target_=${target_/#powerpcle-/powerpc-} ;; + powerpc64-*) $mlittle && target_=${target_/#powerpc64-/powerpc64le-} ;; + powerpc64le-*) $mbig && target_=${target_/#powerpc64le-/powerpc64-} ;; esac - # return the target - echo "${target}" + # Set the target variable + eval ${target_var}=\"${target_}\" } diff --git a/scripts/build/arch/s390.sh b/scripts/build/arch/s390.sh index e303420a..dff86a0c 100644 --- a/scripts/build/arch/s390.sh +++ b/scripts/build/arch/s390.sh @@ -9,11 +9,12 @@ CT_DoArchTupleValues() { #------------------------------------------------------------------------------ # Get multilib architecture-specific target -# Usage: CT_DoArchMultilibTarget "multilib flags" "target tuple" +# Usage: CT_DoArchMultilibTarget "target variable" "multilib flags" CT_DoArchMultilibTarget () { - local target="${1}"; shift + local target_var="${1}"; shift local -a multi_flags=( "$@" ) + local target_ local m31=false local m64=false @@ -25,11 +26,14 @@ CT_DoArchMultilibTarget () esac done + eval target_=\"\${${target_var}}\" + # Fix bitness - case "${target}" in - s390-*) $m64 && target=${target/#s390-/s390x-} ;; - s390x-*) $m31 && target=${target/#s390x-/s390-} ;; + case "${target_}" in + s390-*) $m64 && target_=${target_/#s390-/s390x-} ;; + s390x-*) $m31 && target_=${target_/#s390x-/s390-} ;; esac - echo "${target}" + # Set the target variable + eval ${target_var}=\"${target_}\" } diff --git a/scripts/build/arch/sparc.sh b/scripts/build/arch/sparc.sh index 189cebe2..15213a6a 100644 --- a/scripts/build/arch/sparc.sh +++ b/scripts/build/arch/sparc.sh @@ -19,11 +19,12 @@ CT_DoArchTupleValues() { #------------------------------------------------------------------------------ # Get multilib architecture-specific target -# Usage: CT_DoArchMultilibTarget "multilib flags" "target tuple" +# Usage: CT_DoArchMultilibTarget "target variable" "multilib flags" CT_DoArchMultilibTarget () { - local target="${1}"; shift + local target_var="${1}"; shift local -a multi_flags=( "$@" ) + local target_ local m32=false local m64=false @@ -35,29 +36,37 @@ CT_DoArchMultilibTarget () esac done + eval target_=\"\${${target_var}}\" + # Fix up bitness - case "${target}" in - sparc-*) $m64 && target=${target/#sparc-/sparc64-} ;; - sparc64-*) $m32 && target=${target/#sparc64-/sparc-} ;; + case "${target_}" in + sparc-*) $m64 && target_=${target_/#sparc-/sparc64-} ;; + sparc64-*) $m32 && target_=${target_/#sparc64-/sparc-} ;; esac - echo "${target}" + # Set the target variable + eval ${target_var}=\"${target_}\" } # Special tuple adjustment for glibc. CT_DoArchGlibcAdjustTuple() { - local target="${1}" + local target_var="${1}" + local target_ + + eval target_=\"\${${target_var}}\" - case "${target}" in + 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-} + CT_DoLog WARN "GLIBC 2.23 only supports SPARCv9" + target_=${target_/#sparc-/sparcv9-} fi ;; esac - echo "${target}" + # Set the target variable + eval ${target_var}=\"${target_}\" } diff --git a/scripts/build/arch/x86.sh b/scripts/build/arch/x86.sh index 0e41d67f..51476786 100644 --- a/scripts/build/arch/x86.sh +++ b/scripts/build/arch/x86.sh @@ -35,11 +35,12 @@ CT_DoArchTupleValues() { #------------------------------------------------------------------------------ # Get multilib architecture-specific target -# Usage: CT_DoArchMultilibTarget "multilib flags" "target tuple" +# Usage: CT_DoArchMultilibTarget "target variable" "multilib flags" CT_DoArchMultilibTarget () { - local target="${1}"; shift + local target_var="${1}"; shift local -a multi_flags=( "$@" ) + local target_ local bit32=false local bit64=false @@ -54,26 +55,32 @@ CT_DoArchMultilibTarget () esac done + eval target_=\"\${${target_var}}\" + # Fix up architecture. - case "${target}" in - x86_64-*) $bit32 && target=${target/#x86_64-/i386-} ;; - i[34567]86-*) $bit64 && target=${target/#i[34567]86-/x86_64-} ;; + case "${target_}" in + x86_64-*) $bit32 && target_=${target_/#x86_64-/i386-} ;; + i[34567]86-*) $bit64 && target_=${target_/#i[34567]86-/x86_64-} ;; esac # Fix up the ABI part. - case "${target}" in - *x32) $abi_dflt && target=${target/%x32} ;; - *) $abi_x32 && target=${target}x32 ;; + case "${target_}" in + *x32) $abi_dflt && target_=${target_/%x32} ;; + *) $abi_x32 && target_=${target_}x32 ;; esac - echo "${target}" + # Set the target variable + eval ${target_var}=\"${target_}\" } # Adjust target tuple for GLIBC CT_DoArchGlibcAdjustTuple() { - local target="${1}" + local target_var="${1}" + local target_ + + eval target_=\"\${${target_var}}\" - case "${target}" in + 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 @@ -81,14 +88,15 @@ CT_DoArchGlibcAdjustTuple() { # conservative choice, i486. i386-*) if [ "${CT_TARGET_ARCH}" = "x86_64" ]; then - target=${target/#i386-/i686-} + target_=${target_/#i386-/i686-} elif [ "${CT_TARGET_ARCH}" != "i386" ]; then - target=${target/#i386-/${CT_TARGET_ARCH}-} + target_=${target_/#i386-/${CT_TARGET_ARCH}-} else - target=${target/#i386-/i486-} + target_=${target_/#i386-/i486-} fi ;; esac - echo "${target}" + # Set the target variable + eval ${target_var}=\"${target_}\" } diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index a08ed973..dc9443c0 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -120,8 +120,9 @@ do_libc_backend() { 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} ) - target=$( CT_DoArchGlibcAdjustTuple "${target}" ) + target="${CT_TARGET}" + CT_DoMultilibTarget target ${extra_flags} + CT_DoArchGlibcAdjustTuple target CT_DoStep INFO "Building for multilib '${multi_flags}'" # Ensure sysroot (with suffix, if applicable) exists diff --git a/scripts/functions b/scripts/functions index 49b06869..ef75e09e 100644 --- a/scripts/functions +++ b/scripts/functions @@ -1371,18 +1371,18 @@ CT_DoBuildTargetTuple() { # GCC prints nothing and exits with status 0), falling back to calling # the architecture-specific functions. CT_DoMultilibTarget() { - local target="$1"; shift + local target_var="$1"; shift local -a multi_flags=( "$@" ) local gcc_multiarch gcc_multiarch=$( "${CT_TARGET}-gcc" -print-multiarch "${multi_flags[@]}" ) if [ -n "${gcc_multiarch}" ]; then - echo "${gcc_multiarch}" + eval "${target_var}=${gcc_multiarch}" return fi # Fall back to arch-specific guesswork - CT_DoArchMultilibTarget "${target}" "${multi_flags[@]}" + CT_DoArchMultilibTarget "${target_var}" "${multi_flags[@]}" } # This function does pause the build until the user strikes "Return" -- cgit v1.2.3 From bf3eceb5d9b27fc65c819abe0b7f3cec704917e7 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Mon, 4 Apr 2016 08:25:07 -0700 Subject: uClibc: Split configuration tweaker into per-arch functions. Signed-off-by: Alexey Neyman --- scripts/build/arch.sh | 18 ++++++ scripts/build/arch/arm.sh | 19 ++++++ scripts/build/arch/m68k.sh | 6 ++ scripts/build/arch/microblaze.sh | 6 ++ scripts/build/arch/mips.sh | 33 ++++++++++ scripts/build/arch/powerpc.sh | 17 +++++ scripts/build/arch/sh.sh | 15 +++++ scripts/build/arch/sparc.sh | 7 +++ scripts/build/arch/x86.sh | 30 +++++++++ scripts/build/arch/xtensa.sh | 6 ++ scripts/build/libc/uClibc.sh | 130 +++++---------------------------------- 11 files changed, 174 insertions(+), 113 deletions(-) (limited to 'scripts/build/arch') diff --git a/scripts/build/arch.sh b/scripts/build/arch.sh index 2199a17f..6414b54a 100644 --- a/scripts/build/arch.sh +++ b/scripts/build/arch.sh @@ -17,5 +17,23 @@ CT_DoArchGlibcAdjustTuple() { :; } +# Helper for uClibc configurators: select the architecture +# Usage: CT_DoArchUClibcSelectArch +CT_DoArchUClibcSelectArch() { + local cfg="${1}" + local arch="${2}" + + ${sed} -i -r -e '/^TARGET_.*/d' "${cfg}" + CT_KconfigEnableOption "TARGET_${arch}" "${cfg}" + CT_KconfigSetOption "TARGET_ARCH" "${arch}" "${cfg}" +} + +# uClibc: Adjust configuration file according to the CT-NG configuration +# Usage CT_DoArchUClibcConfig +CT_DoArchUClibcConfig() { + CT_DoLog WARN "Support for '${CT_ARCH}' is not implemented in uClibc config tweaker." + CT_DoLog WARN "Exact configuration file must be provided." +} + # Override from the actual arch implementation as needed. . "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh" diff --git a/scripts/build/arch/arm.sh b/scripts/build/arch/arm.sh index 5f6ce2fc..8af00722 100644 --- a/scripts/build/arch/arm.sh +++ b/scripts/build/arch/arm.sh @@ -39,3 +39,22 @@ CT_DoArchTupleValues() { CT_TARGET_SYS="${CT_TARGET_SYS}hf" fi } + +CT_DoArchUClibcConfig() { + local cfg="${1}" + + CT_DoArchUClibcSelectArch "${cfg}" "arm" + + # FIXME: CONFIG_ARM_OABI does not exist in neither uClibc/uClibc-ng + # FIXME: CONFIG_ARM_EABI does not seem to affect anything in either of them, too + # (both check the compiler's built-in define, __ARM_EABI__ instead) except for + # a check for match between toolchain configuration and uClibc-ng in + # uClibc_arch_features.h + if [ "${CT_ARCH_ARM_EABI}" = "y" ]; then + CT_KconfigDisableOption "CONFIG_ARM_OABI" "${cfg}" + CT_KconfigEnableOption "CONFIG_ARM_EABI" "${cfg}" + else + CT_KconfigDisableOption "CONFIG_ARM_EABI" "${cfg}" + CT_KconfigEnableOption "CONFIG_ARM_OABI" "${cfg}" + fi +} diff --git a/scripts/build/arch/m68k.sh b/scripts/build/arch/m68k.sh index 052e4a7c..3cba76c6 100644 --- a/scripts/build/arch/m68k.sh +++ b/scripts/build/arch/m68k.sh @@ -1 +1,7 @@ # Compute M68k-specific values + +CT_DoArchUClibcConfig() { + local cfg="${1}" + + CT_DoArchUClibcSelectArch "${cfg}" "m68k" +} diff --git a/scripts/build/arch/microblaze.sh b/scripts/build/arch/microblaze.sh index 456a6e3a..e9d98114 100644 --- a/scripts/build/arch/microblaze.sh +++ b/scripts/build/arch/microblaze.sh @@ -19,3 +19,9 @@ CT_DoArchTupleValues () { esac } + +CT_DoArchUClibcConfig() { + local cfg="${1}" + + CT_DoArchUClibcSelectArch "${cfg}" "microblaze" +} diff --git a/scripts/build/arch/mips.sh b/scripts/build/arch/mips.sh index 4d732be9..030e77b6 100644 --- a/scripts/build/arch/mips.sh +++ b/scripts/build/arch/mips.sh @@ -14,3 +14,36 @@ CT_DoArchTupleValues() { CT_ARCH_ABI_CFLAG="-mabi=${CT_ARCH_mips_ABI}" CT_ARCH_WITH_ABI="--with-abi=${CT_ARCH_mips_ABI}" } + +CT_DoArchUClibcConfig() { + local cfg="${1}" + + CT_DoArchUClibcSelectArch "${cfg}" "${CT_ARCH}" + + CT_KconfigDisableOption "CONFIG_MIPS_O32_ABI" "${cfg}" + CT_KconfigDisableOption "CONFIG_MIPS_N32_ABI" "${cfg}" + CT_KconfigDisableOption "CONFIG_MIPS_N64_ABI" "${cfg}" + case "${CT_ARCH_mips_ABI}" in + 32) + CT_KconfigEnableOption "CONFIG_MIPS_O32_ABI" "${cfg}" + ;; + n32) + CT_KconfigEnableOption "CONFIG_MIPS_N32_ABI" "${cfg}" + ;; + 64) + CT_KconfigEnableOption "CONFIG_MIPS_N64_ABI" "${cfg}" + ;; + esac + + # FIXME: uClibc (!ng) allows to select ISA in the config; should + # match from the selected ARCH_ARCH level... For now, delete and + # fall back to default. + CT_KconfigDeleteOption "CONFIG_MIPS_ISA_1" "${cfg}" + CT_KconfigDeleteOption "CONFIG_MIPS_ISA_2" "${cfg}" + CT_KconfigDeleteOption "CONFIG_MIPS_ISA_3" "${cfg}" + CT_KconfigDeleteOption "CONFIG_MIPS_ISA_4" "${cfg}" + CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS32" "${cfg}" + CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS32R2" "${cfg}" + CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64" "${cfg}" + CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64R2" "${cfg}" +} diff --git a/scripts/build/arch/powerpc.sh b/scripts/build/arch/powerpc.sh index 80157241..52f3f8bb 100644 --- a/scripts/build/arch/powerpc.sh +++ b/scripts/build/arch/powerpc.sh @@ -71,3 +71,20 @@ CT_DoArchMultilibTarget () # Set the target variable eval ${target_var}=\"${target_}\" } + +CT_DoArchUClibcConfig() { + local cfg="${1}" + + CT_DoArchUClibcSelectArch "${cfg}" "powerpc" + + CT_KconfigDisableOption "CONFIG_E500" "${cfg}" + CT_KconfigDisableOption "CONFIG_CLASSIC" "${cfg}" + CT_KconfigDeleteOption "TARGET_SUBARCH" "${cfg}" + if [ "${CT_ARCH_powerpc_ABI}" = "spe" ]; then + CT_KconfigEnableOption "CONFIG_E500" "${cfg}" + CT_KconfigSetOption "TARGET_SUBARCH" "e500" "${cfg}" + else + CT_KconfigEnableOption "CONFIG_CLASSIC" "${cfg}" + CT_KconfigSetOption "TARGET_SUBARCH" "classic" "${cfg}" + fi +} diff --git a/scripts/build/arch/sh.sh b/scripts/build/arch/sh.sh index 7780e40f..101e4ce8 100644 --- a/scripts/build/arch/sh.sh +++ b/scripts/build/arch/sh.sh @@ -35,3 +35,18 @@ CT_DoArchTupleValues () { esac CT_ARCH_FLOAT_CFLAG= } + +CT_DoArchUClibcConfig() { + local cfg="${1}" + + # FIXME: uclibc (!ng) seems to support sh64 (sh5), too + CT_DoArchUClibcSelectArch "${cfg}" "sh" + CT_KconfigDisableOption "CONFIG_SH3" "${cfg}" + CT_KconfigDisableOption "CONFIG_SH4" "${cfg}" + CT_KconfigDisableOption "CONFIG_SH4A" "${cfg}" + case "${CT_ARCH_SH_VARIAN}" in + sh3) CT_KconfigEnableOption "CONFIG_SH3" "${cfg}";; + sh4) CT_KconfigEnableOption "CONFIG_SH4" "${cfg}";; + sh4a) CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}";; + esac +} diff --git a/scripts/build/arch/sparc.sh b/scripts/build/arch/sparc.sh index 15213a6a..74f6f785 100644 --- a/scripts/build/arch/sparc.sh +++ b/scripts/build/arch/sparc.sh @@ -70,3 +70,10 @@ CT_DoArchGlibcAdjustTuple() { # Set the target variable eval ${target_var}=\"${target_}\" } + +CT_DoArchUClibcConfig() { + local cfg="${1}" + + CT_DoArchUClibcSelectArch "${cfg}" "${CT_ARCH}" + # FIXME: select CONFIG_SPARC_V7/V8/V9/V9B according to the CPU selector +} diff --git a/scripts/build/arch/x86.sh b/scripts/build/arch/x86.sh index 51476786..41932782 100644 --- a/scripts/build/arch/x86.sh +++ b/scripts/build/arch/x86.sh @@ -100,3 +100,33 @@ CT_DoArchGlibcAdjustTuple() { # Set the target variable eval ${target_var}=\"${target_}\" } + +CT_DoArchUClibcConfig() { + local cfg="${1}" + + if [ "${CT_ARCH_BITNESS}" = 64 ]; then + CT_DoArchUClibcSelectArch "${cfg}" "x86_64" + else + CT_DoArchUClibcSelectArch "${cfg}" "i386" + fi + + # FIXME This doesn't cover all cases of x86_32 on uClibc (!ng) + CT_KconfigDisableOption "CONFIG_386" "${cfg}" + CT_KconfigDisableOption "CONFIG_486" "${cfg}" + CT_KconfigDisableOption "CONFIG_586" "${cfg}" + CT_KconfigDisableOption "CONFIG_686" "${cfg}" + case ${CT_TARGET_ARCH} in + i386) + CT_KconfigEnableOption "CONFIG_386" "${cfg}" + ;; + i486) + CT_KconfigEnableOption "CONFIG_486" "${cfg}" + ;; + i586) + CT_KconfigEnableOption "CONFIG_586" "${cfg}" + ;; + i686) + CT_KconfigEnableOption "CONFIG_686" "${cfg}" + ;; + esac +} diff --git a/scripts/build/arch/xtensa.sh b/scripts/build/arch/xtensa.sh index c7bd4320..a3010c69 100644 --- a/scripts/build/arch/xtensa.sh +++ b/scripts/build/arch/xtensa.sh @@ -70,3 +70,9 @@ CT_ConfigureXtensa() { CT_Popd } + +CT_DoArchUClibcConfig() { + local cfg="${1}" + + CT_DoArchUClibcSelectArch "${cfg}" "xtensa" +} diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh index c59d5fa2..1e2a2908 100644 --- a/scripts/build/libc/uClibc.sh +++ b/scripts/build/libc/uClibc.sh @@ -193,96 +193,8 @@ manage_uClibc_config() { dst="$2" # Start with fresh files - CT_DoExecLog ALL rm -f "${dst}" - CT_DoExecLog ALL mkdir -p "$(dirname ${dst})" CT_DoExecLog ALL cp "${src}" "${dst}" - # Hack our target in the config file. - case "${CT_ARCH}:${CT_ARCH_BITNESS}" in - x86:32) arch=i386;; - x86:64) arch=x86_64;; - sh:32) arch="sh";; - *) arch="${CT_ARCH}";; - esac - # Also remove stripping: its the responsibility of the - # firmware builder to strip or not. - ${sed} -i -r -e '/^TARGET_.*/d' "${dst}" - CT_KconfigEnableOption "TARGET_${arch}" "${dst}" - CT_KconfigSetOption "TARGET_ARCH" "${arch}" "${dst}" - CT_KconfigDisableOption "DOSTRIP" "${dst}" - - # Ah. We may one day need architecture-specific handler here... - case "${arch}" in - arm*) - if [ "${CT_ARCH_ARM_EABI}" = "y" ]; then - CT_KconfigDisableOption "CONFIG_ARM_OABI" "${dst}" - CT_KconfigEnableOption "CONFIG_ARM_EABI" "${dst}" - else - CT_KconfigDisableOption "CONFIG_ARM_EABI" "${dst}" - CT_KconfigEnableOption "CONFIG_ARM_OABI" "${dst}" - fi - ;; - i386) - # FIXME This doesn't cover all cases of x86_32... - case ${CT_TARGET_ARCH} in - i386) - CT_KconfigEnableOption "CONFIG_386" "${dst}" - ;; - i486) - CT_KconfigEnableOption "CONFIG_486" "${dst}" - ;; - i586) - CT_KconfigEnableOption "CONFIG_586" "${dst}" - ;; - i686) - CT_KconfigEnableOption "CONFIG_686" "${dst}" - ;; - esac - ;; - mips*) - CT_KconfigDisableOption "CONFIG_MIPS_O32_ABI" "${dst}" - CT_KconfigDisableOption "CONFIG_MIPS_N32_ABI" "${dst}" - CT_KconfigDisableOption "CONFIG_MIPS_N64_ABI" "${dst}" - CT_KconfigDeleteOption "CONFIG_MIPS_ISA_1" "${dst}" - CT_KconfigDeleteOption "CONFIG_MIPS_ISA_2" "${dst}" - CT_KconfigDeleteOption "CONFIG_MIPS_ISA_3" "${dst}" - CT_KconfigDeleteOption "CONFIG_MIPS_ISA_4" "${dst}" - CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS32" "${dst}" - CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS32R2" "${dst}" - CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64" "${dst}" - CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64R2" "${dst}" - case "${CT_ARCH_mips_ABI}" in - 32) - CT_KconfigEnableOption "CONFIG_MIPS_O32_ABI" "${dst}" - ;; - n32) - CT_KconfigEnableOption "CONFIG_MIPS_N32_ABI" "${dst}" - ;; - 64) - CT_KconfigEnableOption "CONFIG_MIPS_N64_ABI" "${dst}" - ;; - esac - ;; - powerpc*) - CT_KconfigDisableOption "CONFIG_E500" "${dst}" - CT_KconfigDisableOption "CONFIG_CLASSIC" "${dst}" - CT_KconfigDeleteOption "TARGET_SUBARCH" "${dst}" - if [ "${CT_ARCH_powerpc_ABI}" = "spe" ]; then - CT_KconfigEnableOption "CONFIG_E500" "${dst}" - CT_KconfigSetOption "TARGET_SUBARCH" "e500" "${dst}" - else - CT_KconfigEnableOption "CONFIG_CLASSIC" "${dst}" - CT_KconfigSetOption "TARGET_SUBARCH" "classic" "${dst}" - fi - ;; - sh) - # all we really support right now is sh4:32 - CT_KconfigEnableOption "CONFIG_SH4" "${dst}" - ;; - esac - - # Accomodate for old and new uClibc versions, where the - # way to select between big/little endian has changed case "${CT_ARCH_ENDIAN}" in big) CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${dst}" @@ -298,8 +210,6 @@ manage_uClibc_config() { ;; esac - # Accomodate for old and new uClibc versions, where the - # MMU settings has different config knobs if [ "${CT_ARCH_USE_MMU}" = "y" ]; then CT_KconfigEnableOption "ARCH_USE_MMU" "${dst}" else @@ -392,29 +302,23 @@ manage_uClibc_config() { fi # Push the threading model + CT_KconfigDisableOption "UCLIBC_HAS_THREADS" "${dst}" + CT_KconfigDisableOption "LINUXTHREADS_OLD" "${dst}" + CT_KconfigDisableOption "LINUXTHREADS_NEW" "${dst}" + CT_KconfigDisableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}" case "${CT_THREADS}:${CT_LIBC_UCLIBC_LNXTHRD}" in none:) - CT_KconfigDisableOption "UCLIBC_HAS_THREADS" "${dst}" - CT_KconfigDisableOption "LINUXTHREADS_OLD" "${dst}" - CT_KconfigDisableOption "LINUXTHREADS_NEW" "${dst}" - CT_KconfigDisableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}" ;; linuxthreads:old) CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" CT_KconfigEnableOption "LINUXTHREADS_OLD" "${dst}" - CT_KconfigDisableOption "LINUXTHREADS_NEW" "${dst}" - CT_KconfigDisableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}" ;; linuxthreads:new) CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" - CT_KconfigDisableOption "LINUXTHREADS_OLD" "${dst}" CT_KconfigEnableOption "LINUXTHREADS_NEW" "${dst}" - CT_KconfigDisableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}" ;; nptl:) CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" - CT_KconfigDisableOption "LINUXTHREADS_OLD" "${dst}" - CT_KconfigDisableOption "LINUXTHREADS_NEW" "${dst}" CT_KconfigEnableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}" ;; *) @@ -426,29 +330,22 @@ manage_uClibc_config() { CT_KconfigEnableOption "PTHREADS_DEBUG_SUPPORT" "${dst}" # Force on debug options if asked for + CT_KconfigDisableOption "DODEBUG" "${dst}" + CT_KconfigDisableOption "DODEBUG_PT" "${dst}" + CT_KconfigDisableOption "DOASSERTS" "${dst}" + CT_KconfigDisableOption "SUPPORT_LD_DEBUG" "${dst}" + CT_KconfigDisableOption "SUPPORT_LD_DEBUG_EARLY" "${dst}" + CT_KconfigDisableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}" case "${CT_LIBC_UCLIBC_DEBUG_LEVEL}" in 0) - CT_KconfigDisableOption "DODEBUG" "${dst}" - CT_KconfigDisableOption "DODEBUG_PT" "${dst}" - CT_KconfigDisableOption "DOASSERTS" "${dst}" - CT_KconfigDisableOption "SUPPORT_LD_DEBUG" "${dst}" - CT_KconfigDisableOption "SUPPORT_LD_DEBUG_EARLY" "${dst}" - CT_KconfigDisableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}" ;; 1) CT_KconfigEnableOption "DODEBUG" "${dst}" - CT_KconfigDisableOption "DODEBUG_PT" "${dst}" - CT_KconfigDisableOption "DOASSERTS" "${dst}" - CT_KconfigDisableOption "SUPPORT_LD_DEBUG" "${dst}" - CT_KconfigDisableOption "SUPPORT_LD_DEBUG_EARLY" "${dst}" - CT_KconfigDisableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}" ;; 2) CT_KconfigEnableOption "DODEBUG" "${dst}" - CT_KconfigDisableOption "DODEBUG_PT" "${dst}" CT_KconfigEnableOption "DOASSERTS" "${dst}" CT_KconfigEnableOption "SUPPORT_LD_DEBUG" "${dst}" - CT_KconfigDisableOption "SUPPORT_LD_DEBUG_EARLY" "${dst}" CT_KconfigEnableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}" ;; 3) @@ -460,6 +357,13 @@ manage_uClibc_config() { CT_KconfigEnableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}" ;; esac + + # Remove stripping: its the responsibility of the + # firmware builder to strip or not. + CT_KconfigDisableOption "DOSTRIP" "${dst}" + + # Now allow architecture to tweak as it wants + CT_DoArchUClibcConfig "${dst}" } do_libc_post_cc() { -- cgit v1.2.3 From f2ffdf798ddcd5b471a5055c18215ca2988ddf29 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 5 Apr 2016 14:47:20 -0700 Subject: First stab at multilib/uClibc. Create a separate 'libc_backend_once', install headers into a subdirectory (different sets of headers are installed for 32- and 64-bit architectures), and create a symlink for the dynamic linker location expected by GCC. Signed-off-by: Alexey Neyman --- scripts/build/arch.sh | 24 +++++++- scripts/build/arch/arm.sh | 62 ++++++++++++++++++- scripts/build/arch/mips.sh | 22 +++++++ scripts/build/arch/x86.sh | 37 +++++++++++ scripts/build/libc/uClibc.sh | 144 ++++++++++++++++++++++++++++++++++++++----- 5 files changed, 273 insertions(+), 16 deletions(-) (limited to 'scripts/build/arch') diff --git a/scripts/build/arch.sh b/scripts/build/arch.sh index 6414b54a..b75c1bed 100644 --- a/scripts/build/arch.sh +++ b/scripts/build/arch.sh @@ -29,11 +29,33 @@ CT_DoArchUClibcSelectArch() { } # uClibc: Adjust configuration file according to the CT-NG configuration -# Usage CT_DoArchUClibcConfig +# Usage: CT_DoArchUClibcConfig CT_DoArchUClibcConfig() { CT_DoLog WARN "Support for '${CT_ARCH}' is not implemented in uClibc config tweaker." CT_DoLog WARN "Exact configuration file must be provided." } +# Multilib/uClibc: Adjust configuration file for given CFLAGS +# Usage: CT_DoArchUClibcCflags +CT_DoArchUClibcCflags() { + local cfg="${1}" + local cflags="${2}" + + # Likely, any non-default cflags need to be reflected into the config. + # It may work if we just pass them into EXTRA_CFLAGS, but we have no + # idea as they might interact with the CFLAGS inferred by uClibc from + # the configuration file. + if [ "${cflags}" != "" ]; then + CT_DoLog WARN "Multilib configuration not supported for uClibc/${CT_ARCH}" + fi +} + +# Multilib/uClibc: Adjust header installation path for given CFLAGS +# Usage: CT_DoArchUClibcHeaderDir +CT_DoArchUClibcHeaderDir() { + # Only needed if a given architecture may select different uClibc architectures. + :; +} + # Override from the actual arch implementation as needed. . "${CT_LIB_DIR}/scripts/build/arch/${CT_ARCH}.sh" diff --git a/scripts/build/arch/arm.sh b/scripts/build/arch/arm.sh index 8af00722..b728311e 100644 --- a/scripts/build/arch/arm.sh +++ b/scripts/build/arch/arm.sh @@ -27,7 +27,6 @@ CT_DoArchTupleValues() { thumb) CT_ARCH_CC_CORE_EXTRA_CONFIG="--with-mode=thumb" CT_ARCH_CC_EXTRA_CONFIG="--with-mode=thumb" -# CT_ARCH_TARGET_CFLAGS="-mthumb" ;; esac @@ -38,6 +37,23 @@ CT_DoArchTupleValues() { if [ "${CT_ARCH_ARM_TUPLE_USE_EABIHF}" = "y" ]; then CT_TARGET_SYS="${CT_TARGET_SYS}hf" fi + + # If building multilib, zero out any WITH_*/*_CFLAG - GCC on ARM does not allow + # any of them with multilib. + if [ "${CT_MULTILIB}" = "y" ]; then + CT_ARCH_WITH_ARCH= + CT_ARCH_WITH_ABI= + CT_ARCH_WITH_CPU= + CT_ARCH_WITH_TUNE= + CT_ARCH_WITH_FPU= + CT_ARCH_WITH_FLOAT= + CT_ARCH_ARCH_CFLAG= + CT_ARCH_ABI_CFLAG= + CT_ARCH_CPU_CFLAG= + CT_ARCH_TUNE_CFLAG= + CT_ARCH_FPU_CFLAG= + CT_ARCH_FLOAT_CFLAG= + fi } CT_DoArchUClibcConfig() { @@ -45,6 +61,15 @@ CT_DoArchUClibcConfig() { CT_DoArchUClibcSelectArch "${cfg}" "arm" + case "${CT_ARCH_ARM_MODE}" in + arm) + CT_KconfigDisableOption "COMPILE_IN_THUMB_MODE" "${cfg}" + ;; + thumb) + CT_KconfigEnableOption "COMPILE_IN_THUMB_MODE" "${cfg}" + ;; + esac + # FIXME: CONFIG_ARM_OABI does not exist in neither uClibc/uClibc-ng # FIXME: CONFIG_ARM_EABI does not seem to affect anything in either of them, too # (both check the compiler's built-in define, __ARM_EABI__ instead) except for @@ -58,3 +83,38 @@ CT_DoArchUClibcConfig() { CT_KconfigEnableOption "CONFIG_ARM_OABI" "${cfg}" fi } + +CT_DoArchUClibcCflags() { + local cfg="${1}" + local cflags="${2}" + local f + + for f in ${cflags}; do + case "${f}" in + -mthumb) + CT_KconfigEnableOption "COMPILE_IN_THUMB_MODE" "${cfg}" + ;; + -marm) + CT_KconfigDisableOption "COMPILE_IN_THUMB_MODE" "${cfg}" + ;; + -mlittle-endian) + CT_KconfigDisableOption "ARCH_BIG_ENDIAN" "${cfg}" + CT_KconfigDisableOption "ARCH_WANTS_BIG_ENDIAN" "${cfg}" + CT_KconfigEnableOption "ARCH_LITTLE_ENDIAN" "${cfg}" + CT_KconfigEnableOption "ARCH_WANTS_LITTLE_ENDIAN" "${cfg}" + ;; + -mbig-endian) + CT_KconfigEnableOption "ARCH_BIG_ENDIAN" "${cfg}" + CT_KconfigEnableOption "ARCH_WANTS_BIG_ENDIAN" "${cfg}" + CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${cfg}" + CT_KconfigDisableOption "ARCH_WANTS_LITTLE_ENDIAN" "${cfg}" + ;; + -mhard-float|-mfloat-abi=hard|-mfloat-abi=softfp) + CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${cfg}" + ;; + -msoft-float|-mfloat-abi=soft) + CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}" + ;; + esac + done +} diff --git a/scripts/build/arch/mips.sh b/scripts/build/arch/mips.sh index 030e77b6..6097c89f 100644 --- a/scripts/build/arch/mips.sh +++ b/scripts/build/arch/mips.sh @@ -47,3 +47,25 @@ CT_DoArchUClibcConfig() { CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64" "${cfg}" CT_KconfigDeleteOption "CONFIG_MIPS_ISA_MIPS64R2" "${cfg}" } + +CT_DoArchUClibcCflags() { + local cfg="${1}" + local cflags="${2}" + local f + + for f in ${cflags}; do + case "${f}" in + -mabi=*) + CT_KconfigDisableOption "CONFIG_MIPS_O32_ABI" "${cfg}" + CT_KconfigDisableOption "CONFIG_MIPS_N32_ABI" "${cfg}" + CT_KconfigDisableOption "CONFIG_MIPS_N64_ABI" "${cfg}" + case "${f#-mabi=}" in + 32) CT_KconfigEnableOption "CONFIG_MIPS_O32_ABI" "${cfg}";; + n32) CT_KconfigEnableOption "CONFIG_MIPS_N32_ABI" "${cfg}";; + 64) CT_KconfigEnableOption "CONFIG_MIPS_N64_ABI" "${cfg}";; + *) CT_Abort "Unsupported ABI: ${f#-mabi=}";; + esac + ;; + esac + done +} diff --git a/scripts/build/arch/x86.sh b/scripts/build/arch/x86.sh index 41932782..9cd14a04 100644 --- a/scripts/build/arch/x86.sh +++ b/scripts/build/arch/x86.sh @@ -130,3 +130,40 @@ CT_DoArchUClibcConfig() { ;; esac } + +CT_DoArchUClibcCflags() { + local cfg="${1}" + local cflags="${2}" + local f + + for f in ${cflags}; do + case "${f}" in + -m64) + CT_DoArchUClibcSelectArch "${cfg}" "x86_64" + ;; + -m32) + # Since it's a part of multilib with 64-bit flavor, default + # to new architecture (i686). + CT_DoArchUClibcSelectArch "${cfg}" "i386" + CT_KconfigDisableOption "CONFIG_386" "${cfg}" + CT_KconfigDisableOption "CONFIG_486" "${cfg}" + CT_KconfigDisableOption "CONFIG_586" "${cfg}" + CT_KconfigEnableOption "CONFIG_686" "${cfg}" + ;; + -mx32) + CT_Abort "uClibc does not support x32 ABI" + ;; + esac + done +} + +CT_DoArchUClibcHeaderDir() { + local dir_var="${1}" + local cflags="${2}" + + # If it is non-default multilib, add a suffix with architecture (reported by gcc) + # to the headers installation path. + if [ -n "${cflags}" ]; then + eval "${dir_var}="$( ${CT_TARGET}-gcc -print-multiarch ${cflags} ) + fi +} diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh index 1e2a2908..822d3817 100644 --- a/scripts/build/libc/uClibc.sh +++ b/scripts/build/libc/uClibc.sh @@ -63,12 +63,13 @@ do_libc() { do_libc_backend libc_mode=final } -# Common backend for 1st and 2nd passes +# Common backend for 1st and 2nd passes. do_libc_backend() { local libc_mode - local multi_os_dir multi_root multilib_dir startfiles_dir - local jflag=${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}} - local -a make_args + local -a multilibs + local multilib + local multi_dir multi_os_dir multi_flags + local ldso ldso_f ldso_d multilib_dir for arg in "$@"; do eval "${arg// /\\ }" @@ -80,14 +81,86 @@ do_libc_backend() { *) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";; esac + # See glibc.sh for the explanation of this magic. + multilibs=( $("${CT_TARGET}-gcc" -print-multi-lib 2>/dev/null) ) + for multilib in "${multilibs[@]}"; do + multi_flags=$( echo "${multilib#*;}" | ${sed} -r -e 's/@/ -/g;' ) + multi_dir="${multilib%%;*}" + multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ${multi_flags} ) + multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ${multi_flags} ) + + CT_DoStep INFO "Building for multilib '${multi_flags}'" + do_libc_backend_once multi_dir="${multi_dir}" \ + multi_os_dir="${multi_os_dir}" \ + multi_flags="${multi_flags}" \ + multi_root="${multi_root}" \ + libc_mode="${libc_mode}" + CT_EndStep + done + + if [ "${libc_mode}" = "final" -a "${CT_SHARED_LIBS}" = "y" ]; then + # uClibc and GCC disagree where the dynamic linker lives. uClibc always + # places it in the MULTILIB_DIR, while gcc does that for *some* variants + # and expects it in /lib for the other. So, create a symlink from lib + # to the actual location, but only if that will not override the actual + # file in /lib. Thus, need to do this after all the variants are built. + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-test-ldso" + echo "int main(void) { return 0; }" > dummy.c + for multilib in "${multilibs[@]}"; do + multi_flags=$( echo "${multilib#*;}" | ${sed} -r -e 's/@/ -/g;' ) + multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ${multi_flags} ) + multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ${multi_flags} ) + multilib_dir="/lib/${multi_os_dir}" + CT_SanitizeVarDir multilib_dir + + CT_DoExecLog ALL "${CT_TARGET}-gcc" -o dummy dummy.c ${multi_flags} + ldso=$( ${CT_TARGET}-readelf -Wl dummy | \ + grep 'Requesting program interpreter: ' | \ + sed -e 's,.*: ,,' -e 's,\].*,,' ) + ldso_d="${ldso%/ld*.so.*}" + ldso_f="${ldso##*/}" + if [ -z "${ldso}" -o "${ldso_d}" = "${multilib_dir}" ]; then + # GCC cannot produce shared executable, or the base directory + # for ld.so is the same as the multi_os_directory + continue + fi + + # If there is no such file in the expected ldso dir, create a symlink to + # multilib_dir ld.so + if [ ! -r "${multi_root}${ldso}" ]; then + # Convert ldso_d to "how many levels we need to go up" and remove + # leading slash. + ldso_d=$( echo "${ldso_d#/}" | sed 's,[^/]\+,..,g' ) + CT_DoExecLog ALL ln -sf "${ldso_d}${multilib_dir}/${ldso_f}" \ + "${multi_root}${ldso}" + fi + done + CT_Popd + fi + + CT_EndStep +} + +# Common backend for 1st and 2nd passes, once per multilib. +do_libc_backend_once() { + local libc_mode + local multi_dir multi_os_dir multi_root multilib_dir startfiles_dir + local jflag=${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}} + local -a make_args + local build_dir + local extra_cflags f cfg_cflags cf + local hdr_install_subdir + + for arg in "$@"; do + eval "${arg// /\\ }" + done + # Simply copy files until uClibc has the ability to build out-of-tree CT_DoLog EXTRA "Copying sources to build dir" - CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}" \ - "${CT_BUILD_DIR}/build-libc-${libc_mode}" - cd "${CT_BUILD_DIR}/build-libc-${libc_mode}" + build_dir="${CT_BUILD_DIR}/build-libc-${libc_mode}${multi_dir//\//_}" + CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}" "${build_dir}" + cd "${build_dir}" - multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ) - multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ) multilib_dir="lib/${multi_os_dir}" startfiles_dir="${multi_root}/usr/${multilib_dir}" CT_SanitizeVarDir multilib_dir startfiles_dir @@ -103,7 +176,6 @@ do_libc_backend() { # - We do _not_ want to strip anything for now, in case we specifically # asked for a debug toolchain, thus the STRIPTOOL= assignment. make_args=( CROSS_COMPILE="${CT_TARGET}-" \ - UCLIBC_EXTRA_CFLAGS="-pipe" \ PREFIX="${multi_root}/" \ MULTILIB_DIR="${multilib_dir}" \ LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ @@ -120,10 +192,45 @@ do_libc_backend() { CT_LIBC_UCLIBC_CONFIG_FILE="${CT_LIB_DIR}/contrib/uClibc-defconfigs/${uclibc_name}.config" fi - manage_uClibc_config "${CT_LIBC_UCLIBC_CONFIG_FILE}" .config - + manage_uClibc_config "${CT_LIBC_UCLIBC_CONFIG_FILE}" .config "${multi_flags}" CT_DoYes | CT_DoExecLog ALL ${make} "${make_args[@]}" oldconfig + # Now filter the multilib flags. manage_uClibc_config did the opposite of + # what Rules.mak in uClibc would do: by the multilib's CFLAGS, it determined + # the applicable configuration options. We don't want to pass the same options + # in the UCLIBC_EXTRA_CFLAGS again (on some targets, the options do not correctly + # override each other). On the other hand, we do not want to lose the options + # that are not reflected in the .config. + extra_cflags="-pipe" + { echo "include Rules.mak"; echo "show-cpu-flags:"; printf '\t@echo $(CPU_CFLAGS)\n'; } \ + > .show-cpu-cflags.mk + cfg_cflags=$( ${make} "${make_args[@]}" \ + --no-print-directory -f .show-cpu-cflags.mk show-cpu-flags ) + CT_DoExecLog ALL rm -f .show-cpu-cflags.mk + CT_DoLog DEBUG "CPU_CFLAGS detected by uClibc: ${cfg_cflags[@]}" + for f in ${multi_flags}; do + for cf in ${cfg_cflags}; do + if [ "${f}" = "${cf}" ]; then + f= + break + fi + done + if [ -n "${f}" ]; then + extra_cflags+=" ${f}" + fi + done + CT_DoLog DEBUG "Filtered multilib CFLAGS: ${extra_cflags}" + make_args+=( UCLIBC_EXTRA_CFLAGS="${extra_cflags}" ) + + # uClibc does not have a way to select the installation subdirectory for headers, + # it is always $(DEVEL_PREFIX)/include. Also, we're reinstalling the headers + # at the final stage (see the note below), we may already have the subdirectory + # in /usr/include. + CT_DoArchUClibcHeaderDir hdr_install_subdir "${multi_flags}" + if [ -n "$hdr_install_subdir" ]; then + CT_DoExecLog ALL cp -a "${multi_root}/usr/include" "${multi_root}/usr/include.saved" + fi + if [ "${libc_mode}" = "startfiles" ]; then CT_DoLog EXTRA "Building headers" CT_DoExecLog ALL ${make} "${make_args[@]}" headers @@ -146,7 +253,7 @@ do_libc_backend() { # No problem to create it for other archs. CT_DoLog EXTRA "Building dummy shared libs" CT_DoExecLog ALL "${CT_TARGET}-gcc" -nostdlib -nostartfiles \ - -shared -x c /dev/null -o libdummy.so + -shared ${multi_flags} -x c /dev/null -o libdummy.so CT_DoLog EXTRA "Installing start files" CT_DoExecLog ALL ${install} -m 0644 lib/crt1.o lib/crti.o lib/crtn.o \ @@ -182,7 +289,14 @@ do_libc_backend() { CT_DoExecLog ALL ${make} "${make_args[@]}" install fi # libc_mode == final - CT_EndStep + # Now, if installing headers into a subdirectory, put everything in its place. + # Remove the header subdirectory if it existed already. + if [ -n "$hdr_install_subdir" ]; then + CT_DoExecLog ALL mv "${multi_root}/usr/include" "${multi_root}/usr/include.new" + CT_DoExecLog ALL mv "${multi_root}/usr/include.saved" "${multi_root}/usr/include" + CT_DoExecLog ALL rm -rf "${multi_root}/usr/include/${hdr_install_subdir}" + CT_DoExecLog ALL mv "${multi_root}/usr/include.new" "${multi_root}/usr/include/${hdr_install_subdir}" + fi } # Initialises the .config file to sensible values @@ -191,6 +305,7 @@ do_libc_backend() { manage_uClibc_config() { src="$1" dst="$2" + flags="$3" # Start with fresh files CT_DoExecLog ALL cp "${src}" "${dst}" @@ -364,6 +479,7 @@ manage_uClibc_config() { # Now allow architecture to tweak as it wants CT_DoArchUClibcConfig "${dst}" + CT_DoArchUClibcCflags "${dst}" "${flags}" } do_libc_post_cc() { -- cgit v1.2.3 From 98e556d3868b638a658f497af0b64ce04fc5287d Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Mon, 11 Apr 2016 13:59:16 -0700 Subject: Support multilib in sh/uClibc. Signed-off-by: Alexey Neyman --- scripts/build/arch/sh.sh | 32 ++++++++- scripts/build/libc/glibc.sh | 122 +++++----------------------------- scripts/build/libc/uClibc.sh | 125 ++++++++++++----------------------- scripts/functions | 151 +++++++++++++++++++++++++++++++++++-------- 4 files changed, 213 insertions(+), 217 deletions(-) (limited to 'scripts/build/arch') diff --git a/scripts/build/arch/sh.sh b/scripts/build/arch/sh.sh index 101e4ce8..6761435d 100644 --- a/scripts/build/arch/sh.sh +++ b/scripts/build/arch/sh.sh @@ -44,9 +44,39 @@ CT_DoArchUClibcConfig() { CT_KconfigDisableOption "CONFIG_SH3" "${cfg}" CT_KconfigDisableOption "CONFIG_SH4" "${cfg}" CT_KconfigDisableOption "CONFIG_SH4A" "${cfg}" - case "${CT_ARCH_SH_VARIAN}" in + case "${CT_ARCH_SH_VARIANT}" in sh3) CT_KconfigEnableOption "CONFIG_SH3" "${cfg}";; sh4) CT_KconfigEnableOption "CONFIG_SH4" "${cfg}";; sh4a) CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}";; esac } + +CT_DoArchUClibcCflags() { + local cfg="${1}" + local cflags="${2}" + local f + + for f in ${cflags}; do + case "${f}" in + -m3) + CT_KconfigEnableOption "CONFIG_SH3" "${cfg}" + ;; + -m4) + CT_KconfigEnableOption "CONFIG_SH4" "${cfg}" + CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${cfg}" + ;; + -m4-nofpu) + CT_KconfigEnableOption "CONFIG_SH4" "${cfg}" + CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}" + ;; + -m4a) + CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}" + CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${cfg}" + ;; + -m4a-nofpu) + CT_KconfigEnableOption "CONFIG_SH4A" "${cfg}" + CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${cfg}" + ;; + esac + done +} diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 8093e08b..8027b8f8 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -64,11 +64,6 @@ do_libc_post_cc() { # libc_mode : 'startfiles' or 'final' : string : (none) do_libc_backend() { local libc_mode - local -a multilibs - local multilib - local multi_dir multi_os_dir multi_root multi_flags multi_last - local root_suffix - local target local arg for arg in "$@"; do @@ -88,94 +83,7 @@ do_libc_backend() { esac CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" - - # If gcc is not configured for multilib, it still prints - # a single line for the default settings - multilibs=( $("${CT_TARGET}-gcc" -print-multi-lib 2>/dev/null) ) - for multilib in "${multilibs[@]}"; do - # GCC makes the distinction between: - # multilib (-print-multi-lib or -print-multi-directory) and - # multilib-os (--print-multi-os-directory) - # as the gcc library and gcc sysroot library paths, respectively. - # For example, on x86_64: - # multilib: -m32=32 -m64=. - # multilib-os: -m32=../lib -m64=../lib64 - # Moreover, while some multilibs can coexist in the same sysroot (e.g. - # on x86), some have a "sysroot suffix" to separate incompatible variants. - # Such sysroot suffixes combine with multilib-os directories, e.g. - # on sh4 with -m4a multilib, the search order in sysroot is (dropping some - # directories for brevity: - # /m4a/lib/m4a/ - # /m4a/usr/lib/m4a/ - # /m4a/lib/ - # /m4a/usr/lib/ - # The problem is that while GCC itself is aware of these subtleties, the - # binutils (notably, ld) it invokes under the hood are not. For example, - # if a shared library libfoo.so.1 requires libbar.so.1, ld will only search - # for libbar.so.1 in /m4a/usr/lib, but not in /m4a/usr/lib/m4a. - # In other words, 'gcc -lfoo -lbar' will work for both the default and -m4a - # cases, and 'gcc -lfoo' will work for the default, but not for -m4a. To - # address this, we first try to determine if the sysroot alone makes the - # configuration sufficiently unique. If there are no multilibs within the - # same suffixed sysroot, we can drop the multi_os_dir and both gcc and ld - # will work. If not, we'll supply both multi_root/multi_os_dir (which will - # likely break later, e.g. while building final GCC with C++ support). But, - # we've done all we can. - multi_flags=$( echo "${multilib#*;}" | ${sed} -r -e 's/@/ -/g;' ) - multi_dir="${multilib%%;*}" - multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ${multi_flags} ) - multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ${multi_flags} ) - root_suffix="${multi_root#${CT_SYSROOT_DIR}}" - CT_DoExecLog ALL mkdir -p "sysroot${root_suffix}" - if [ -e "sysroot${root_suffix}/seen" ]; then - CT_DoExecLog ALL rm -f "sysroot${root_suffix}/unique" - else - CT_DoExecLog ALL touch "sysroot${root_suffix}/seen" "sysroot${root_suffix}/unique" - fi - done - - last_multi= - for multilib in "${multilibs[@]}"; do - last_multi=$(( ${#multilibs[@]} - 1 )) - if [ "${multilib%%;*}" = "${multilibs[last_multi]%%;*}" ]; then - # This is the last multilib build or multilib is '.' - # (default target, not multilib) - multi_last=y - fi - - multi_flags=$( echo "${multilib#*;}" | ${sed} -r -e 's/@/ -/g;' ) - multi_dir="${multilib%%;*}" - multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ${multi_flags} ) - multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ${multi_flags} ) - root_suffix="${multi_root#${CT_SYSROOT_DIR}}" - - # Avoid multi_os_dir if it's the only directory in this sysroot. - if [ -e "sysroot${root_suffix}/unique" ]; then - multi_os_dir=. - fi - - # Adjust target tuple according to CFLAGS + any GLIBC quirks - target="${CT_TARGET}" - CT_DoMultilibTarget target ${extra_flags} - CT_DoArchGlibcAdjustTuple target - CT_DoStep INFO "Building for multilib '${multi_flags}'" - - # Ensure sysroot (with suffix, if applicable) exists - CT_DoExecLog ALL mkdir -p "${multi_root}" - CT_mkdir_pushd "multilib_${multi_dir//\//_}" - do_libc_backend_once multi_dir="${multi_dir}" \ - multi_os_dir="${multi_os_dir}" \ - multi_flags="${multi_flags}" \ - multi_root="${multi_root}" \ - multi_last="${multi_last}" \ - libc_mode="${libc_mode}" \ - libc_target="${target}" - - CT_Popd - CT_EndStep - - done - + CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}" CT_Popd CT_EndStep } @@ -184,26 +92,28 @@ do_libc_backend() { # Usage: do_libc_backend_once param=value [...] # Parameter : Definition : Type # libc_mode : 'startfiles' or 'final' : string : (empty) -# libc_target : Build libc target triplet : string : (empty) -# multi_root : Installation root, chosen for multilib: string : (empty) -# multi_flags : Extra CFLAGS to use (for multilib) : string : (empty) -# multi_dir : Extra subdir for multilib (gcc) : string : (empty) -# multi_os_dir : Extra subdir for multilib (os) : string : (empty) -# multi_last : The last multilib target : bool : n +# multi_* : as defined in CT_IterateMultilibs : (varies) : do_libc_backend_once() { - local multi_flags multi_dir multi_os_dir multi_root multi_last multi_root + local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count local startfiles_dir local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}" local -a extra_config local -a extra_make_args local glibc_cflags - local libc_target="${CT_TARGET}" local arg opt for arg in "$@"; do eval "${arg// /\\ }" done + CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'" + + # Ensure sysroot (with suffix, if applicable) exists + CT_DoExecLog ALL mkdir -p "${multi_root}" + + # Adjust target tuple according GLIBC quirks + CT_DoArchGlibcAdjustTuple multi_target + # Glibc seems to be smart enough to know about the cases that can coexist # in the same root and installs them into proper multilib-os directory; all # we need is to point to the right root. We do need to handle multilib-os @@ -335,7 +245,7 @@ do_libc_backend_once() { CT_DoLog DEBUG "Extra config args passed : '${extra_config[*]}'" CT_DoLog DEBUG "Extra CFLAGS passed : '${glibc_cflags}'" CT_DoLog DEBUG "Placing startfiles into : '${startfiles_dir}'" - CT_DoLog DEBUG "Configuring with --host : '${libc_target}'" + CT_DoLog DEBUG "Configuring with --host : '${multi_target}'" # CFLAGS are only applied when compiling .c files. .S files are compiled with ASFLAGS, # but they are not passed by configure. Thus, pass everything in CC instead. @@ -348,7 +258,7 @@ do_libc_backend_once() { "${src_dir}/configure" \ --prefix=/usr \ --build=${CT_BUILD} \ - --host=${libc_target} \ + --host=${multi_target} \ --cache-file="$(pwd)/config.cache" \ --without-cvs \ --disable-profile \ @@ -474,7 +384,7 @@ do_libc_backend_once() { install_root="${multi_root}" \ install - if [ "${CT_BUILD_MANUALS}" = "y" -a "${multi_last}" = "y" ]; then + if [ "${CT_BUILD_MANUALS}" = "y" -a "${multi_index}" = "${multi_count}" ]; then # We only need to build the manuals once. Only build them on the # last multilib target. If it's not multilib, it will happen on the # only target. @@ -488,10 +398,12 @@ do_libc_backend_once() { ${CT_PREFIX_DIR}/share/doc fi - if [ "${CT_LIBC_LOCALES}" = "y" -a "${multi_last}" = "y" ]; then + if [ "${CT_LIBC_LOCALES}" = "y" -a "${multi_index}" = "${multi_count}" ]; then do_libc_locales fi fi # libc_mode = final + + CT_EndStep } # Build up the addons list, separated with $1 diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh index edde8159..046ba1d0 100644 --- a/scripts/build/libc/uClibc.sh +++ b/scripts/build/libc/uClibc.sh @@ -66,10 +66,7 @@ do_libc() { # Common backend for 1st and 2nd passes. do_libc_backend() { local libc_mode - local -a multilibs - local multilib - local multi_dir multi_os_dir multi_flags - local ldso ldso_f ldso_d multilib_dir + local arg for arg in "$@"; do eval "${arg// /\\ }" @@ -82,43 +79,7 @@ do_libc_backend() { esac CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" - - # See glibc.sh for the explanation of this magic. - multilibs=( $("${CT_TARGET}-gcc" -print-multi-lib 2>/dev/null) ) - for multilib in "${multilibs[@]}"; do - multi_flags=$( echo "${multilib#*;}" | ${sed} -r -e 's/@/ -/g;' ) - multi_dir="${multilib%%;*}" - multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ${multi_flags} ) - multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ${multi_flags} ) - root_suffix="${multi_root#${CT_SYSROOT_DIR}}" - CT_DoExecLog ALL mkdir -p "sysroot${root_suffix}" - if [ -e "sysroot${root_suffix}/seen" ]; then - CT_DoExecLog ALL rm -f "sysroot${root_suffix}/unique" - else - CT_DoExecLog ALL touch "sysroot${root_suffix}/seen" "sysroot${root_suffix}/unique" - fi - done - - for multilib in "${multilibs[@]}"; do - multi_flags=$( echo "${multilib#*;}" | ${sed} -r -e 's/@/ -/g;' ) - multi_dir="${multilib%%;*}" - multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ${multi_flags} ) - multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ${multi_flags} ) - root_suffix="${multi_root#${CT_SYSROOT_DIR}}" - - # Avoid multi_os_dir if it's the only directory in this sysroot. - if [ -e "sysroot${root_suffix}/unique" ]; then - multi_os_dir=. - fi - - CT_DoStep INFO "Building for multilib '${multi_flags}'" - do_libc_backend_once multi_dir="${multi_dir}" \ - multi_os_dir="${multi_os_dir}" \ - multi_flags="${multi_flags}" \ - multi_root="${multi_root}" \ - libc_mode="${libc_mode}" - CT_EndStep - done + CT_IterateMultilibs do_libc_backend_once multilib libc_mode="${libc_mode}" if [ "${libc_mode}" = "final" -a "${CT_SHARED_LIBS}" = "y" ]; then # uClibc and GCC disagree where the dynamic linker lives. uClibc always @@ -127,42 +88,7 @@ do_libc_backend() { # to the actual location, but only if that will not override the actual # file in /lib. Thus, need to do this after all the variants are built. echo "int main(void) { return 0; }" > test-ldso.c - for multilib in "${multilibs[@]}"; do - multi_flags=$( echo "${multilib#*;}" | ${sed} -r -e 's/@/ -/g;' ) - multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ${multi_flags} ) - multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ${multi_flags} ) - root_suffix="${multi_root#${CT_SYSROOT_DIR}}" - - # Avoid multi_os_dir if it's the only directory in this sysroot. - if [ -e "sysroot${root_suffix}/unique" ]; then - multi_os_dir=. - fi - - multilib_dir="/lib/${multi_os_dir}" - CT_SanitizeVarDir multilib_dir - - CT_DoExecLog ALL "${CT_TARGET}-gcc" -o test-ldso test-ldso.c ${multi_flags} - ldso=$( ${CT_TARGET}-readelf -Wl test-ldso | \ - grep 'Requesting program interpreter: ' | \ - sed -e 's,.*: ,,' -e 's,\].*,,' ) - ldso_d="${ldso%/ld*.so.*}" - ldso_f="${ldso##*/}" - if [ -z "${ldso}" -o "${ldso_d}" = "${multilib_dir}" ]; then - # GCC cannot produce shared executable, or the base directory - # for ld.so is the same as the multi_os_directory - continue - fi - - # If there is no such file in the expected ldso dir, create a symlink to - # multilib_dir ld.so - if [ ! -r "${multi_root}${ldso}" ]; then - # Convert ldso_d to "how many levels we need to go up" and remove - # leading slash. - ldso_d=$( echo "${ldso_d#/}" | sed 's,[^/]\+,..,g' ) - CT_DoExecLog ALL ln -sf "${ldso_d}${multilib_dir}/${ldso_f}" \ - "${multi_root}${ldso}" - fi - done + CT_IterateMultilibs do_libc_ldso_fixup ldso_fixup fi CT_Popd @@ -172,10 +98,10 @@ do_libc_backend() { # Common backend for 1st and 2nd passes, once per multilib. do_libc_backend_once() { local libc_mode - local multi_dir multi_os_dir multi_root multilib_dir startfiles_dir + local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count + local multilib_dir startfiles_dir local jflag=${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}} local -a make_args - local build_dir local extra_cflags f cfg_cflags cf local hdr_install_subdir @@ -183,11 +109,11 @@ do_libc_backend_once() { eval "${arg// /\\ }" done + CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'" + # Simply copy files until uClibc has the ability to build out-of-tree CT_DoLog EXTRA "Copying sources to build dir" - build_dir="multilib_${multi_dir//\//_}" - CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}" "${build_dir}" - CT_Pushd "${build_dir}" + CT_DoExecLog ALL cp -aT "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}" . multilib_dir="lib/${multi_os_dir}" startfiles_dir="${multi_root}/usr/${multilib_dir}" @@ -326,7 +252,40 @@ do_libc_backend_once() { CT_DoExecLog ALL mv "${multi_root}/usr/include.new" "${multi_root}/usr/include/${hdr_install_subdir}" fi - CT_Popd + CT_EndStep +} + +do_libc_ldso_fixup() { + local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count + local ldso ldso_f ldso_d multilib_dir + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoLog EXTRA "Checking dynamic linker for multilib '${multi_flags}'" + + multilib_dir="/lib/${multi_os_dir}" + CT_SanitizeVarDir multilib_dir + + CT_DoExecLog ALL "${CT_TARGET}-gcc" -o test-ldso ../test-ldso.c ${multi_flags} + ldso=$( ${CT_TARGET}-readelf -Wl test-ldso | \ + grep 'Requesting program interpreter: ' | \ + sed -e 's,.*: ,,' -e 's,\].*,,' ) + CT_DoLog DEBUG "Detected dynamic linker for multilib '${multi_flags}': '${ldso}'" + + ldso_d="${ldso%/ld*.so.*}" + ldso_f="${ldso##*/}" + # Create symlink if GCC produced an executable, dynamically linked, it was requesting + # a linker not in the current directory, and there is no such file in the expected + # ldso dir. + if [ -n "${ldso}" -a "${ldso_d}" != "${multilib_dir}" -a ! -r "${multi_root}${ldso}" ]; then + # Convert ldso_d to "how many levels we need to go up" and remove + # leading slash. + ldso_d=$( echo "${ldso_d#/}" | sed 's,[^/]\+,..,g' ) + CT_DoExecLog ALL ln -sf "${ldso_d}${multilib_dir}/${ldso_f}" \ + "${multi_root}${ldso}" + fi } # Initialises the .config file to sensible values diff --git a/scripts/functions b/scripts/functions index ef75e09e..f1dfd127 100644 --- a/scripts/functions +++ b/scripts/functions @@ -1366,25 +1366,6 @@ CT_DoBuildTargetTuple() { fi } -# This function determines the target tuple for a given set of compiler -# flags, using either GCC's multiarch feature (if supported; if not, -# GCC prints nothing and exits with status 0), falling back to calling -# the architecture-specific functions. -CT_DoMultilibTarget() { - local target_var="$1"; shift - local -a multi_flags=( "$@" ) - local gcc_multiarch - - gcc_multiarch=$( "${CT_TARGET}-gcc" -print-multiarch "${multi_flags[@]}" ) - if [ -n "${gcc_multiarch}" ]; then - eval "${target_var}=${gcc_multiarch}" - return - fi - - # Fall back to arch-specific guesswork - CT_DoArchMultilibTarget "${target_var}" "${multi_flags[@]}" -} - # This function does pause the build until the user strikes "Return" # Usage: CT_DoPause [optional_message] CT_DoPause() { @@ -1529,9 +1510,9 @@ CT_DoLoadState(){ # This function sets a kconfig option to a specific value in a .config file # Usage: CT_KconfigSetOption