From 712b617a744aa941b99d32d9ff6d9126c77382fb Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 15 Mar 2016 12:39:03 -0700 Subject: Unbreak sparc-unknown-linux-gnu. GLIBC 2.23 dropped support for pre-v9 SPARC in pthreads. Pass host triplet with s/sparc/sparcv9/ replacement for 2.23. Signed-off-by: Alexey Neyman --- scripts/build/libc/glibc.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'scripts/build/libc') diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 0a09cbd1..013c6ebd 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -73,6 +73,7 @@ do_libc_backend() { local multi_dir local multi_flags local extra_dir + local target local libc_headers libc_startfiles libc_full local hdr local arg @@ -136,11 +137,24 @@ do_libc_backend() { CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}${extra_dir//\//_}" + target=${CT_TARGET} + 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 + do_libc_backend_once extra_dir="${extra_dir}" \ extra_flags="${extra_flags}" \ libc_headers="${libc_headers}" \ libc_startfiles="${libc_startfiles}" \ - libc_full="${libc_full}" + libc_full="${libc_full}" \ + target="${target}" CT_Popd @@ -192,6 +206,7 @@ do_libc_backend_once() { local glibc_cflags local float_extra local endian_extra + local target local arg for arg in "$@"; do @@ -341,7 +356,7 @@ do_libc_backend_once() { "${src_dir}/configure" \ --prefix=/usr \ --build=${CT_BUILD} \ - --host=${CT_TARGET} \ + --host=${target} \ --cache-file="$(pwd)/config.cache" \ --without-cvs \ --disable-profile \ -- cgit v1.2.3 From 55879ed1d83ebb72f2ab6cbbd892448c731a7163 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 19 Mar 2016 00:13:52 -0700 Subject: glibc: do not add bogus options If a multilib configuration contains an endianness option, the ${endian_extra} is set to, for example, 'mb' (note, no dash!). It is then added to CFLAGS, resulting in bogus flags like 'mb -mb'. But it is not even needed, as ${extra_flags} already contains the very same option! Found by experimenting with multilibs with different endianness on SH, which still didn't work, but that's another story... Signed-off-by: Alexey Neyman --- scripts/build/libc/glibc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/build/libc') diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 013c6ebd..f8c970da 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -288,12 +288,12 @@ do_libc_backend_once() { |${sed} -r -e '/^(.*[[:space:]])?-(E[BL]|m((big|little)(-endian)?|e?[bl]))([[:space:]].*)?$/!d;' \ -e 's//\2/;' \ )" + # If extra_flags contained an endianness option, no need to add it again. Otherwise, + # add the option from the configuration. case "${endian_extra}" in EB|mbig-endian|mbig|meb|mb) - extra_cc_args="${extra_cc_args} ${endian_extra}" ;; EL|mlittle-endian|mlittle|mel|ml) - extra_cc_args="${extra_cc_args} ${endian_extra}" ;; "") extra_cc_args="${extra_cc_args} ${CT_ARCH_ENDIAN_OPT}" ;; -- cgit v1.2.3 From c7da54edf4c2e3a3eb97eb5fb967143e5071a670 Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Sat, 12 Apr 2014 13:16:52 +0100 Subject: glibc: Use common arch call to get multilib targets The previous patch added the function 'CT_DoMultilibTarget()' to scripts/build/arch/*.sh. This patch calls the common function to (currently) get just the target tuple for the current multilib target. This patch was originally by: Cody P Schafer Changed by Alexey Neyman: first, try `gcc -print-multiarch`. If it is supported, use whatever it reports. Otherwise, fall back to our guesswork. Move "i486" quirk into glibc.sh, as it is specific to glibc (e.g. uclibc will need i386, which is what GCC reports). Signed-off-by: Bryan Hundven Signed-off-by: Ray Donnelly Signed-off-by: Alexey Neyman --- scripts/build/libc/glibc.sh | 19 ++++++++++++++++++- scripts/functions | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'scripts/build/libc') diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index f8c970da..192a0055 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -137,7 +137,7 @@ do_libc_backend() { CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}${extra_dir//\//_}" - target=${CT_TARGET} + 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 @@ -147,6 +147,18 @@ do_libc_backend() { 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 do_libc_backend_once extra_dir="${extra_dir}" \ @@ -193,6 +205,7 @@ do_libc_backend() { # libc_full : Build full libc : bool : n # extra_flags : Extra CFLAGS to use (for multilib) : string : (empty) # extra_dir : Extra subdir for multilib : string : (empty) +# target : Build libc using this target (for multilib) : string : ${CT_TARGET} do_libc_backend_once() { local libc_headers local libc_startfiles @@ -213,6 +226,10 @@ do_libc_backend_once() { eval "${arg// /\\ }" done + if [ "${target}" = "" ]; then + target="${CT_TARGET}" + fi + CT_DoLog EXTRA "Configuring C library" case "${CT_LIBC}" in diff --git a/scripts/functions b/scripts/functions index 70c1ba61..62d264e3 100644 --- a/scripts/functions +++ b/scripts/functions @@ -1305,6 +1305,25 @@ CT_DoBuildTargetTuple() { CT_ARCH_TARGET_LDFLAGS="${CT_ARCH_TARGET_LDFLAGS} ${CT_ARCH_ENDIAN_LDFLAG}" } +# 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="$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}" + return + fi + + # Fall back to arch-specific guesswork + CT_DoArchMultilibTarget "${target}" "${multi_flags[@]}" +} + # This function does pause the build until the user strikes "Return" # Usage: CT_DoPause [optional_message] CT_DoPause() { -- cgit v1.2.3 From dc8f2d1c04258069101e913d22c898298b98384c Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Sat, 21 May 2016 16:53:19 -0700 Subject: glibc.sh: build dummy libc.so with correct extra flags Signed-off-by: Alexey Neyman --- scripts/build/libc/glibc.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts/build/libc') diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 192a0055..472acad4 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -475,7 +475,8 @@ do_libc_backend_once() { # However, since we will never actually execute its code, # it doesn't matter what it contains. So, treating '/dev/null' # as a C source file, we produce a dummy 'libc.so' in one step - CT_DoExecLog ALL "${cross_cc}" -nostdlib \ + CT_DoExecLog ALL "${cross_cc}" ${extra_flags} \ + -nostdlib \ -nostartfiles \ -shared \ -x c /dev/null \ -- cgit v1.2.3