From 43c303c946c61469181d633cd5620cb92e44c329 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Mon, 21 Mar 2016 11:18:53 -0700 Subject: libc/*.sh: handle combinations of multilib root/dir. Install startfiles for libc variants into the most specific combination (suffixed sysroot, if applicable + suffixed multi-os dir, if applicable). Install headers once in every suffixed sysroot (although it seems that GCC picks up headers from top-level sysroot, GCC manual claims that sysroot suffix affects headers search path). In uClibc, this requires a better sanitization of the directory: it creates symlinks from {sysroot}/usr/lib/{multi_os_dir} to {sysroot}/lib/{multi_os_dir} and to do so, it counts the number of path components in the libdir. This breaks if one of such components is `..' - symlinks contain an extra `../..' then. Since such sanitization had to be implemented anyway, use it in other places to print more sensible directory names. Also, fix the description of configure --host/--target per musl's configure help message (and its actual code). Signed-off-by: Alexey Neyman --- scripts/build/libc/uClibc.sh | 70 +++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 27 deletions(-) (limited to 'scripts/build/libc/uClibc.sh') diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh index 422412c9..7903a762 100644 --- a/scripts/build/libc/uClibc.sh +++ b/scripts/build/libc/uClibc.sh @@ -73,63 +73,62 @@ do_libc_check_config() { # Build and install headers and start files do_libc_start_files() { - local cross + local multi_os_dir multi_root startfiles_dir CT_DoStep INFO "Installing C library headers" # 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 -av "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}" \ + CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}" \ "${CT_BUILD_DIR}/build-libc-headers" cd "${CT_BUILD_DIR}/build-libc-headers" # Retrieve the config file CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/uClibc.config" .config - # uClibc uses the CROSS environment variable as a prefix to the - # compiler tools to use. Setting it to the empty string forces - # use of the native build host tools, which we need at this - # stage, as we don't have target tools yet. - # BUT! With NPTL, we need a cross-compiler (and we have it) - if [ "${CT_THREADS}" = "nptl" ]; then - cross="${CT_TARGET}-" - fi + multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ) + multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ) + startfiles_dir="${multi_root}/usr/lib/${multi_os_dir}" + CT_SanitizeVarDir startfiles_dir + CT_DoExecLog ALL mkdir -p "${startfiles_dir}" # Force the date of the pregen locale data, as the # newer ones that are referenced are not available CT_DoLog EXTRA "Applying configuration" CT_DoYes "" |CT_DoExecLog ALL \ - ${make} CROSS_COMPILE="${cross}" \ + ${make} CROSS_COMPILE="${CT_TARGET}-" \ UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${CT_SYSROOT_DIR}/" \ + PREFIX="${multi_root}/" \ LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ oldconfig CT_DoLog EXTRA "Building headers" CT_DoExecLog ALL \ ${make} ${CT_LIBC_UCLIBC_VERBOSITY} \ - CROSS_COMPILE="${cross}" \ + CROSS_COMPILE="${CT_TARGET}-" \ UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${CT_SYSROOT_DIR}/" \ + PREFIX="${multi_root}/" \ LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ headers CT_DoLog EXTRA "Installing headers" CT_DoExecLog ALL \ ${make} ${CT_LIBC_UCLIBC_VERBOSITY} \ - CROSS_COMPILE="${cross}" \ + CROSS_COMPILE="${CT_TARGET}-" \ UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${CT_SYSROOT_DIR}/" \ + PREFIX="${multi_root}/" \ LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ install_headers + # The check might look bogus, but it is the same condition as is used + # by GCC build script to enable/disable shared library support. if [ "${CT_THREADS}" = "nptl" ]; then CT_DoLog EXTRA "Building start files" CT_DoExecLog ALL \ ${make} ${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}} \ - CROSS_COMPILE="${cross}" \ + CROSS_COMPILE="${CT_TARGET}-" \ UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${CT_SYSROOT_DIR}/" \ + PREFIX="${multi_root}/" \ STRIPTOOL=true \ ${CT_LIBC_UCLIBC_VERBOSITY} \ LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ @@ -139,7 +138,7 @@ do_libc_start_files() { # libm.so is needed for ppc, as libgcc is linked against libm.so # No problem to create it for other archs. CT_DoLog EXTRA "Building dummy shared libs" - CT_DoExecLog ALL "${cross}gcc" -nostdlib \ + CT_DoExecLog ALL "${CT_TARGET}-gcc" -nostdlib \ -nostartfiles \ -shared \ -x c /dev/null \ @@ -147,11 +146,11 @@ do_libc_start_files() { CT_DoLog EXTRA "Installing start files" CT_DoExecLog ALL ${install} -m 0644 lib/crt1.o lib/crti.o lib/crtn.o \ - "${CT_SYSROOT_DIR}/usr/lib" + "${startfiles_dir}" CT_DoLog EXTRA "Installing dummy shared libs" - CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${CT_SYSROOT_DIR}/usr/lib/libc.so" - CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${CT_SYSROOT_DIR}/usr/lib/libm.so" + CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${startfiles_dir}/libc.so" + CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${startfiles_dir}/libm.so" fi # CT_THREADS == nptl CT_EndStep @@ -159,6 +158,8 @@ do_libc_start_files() { # This function build and install the full uClibc do_libc() { + local multi_os_dir multi_root multilib_dir startfiles_dir + CT_DoStep INFO "Installing C library" # Simply copy files until uClibc has the ability to build out-of-tree @@ -170,6 +171,20 @@ do_libc() { # Retrieve the config file CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/uClibc.config" .config + multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ) + multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ) + startfiles_dir="${multi_root}/usr/lib/${multi_os_dir}" + + CT_DoLog EXTRA "Cleaning up startfiles" + CT_DoExecLog ALL rm -f "${startfiles_dir}/crt1.o" \ + "${startfiles_dir}/crti.o" \ + "${startfiles_dir}/crtn.o" \ + "${startfiles_dir}/libc.so" \ + "${startfiles_dir}/libm.so" + + multilib_dir="lib/${multi_os_dir}" + CT_SanitizeVarDir multilib_dir + # uClibc uses the CROSS environment variable as a prefix to the compiler # tools to use. The newly built tools should be in our path, so we need # only give the correct name for them. @@ -181,7 +196,7 @@ do_libc() { CT_DoYes "" |CT_DoExecLog CFG \ ${make} CROSS_COMPILE=${CT_TARGET}- \ UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${CT_SYSROOT_DIR}/" \ + PREFIX="${multi_root}/" \ LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ oldconfig @@ -193,7 +208,7 @@ do_libc() { ${make} -j1 \ CROSS_COMPILE=${CT_TARGET}- \ UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${CT_SYSROOT_DIR}/" \ + PREFIX="${multi_root}/" \ STRIPTOOL=true \ ${CT_LIBC_UCLIBC_VERBOSITY} \ LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ @@ -202,7 +217,7 @@ do_libc() { ${make} ${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}} \ CROSS_COMPILE=${CT_TARGET}- \ UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${CT_SYSROOT_DIR}/" \ + PREFIX="${multi_root}/" \ STRIPTOOL=true \ ${CT_LIBC_UCLIBC_VERBOSITY} \ LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ @@ -220,16 +235,17 @@ do_libc() { # We do _not_ want to strip anything for now, in case we specifically # asked for a debug toolchain, hence the STRIPTOOL= assignment # - # Note: JOBSFLAGS is not usefull for installation. + # Note: JOBSFLAGS is not useful for installation. # CT_DoLog EXTRA "Installing C library" CT_DoExecLog ALL \ ${make} CROSS_COMPILE=${CT_TARGET}- \ UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${CT_SYSROOT_DIR}/" \ + PREFIX="${multi_root}/" \ STRIPTOOL=true \ ${CT_LIBC_UCLIBC_VERBOSITY} \ LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ + MULTILIB_DIR="${multilib_dir}" \ install CT_EndStep -- cgit v1.2.3 From 28c24f5034768c7f01ef2987d3e72dfdf7c438db Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Fri, 1 Apr 2016 18:24:27 -0700 Subject: uClibc.sh: typo, local -> locale. Signed-off-by: Alexey Neyman --- scripts/build/libc/uClibc.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'scripts/build/libc/uClibc.sh') diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh index 7903a762..41b651f2 100644 --- a/scripts/build/libc/uClibc.sh +++ b/scripts/build/libc/uClibc.sh @@ -5,7 +5,7 @@ # This is a constant because it does not change very often. # We're in 2010, and are still using data from 7 years ago. uclibc_locales_version=030818 -uclibc_local_tarball="uClibc-locale-${uclibc_locales_version}" +uclibc_locale_tarball="uClibc-locale-${uclibc_locales_version}" if [ "${CT_LIBC_UCLIBC_NG}" = "y" ]; then uclibc_name="uClibc-ng" @@ -26,7 +26,7 @@ do_libc_get() { fi # uClibc locales if [ "${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" = "y" ]; then - CT_GetFile "${uclibc_local_tarball}" ${libc_src} + CT_GetFile "${uclibc_locale_tarball}" ${libc_src} fi return 0 @@ -41,11 +41,11 @@ do_libc_extract() { # Extracting pregen locales ourselves is kinda # broken, so just link it in place... if [ "${CT_LIBC_UCLIBC_LOCALES_PREGEN_DATA}" = "y" \ - -a ! -f "${CT_SRC_DIR}/.${uclibc_local_tarball}.extracted" ]; then + -a ! -f "${CT_SRC_DIR}/.${uclibc_locale_tarball}.extracted" ]; then CT_Pushd "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}/extra/locale" - CT_DoExecLog ALL ln -s "${CT_TARBALLS_DIR}/${uclibc_local_tarball}.tgz" . + CT_DoExecLog ALL ln -s "${CT_TARBALLS_DIR}/${uclibc_locale_tarball}.tgz" . CT_Popd - touch "${CT_SRC_DIR}/.${uclibc_local_tarball}.extracted" + touch "${CT_SRC_DIR}/.${uclibc_locale_tarball}.extracted" fi return 0 @@ -99,7 +99,7 @@ do_libc_start_files() { ${make} CROSS_COMPILE="${CT_TARGET}-" \ UCLIBC_EXTRA_CFLAGS="-pipe" \ PREFIX="${multi_root}/" \ - LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ + LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ oldconfig CT_DoLog EXTRA "Building headers" @@ -108,7 +108,7 @@ do_libc_start_files() { CROSS_COMPILE="${CT_TARGET}-" \ UCLIBC_EXTRA_CFLAGS="-pipe" \ PREFIX="${multi_root}/" \ - LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ + LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ headers CT_DoLog EXTRA "Installing headers" @@ -117,7 +117,7 @@ do_libc_start_files() { CROSS_COMPILE="${CT_TARGET}-" \ UCLIBC_EXTRA_CFLAGS="-pipe" \ PREFIX="${multi_root}/" \ - LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ + LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ install_headers # The check might look bogus, but it is the same condition as is used @@ -131,7 +131,7 @@ do_libc_start_files() { PREFIX="${multi_root}/" \ STRIPTOOL=true \ ${CT_LIBC_UCLIBC_VERBOSITY} \ - LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ + LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ lib/crt1.o lib/crti.o lib/crtn.o # From: http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=ad5668a7ac7e0436db92e55caaf3fdf782b6ba3b @@ -197,7 +197,7 @@ do_libc() { ${make} CROSS_COMPILE=${CT_TARGET}- \ UCLIBC_EXTRA_CFLAGS="-pipe" \ PREFIX="${multi_root}/" \ - LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ + LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ oldconfig # We do _not_ want to strip anything for now, in case we specifically @@ -211,7 +211,7 @@ do_libc() { PREFIX="${multi_root}/" \ STRIPTOOL=true \ ${CT_LIBC_UCLIBC_VERBOSITY} \ - LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ + LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ pregen CT_DoExecLog ALL \ ${make} ${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}} \ @@ -220,7 +220,7 @@ do_libc() { PREFIX="${multi_root}/" \ STRIPTOOL=true \ ${CT_LIBC_UCLIBC_VERBOSITY} \ - LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ + LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ all # YEM-FIXME: @@ -244,7 +244,7 @@ do_libc() { PREFIX="${multi_root}/" \ STRIPTOOL=true \ ${CT_LIBC_UCLIBC_VERBOSITY} \ - LOCALE_DATA_FILENAME="${uclibc_local_tarball}.tgz" \ + LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ MULTILIB_DIR="${multilib_dir}" \ install -- cgit v1.2.3 From 4ee22d66a849123c06812736dd1472840aad5823 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Fri, 1 Apr 2016 23:28:43 -0700 Subject: uclibc: merge startfiles/final into single backend. In preparation for multilib support, use the same "backend" model that is already employed by glibc and musl. Also, the verbosity setting descriptions were swapped. V=2 is actually less verbose than V=1: V=1 prints full commands, while V=2 prints 'CC '. Signed-off-by: Alexey Neyman --- config/libc/uClibc.in | 4 +- scripts/build/libc/uClibc.sh | 269 ++++++++++++++++++------------------------- 2 files changed, 111 insertions(+), 162 deletions(-) (limited to 'scripts/build/libc/uClibc.sh') diff --git a/config/libc/uClibc.in b/config/libc/uClibc.in index 989da7ba..a99ff736 100644 --- a/config/libc/uClibc.in +++ b/config/libc/uClibc.in @@ -129,13 +129,13 @@ config LIBC_UCLIBC_VERBOSITY_0 config LIBC_UCLIBC_VERBOSITY_1 bool - prompt "Brief build (show defines, ld flags)" + prompt "Very verbose build" help Print simplified command lines. config LIBC_UCLIBC_VERBOSITY_2 bool - prompt "Very verbose build" + prompt "Brief build (show defines, ld flags)" help Print full command lines. diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh index 41b651f2..edd82f6a 100644 --- a/scripts/build/libc/uClibc.sh +++ b/scripts/build/libc/uClibc.sh @@ -73,180 +73,129 @@ do_libc_check_config() { # Build and install headers and start files do_libc_start_files() { - local multi_os_dir multi_root startfiles_dir - - CT_DoStep INFO "Installing C library headers" - - # 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-headers" - cd "${CT_BUILD_DIR}/build-libc-headers" - - # Retrieve the config file - CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/uClibc.config" .config - - multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ) - multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ) - startfiles_dir="${multi_root}/usr/lib/${multi_os_dir}" - CT_SanitizeVarDir startfiles_dir - CT_DoExecLog ALL mkdir -p "${startfiles_dir}" - - # Force the date of the pregen locale data, as the - # newer ones that are referenced are not available - CT_DoLog EXTRA "Applying configuration" - CT_DoYes "" |CT_DoExecLog ALL \ - ${make} CROSS_COMPILE="${CT_TARGET}-" \ - UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${multi_root}/" \ - LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ - oldconfig - - CT_DoLog EXTRA "Building headers" - CT_DoExecLog ALL \ - ${make} ${CT_LIBC_UCLIBC_VERBOSITY} \ - CROSS_COMPILE="${CT_TARGET}-" \ - UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${multi_root}/" \ - LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ - headers - - CT_DoLog EXTRA "Installing headers" - CT_DoExecLog ALL \ - ${make} ${CT_LIBC_UCLIBC_VERBOSITY} \ - CROSS_COMPILE="${CT_TARGET}-" \ - UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${multi_root}/" \ - LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ - install_headers - - # The check might look bogus, but it is the same condition as is used - # by GCC build script to enable/disable shared library support. - if [ "${CT_THREADS}" = "nptl" ]; then - CT_DoLog EXTRA "Building start files" - CT_DoExecLog ALL \ - ${make} ${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}} \ - CROSS_COMPILE="${CT_TARGET}-" \ - UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${multi_root}/" \ - STRIPTOOL=true \ - ${CT_LIBC_UCLIBC_VERBOSITY} \ - LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ - lib/crt1.o lib/crti.o lib/crtn.o - - # From: http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=ad5668a7ac7e0436db92e55caaf3fdf782b6ba3b - # libm.so is needed for ppc, as libgcc is linked against libm.so - # 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 - - CT_DoLog EXTRA "Installing start files" - CT_DoExecLog ALL ${install} -m 0644 lib/crt1.o lib/crti.o lib/crtn.o \ - "${startfiles_dir}" - - CT_DoLog EXTRA "Installing dummy shared libs" - CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${startfiles_dir}/libc.so" - CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${startfiles_dir}/libm.so" - fi # CT_THREADS == nptl - - CT_EndStep + # Start files and Headers should be configured the same way as the + # final libc, but built and installed differently. + do_libc_backend libc_mode=startfiles } -# This function build and install the full uClibc +# This function builds and install the full C library do_libc() { + do_libc_backend libc_mode=final +} + +# 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 - CT_DoStep INFO "Installing C library" + for arg in "$@"; do + eval "${arg// /\\ }" + done + + case "${libc_mode}" in + startfiles) CT_DoStep INFO "Installing C library headers & start files";; + final) CT_DoStep INFO "Installing C library";; + *) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";; + esac # 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 -av "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}" \ - "${CT_BUILD_DIR}/build-libc" - cd "${CT_BUILD_DIR}/build-libc" - - # Retrieve the config file - CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/uClibc.config" .config + 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}" multi_os_dir=$( "${CT_TARGET}-gcc" -print-multi-os-directory ) multi_root=$( "${CT_TARGET}-gcc" -print-sysroot ) - startfiles_dir="${multi_root}/usr/lib/${multi_os_dir}" + multilib_dir="lib/${multi_os_dir}" + startfiles_dir="${multi_root}/usr/${multilib_dir}" + CT_SanitizeVarDir multilib_dir startfiles_dir + + # Construct make arguments: + # - uClibc uses the CROSS environment variable as a prefix to the compiler + # tools to use. Since it requires core pass-1, thusly named compiler is + # already available. + # - Note about CFLAGS: In uClibc, CFLAGS are generated by Rules.mak, + # depending on the configuration of the library. That is, they are tailored + # to best fit the target. So it is useless and seems to be a bad thing to + # use LIBC_EXTRA_CFLAGS here. + # - 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" \ + STRIPTOOL=true \ + ${CT_LIBC_UCLIBC_VERBOSITY} \ + ) - CT_DoLog EXTRA "Cleaning up startfiles" - CT_DoExecLog ALL rm -f "${startfiles_dir}/crt1.o" \ - "${startfiles_dir}/crti.o" \ - "${startfiles_dir}/crtn.o" \ - "${startfiles_dir}/libc.so" \ - "${startfiles_dir}/libm.so" + # Retrieve the config file + CT_DoExecLog ALL cp "${CT_CONFIG_DIR}/uClibc.config" .config - multilib_dir="lib/${multi_os_dir}" - CT_SanitizeVarDir multilib_dir - - # uClibc uses the CROSS environment variable as a prefix to the compiler - # tools to use. The newly built tools should be in our path, so we need - # only give the correct name for them. - # Note about CFLAGS: In uClibc, CFLAGS are generated by Rules.mak, - # depending on the configuration of the library. That is, they are tailored - # to best fit the target. So it is useless and seems to be a bad thing to - # use LIBC_EXTRA_CFLAGS here. + # Force the date of the pregen locale data, as the + # newer ones that are referenced are not available CT_DoLog EXTRA "Applying configuration" - CT_DoYes "" |CT_DoExecLog CFG \ - ${make} CROSS_COMPILE=${CT_TARGET}- \ - UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${multi_root}/" \ - LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ - oldconfig - - # We do _not_ want to strip anything for now, in case we specifically - # asked for a debug toolchain, thus the STRIPTOOL= assignment - # /Old/ versions can not build in // - CT_DoLog EXTRA "Building C library" - CT_DoExecLog ALL \ - ${make} -j1 \ - CROSS_COMPILE=${CT_TARGET}- \ - UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${multi_root}/" \ - STRIPTOOL=true \ - ${CT_LIBC_UCLIBC_VERBOSITY} \ - LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ - pregen - CT_DoExecLog ALL \ - ${make} ${CT_LIBC_UCLIBC_PARALLEL:+${JOBSFLAGS}} \ - CROSS_COMPILE=${CT_TARGET}- \ - UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${multi_root}/" \ - STRIPTOOL=true \ - ${CT_LIBC_UCLIBC_VERBOSITY} \ - LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ - all - - # YEM-FIXME: - # - we want to install 'runtime' files, eg. lib*.{a,so*}, crti.o and - # such files, except the headers as they already are installed - # - "make install_dev" installs the headers, the crti.o... and the - # static libs, but not the dynamic libs - # - "make install_runtime" installs the dynamic libs only - # - "make install" calls install_runtime and install_dev - # - so we're left with re-installing the headers... Sigh... - # - # We do _not_ want to strip anything for now, in case we specifically - # asked for a debug toolchain, hence the STRIPTOOL= assignment - # - # Note: JOBSFLAGS is not useful for installation. - # - CT_DoLog EXTRA "Installing C library" - CT_DoExecLog ALL \ - ${make} CROSS_COMPILE=${CT_TARGET}- \ - UCLIBC_EXTRA_CFLAGS="-pipe" \ - PREFIX="${multi_root}/" \ - STRIPTOOL=true \ - ${CT_LIBC_UCLIBC_VERBOSITY} \ - LOCALE_DATA_FILENAME="${uclibc_locale_tarball}.tgz" \ - MULTILIB_DIR="${multilib_dir}" \ - install + CT_DoYes | CT_DoExecLog ALL ${make} "${make_args[@]}" oldconfig + + if [ "${libc_mode}" = "startfiles" ]; then + CT_DoLog EXTRA "Building headers" + CT_DoExecLog ALL ${make} "${make_args[@]}" headers + + # Ensure the directory for installing multilib-specific binaries exists. + CT_DoExecLog ALL mkdir -p "${startfiles_dir}" + + CT_DoLog EXTRA "Installing headers" + CT_DoExecLog ALL ${make} "${make_args[@]}" install_headers + + # The check might look bogus, but it is the same condition as is used + # by GCC build script to enable/disable shared library support. + if [ "${CT_THREADS}" = "nptl" ]; then + CT_DoLog EXTRA "Building start files" + CT_DoExecLog ALL ${make} ${jflag} "${make_args[@]}" \ + lib/crt1.o lib/crti.o lib/crtn.o + + # From: http://git.openembedded.org/cgit.cgi/openembedded/commit/?id=ad5668a7ac7e0436db92e55caaf3fdf782b6ba3b + # libm.so is needed for ppc, as libgcc is linked against libm.so + # 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 + + CT_DoLog EXTRA "Installing start files" + CT_DoExecLog ALL ${install} -m 0644 lib/crt1.o lib/crti.o lib/crtn.o \ + "${startfiles_dir}" + + CT_DoLog EXTRA "Installing dummy shared libs" + CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${startfiles_dir}/libc.so" + CT_DoExecLog ALL ${install} -m 0755 libdummy.so "${startfiles_dir}/libm.so" + fi # CT_THREADS == nptl + fi # libc_mode == startfiles + + if [ "${libc_mode}" = "final" ]; then + CT_DoLog EXTRA "Cleaning up startfiles" + CT_DoExecLog ALL rm -f "${startfiles_dir}/crt1.o" \ + "${startfiles_dir}/crti.o" \ + "${startfiles_dir}/crtn.o" \ + "${startfiles_dir}/libc.so" \ + "${startfiles_dir}/libm.so" + + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL ${make} "${make_args[@]}" pregen + CT_DoExecLog ALL ${make} ${jflag} "${make_args[@]}" all + + # YEM-FIXME: + # - we want to install 'runtime' files, eg. lib*.{a,so*}, crti.o and + # such files, except the headers as they already are installed + # - "make install_dev" installs the headers, the crti.o... and the + # static libs, but not the dynamic libs + # - "make install_runtime" installs the dynamic libs only + # - "make install" calls install_runtime and install_dev + # - so we're left with re-installing the headers... Sigh... + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL ${make} "${make_args[@]}" install + fi # libc_mode == final CT_EndStep } -- cgit v1.2.3 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.sh | 24 ++++++++++++++++++++++++ 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 ++++++++++++++++++++++++ scripts/build/libc/avr-libc.sh | 4 ---- scripts/build/libc/glibc.sh | 29 ++--------------------------- scripts/build/libc/mingw.sh | 4 ---- scripts/build/libc/musl.sh | 4 ---- scripts/build/libc/newlib.sh | 4 ---- scripts/build/libc/none.sh | 4 ---- scripts/build/libc/uClibc.sh | 32 ++++++++------------------------ scripts/crosstool-NG.sh.in | 4 +--- scripts/functions | 2 -- steps.mk | 4 ++-- 21 files changed, 96 insertions(+), 149 deletions(-) create mode 100644 scripts/build/arch.sh (limited to 'scripts/build/libc/uClibc.sh') 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 \ -- 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/libc/uClibc.sh') 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/libc/uClibc.sh') 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 258394c19f7b3fd3700814d7b4de9336bb16e554 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Mon, 11 Apr 2016 23:11:22 -0700 Subject: Treat multiroots differently. 'ld' does not search for dependency libraries in multi_os_directory, so if there's both multi_os_directory and multi_root, and there is only one configuration in each multi_root, forgo the multi_os_directory suffix. Needed for sh4-multilib-linux-uclibc. Signed-off-by: Alexey Neyman --- scripts/build/libc/glibc.sh | 56 ++++++++++++++++++++++++++++++++++++-------- scripts/build/libc/uClibc.sh | 44 ++++++++++++++++++++++++++++------ 2 files changed, 83 insertions(+), 17 deletions(-) (limited to 'scripts/build/libc/uClibc.sh') diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index dc9443c0..8093e08b 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -66,7 +66,8 @@ do_libc_backend() { local libc_mode local -a multilibs local multilib - local multi_dir multi_os_dir multi_flags multi_last + local multi_dir multi_os_dir multi_root multi_flags multi_last + local root_suffix local target local arg @@ -86,18 +87,12 @@ 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) ) - 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 - # GCC makes the distinction between: # multilib (-print-multi-lib or -print-multi-directory) and # multilib-os (--print-multi-os-directory) @@ -114,10 +109,50 @@ do_libc_backend() { # /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}" @@ -127,7 +162,7 @@ do_libc_backend() { # Ensure sysroot (with suffix, if applicable) exists CT_DoExecLog ALL mkdir -p "${multi_root}" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}${multi_dir//\//_}" + CT_mkdir_pushd "multilib_${multi_dir//\//_}" do_libc_backend_once multi_dir="${multi_dir}" \ multi_os_dir="${multi_os_dir}" \ multi_flags="${multi_flags}" \ @@ -141,6 +176,7 @@ do_libc_backend() { done + CT_Popd CT_EndStep } diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh index 822d3817..edde8159 100644 --- a/scripts/build/libc/uClibc.sh +++ b/scripts/build/libc/uClibc.sh @@ -81,6 +81,8 @@ do_libc_backend() { *) CT_Abort "Unsupported (or unset) libc_mode='${libc_mode}'";; 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 @@ -88,6 +90,26 @@ do_libc_backend() { 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}" \ @@ -104,17 +126,23 @@ do_libc_backend() { # 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 + 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 dummy dummy.c ${multi_flags} - ldso=$( ${CT_TARGET}-readelf -Wl dummy | \ + 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.*}" @@ -135,9 +163,9 @@ do_libc_backend() { "${multi_root}${ldso}" fi done - CT_Popd fi + CT_Popd CT_EndStep } @@ -157,9 +185,9 @@ do_libc_backend_once() { # Simply copy files until uClibc has the ability to build out-of-tree CT_DoLog EXTRA "Copying sources to build dir" - build_dir="${CT_BUILD_DIR}/build-libc-${libc_mode}${multi_dir//\//_}" + build_dir="multilib_${multi_dir//\//_}" CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/${uclibc_name}-${CT_LIBC_VERSION}" "${build_dir}" - cd "${build_dir}" + CT_Pushd "${build_dir}" multilib_dir="lib/${multi_os_dir}" startfiles_dir="${multi_root}/usr/${multilib_dir}" @@ -297,6 +325,8 @@ do_libc_backend_once() { 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 + + CT_Popd } # Initialises the .config file to sensible values -- 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/libc/uClibc.sh') 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