From cc6b7fad46f5cb3d84cf87ae47c5f723803a67a3 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 5 Jan 2022 00:37:45 -0800 Subject: Retire obsoleted milestones ... and the code dependent on them, after the latest wave of obsolete package removals. This concludes the glorious history of the original uClibc (non-NG) with lots of kludges removed. There was a choice here, whether to call the resulting libc "uClibc" or "uClibc-ng". I opted in favor of giving uClibc-ng the recognition it deserves, although it had some ripple effect in the ct-ng code. Signed-off-by: Alexey Neyman --- scripts/build/libc/mingw-w64.sh | 16 +- scripts/build/libc/uClibc-ng.sh | 421 ++++++++++++++++++++++++++++++++++++++ scripts/build/libc/uClibc.sh | 437 ---------------------------------------- 3 files changed, 428 insertions(+), 446 deletions(-) create mode 100644 scripts/build/libc/uClibc-ng.sh delete mode 100644 scripts/build/libc/uClibc.sh (limited to 'scripts/build/libc') diff --git a/scripts/build/libc/mingw-w64.sh b/scripts/build/libc/mingw-w64.sh index 683f8be9..60f514af 100644 --- a/scripts/build/libc/mingw-w64.sh +++ b/scripts/build/libc/mingw-w64.sh @@ -56,15 +56,13 @@ mingw_w64_start_files() { do_check_mingw_vendor_tuple() { - if [ "${CT_MINGW_W64_REQUIRES_W64_VENDOR}" = "y" ]; then - CT_DoStep INFO "Checking configured vendor tuple" - if [ ${CT_TARGET_VENDOR} = "w64" ]; then - CT_DoLog DEBUG "The tuple is set to '${CT_TARGET_VENDOR}', as recommended by mingw-64 developers." - else - CT_DoLog WARN "The tuple vendor is '${CT_TARGET_VENDOR}', not equal to 'w64' and might break the toolchain!" - fi - CT_EndStep - fi + CT_DoStep INFO "Checking configured vendor tuple" + if [ ${CT_TARGET_VENDOR} = "w64" ]; then + CT_DoLog DEBUG "The tuple is set to '${CT_TARGET_VENDOR}', as recommended by mingw-64 developers." + else + CT_DoLog WARN "The tuple vendor is '${CT_TARGET_VENDOR}', not equal to 'w64' and might break the toolchain!" + fi + CT_EndStep } do_mingw_tools() diff --git a/scripts/build/libc/uClibc-ng.sh b/scripts/build/libc/uClibc-ng.sh new file mode 100644 index 00000000..16ebc2c9 --- /dev/null +++ b/scripts/build/libc/uClibc-ng.sh @@ -0,0 +1,421 @@ +# This file declares functions to install the uClibc C library +# Copyright 2007 Yann E. MORIN +# Licensed under the GPL v2. See COPYING in the root of this package + +# Build and install headers and start files +uClibc_ng_start_files() +{ + # Start files and Headers should be configured the same way as the + # final libc, but built and installed differently. + uClibc_ng_backend libc_mode=startfiles +} + +# This function builds and install the full C library +uClibc_ng_main() +{ + uClibc_ng_backend libc_mode=final +} + +# Common backend for 1st and 2nd passes. +uClibc_ng_backend() +{ + local libc_mode + local arg + + 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 + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" + CT_IterateMultilibs uClibc_ng_backend_once multilib libc_mode="${libc_mode}" + CT_Popd + CT_EndStep +} + +# Common backend for 1st and 2nd passes, once per multilib. +uClibc_ng_backend_once() +{ + local libc_mode + local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count + local multilib_dir startfiles_dir + local jflag=${CT_JOBSFLAGS} + local -a make_args + local extra_cflags f cfg_cflags cf + local hdr_install_subdir + + for arg in "$@"; do + eval "${arg// /\\ }" + done + + CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'" + + 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}-" \ + HOSTCC="${CT_BUILD}-gcc" \ + PREFIX="${multi_root}/" \ + MULTILIB_DIR="${multilib_dir}" \ + STRIPTOOL=true \ + ${CT_LIBC_UCLIBC_VERBOSITY} \ + ) + + # 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-ng/." . + + # 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}/packages/uClibc-ng/config" + fi + + manage_uClibc_config "${CT_LIBC_UCLIBC_CONFIG_FILE}" .config "${multi_flags}" + CT_DoExecLog ALL make "${make_args[@]}" olddefconfig + + # 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 + + # 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 + + if [ "${CT_SHARED_LIBS}" = "y" ]; then + # 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}-${CT_CC}" -nostdlib -nostartfiles \ + -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 \ + "${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_SHARED_LIBS == y + 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 install_utils + fi # libc_mode == final + + # 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 + + CT_EndStep +} + +# Initialises the .config file to sensible values +# $1: original file +# $2: modified file +manage_uClibc_config() +{ + src="$1" + dst="$2" + flags="$3" + + # Start with fresh files + CT_DoExecLog ALL cp "${src}" "${dst}" + + case "${CT_ARCH_ENDIAN}" in + big|big,little) + CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${dst}" + CT_KconfigDisableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}" + CT_KconfigEnableOption "ARCH_BIG_ENDIAN" "${dst}" + CT_KconfigEnableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}" + ;; + little|little,big) + CT_KconfigDisableOption "ARCH_BIG_ENDIAN" "${dst}" + CT_KconfigDisableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}" + CT_KconfigEnableOption "ARCH_LITTLE_ENDIAN" "${dst}" + CT_KconfigEnableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}" + ;; + esac + + if [ "${CT_ARCH_USE_MMU}" = "y" ]; then + CT_KconfigEnableOption "ARCH_USE_MMU" "${dst}" + else + CT_KconfigDisableOption "ARCH_USE_MMU" "${dst}" + CT_KconfigDisableOption "UCLIBC_FORMAT_FDPIC" "${dst}" + CT_KconfigDisableOption "UCLIBC_FORMAT_FLAT" "${dst}" + CT_KconfigDisableOption "UCLIBC_FORMAT_SHARED_FLAT" "${dst}" + case "${CT_ARCH_BINFMT_FLAT},${CT_ARCH_BINFMT_FDPIC},${CT_SHARED_LIBS}" in + y,,y) CT_KconfigEnableOption "UCLIBC_FORMAT_SHARED_FLAT" "${dst}";; + y,,) CT_KconfigEnableOption "UCLIBC_FORMAT_FLAT" "${dst}";; + ,y,*) CT_KconfigEnableOption "UCLIBC_FORMAT_FDPIC" "${dst}";; + *) CT_Abort "Unsupported binary format";; + esac + fi + + if [ "${CT_SHARED_LIBS}" = "y" ]; then + CT_KconfigEnableOption "HAVE_SHARED" "${dst}" + else + CT_KconfigDisableOption "HAVE_SHARED" "${dst}" + fi + + # Accomodate for old and new uClibc version, where the + # way to select between hard/soft float has changed + case "${CT_ARCH_FLOAT}" in + hard|softfp) + CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${dst}" + CT_KconfigEnableOption "UCLIBC_HAS_FLOATS" "${dst}" + ;; + soft) + CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${dst}" + CT_KconfigEnableOption "UCLIBC_HAS_FLOATS" "${dst}" + CT_KconfigEnableOption "DO_C99_MATH" "${dst}" + ;; + esac + if [ "${CT_LIBC_UCLIBC_FENV}" = "y" ]; then + CT_KconfigEnableOption "UCLIBC_HAS_FENV" "${dst}" + else + CT_KconfigDisableOption "UCLIBC_HAS_FENV" "${dst}" + fi + if [ "${CT_LIBC_UCLIBC_RPC}" = "y" ]; then + CT_KconfigEnableOption "UCLIBC_HAS_RPC" "${dst}" + else + CT_KconfigDisableOption "UCLIBC_HAS_RPC" "${dst}" + fi + + # We always want ctor/dtor + CT_KconfigEnableOption "UCLIBC_CTOR_DTOR" "${dst}" + + # Change paths to work with crosstool-NG + # + # DEVEL_PREFIX is left as '/usr/' because it is post-pended to $PREFIX, + # which is the correct value of ${PREFIX}/${TARGET}. + CT_KconfigSetOption "DEVEL_PREFIX" "\"/usr/\"" "${dst}" + CT_KconfigSetOption "RUNTIME_PREFIX" "\"/\"" "${dst}" + CT_KconfigSetOption "KERNEL_HEADERS" "\"${CT_HEADERS_DIR}\"" "${dst}" + + # Locales support + # Note that the two PREGEN_LOCALE and the XLOCALE lines may be missing + # entirely if LOCALE is not set. If LOCALE was already set, we'll + # assume the user has already made all the appropriate generation + # arrangements. Note that having the uClibc Makefile download the + # pregenerated locales is not compatible with crosstool. + if [ -z "${CT_LIBC_UCLIBC_LOCALES}" ]; then + CT_KconfigDisableOption "UCLIBC_HAS_LOCALE" "${dst}" + else + CT_KconfigEnableOption "UCLIBC_HAS_LOCALE" "${dst}" + CT_KconfigDeleteOption "UCLIBC_PREGENERATED_LOCALE_DATA" "${dst}" + CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA" "${dst}" + fi + + # WCHAR support + if [ "${CT_LIBC_UCLIBC_WCHAR}" = "y" ]; then + CT_KconfigEnableOption "UCLIBC_HAS_WCHAR" "${dst}" + else + CT_KconfigDisableOption "UCLIBC_HAS_WCHAR" "${dst}" + fi + + # IPv6 support + if [ "${CT_LIBC_UCLIBC_IPV6}" = "y" ]; then + CT_KconfigEnableOption "UCLIBC_HAS_IPV6" "${dst}" + else + CT_KconfigDisableOption "UCLIBC_HAS_IPV6" "${dst}" + fi + + # Iconv support + if [ "${CT_LIBC_UCLIBC_LIBICONV}" = "y" ]; then + CT_KconfigEnableOption "UCLIBC_HAS_LIBICONV" "${dst}" + else + CT_KconfigDisableOption "UCLIBC_HAS_LIBICONV" "${dst}" + fi + + # Force on options needed for C++ if we'll be making a C++ compiler. + # I'm not sure locales are a requirement for doing C++... Are they? + if [ "${CT_CC_LANG_CXX}" = "y" ]; then + CT_KconfigEnableOption "DO_C99_MATH" "${dst}" + CT_KconfigEnableOption "UCLIBC_HAS_GNU_GETOPT" "${dst}" + fi + + # Stack Smash Protection (SSP) + if [ "${CT_LIBC_UCLIBC_HAS_SSP}" = "y" ]; then + CT_KconfigEnableOption "UCLIBC_HAS_SSP" "${dst}" + else + CT_KconfigDisableOption "UCLIBC_HAS_SSP" "${dst}" + fi + if [ "${CT_LIBC_UCLIBC_BUILD_SSP}" = "y" ]; then + CT_KconfigEnableOption "UCLIBC_BUILD_SSP" "${dst}" + else + CT_KconfigDisableOption "UCLIBC_BUILD_SSP" "${dst}" + 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}" in + none) + ;; + linuxthreads) + CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" + CT_KconfigEnableOption "UCLIBC_HAS_LINUXTHREADS" "${dst}" + ;; + nptl) + CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" + CT_KconfigEnableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}" + ;; + *) + CT_Abort "Incorrect thread settings: CT_THREADS='${CT_THREADS}'" + ;; + esac + + # Always build the libpthread_db + 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) + ;; + 1) + CT_KconfigEnableOption "DODEBUG" "${dst}" + ;; + 2) + CT_KconfigEnableOption "DODEBUG" "${dst}" + CT_KconfigEnableOption "DOASSERTS" "${dst}" + CT_KconfigEnableOption "SUPPORT_LD_DEBUG" "${dst}" + CT_KconfigEnableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}" + ;; + 3) + CT_KconfigEnableOption "DODEBUG" "${dst}" + CT_KconfigEnableOption "DODEBUG_PT" "${dst}" + CT_KconfigEnableOption "DOASSERTS" "${dst}" + CT_KconfigEnableOption "SUPPORT_LD_DEBUG" "${dst}" + CT_KconfigEnableOption "SUPPORT_LD_DEBUG_EARLY" "${dst}" + 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}" + CT_DoArchUClibcCflags "${dst}" "${flags}" + + # Preserve the config we created (before uclibc's `make olddefconfig` + # overrides anything). + CT_DoExecLog ALL cp "${dst}" "${dst}.created-by-ct-ng" +} + +uClibc_ng_post_cc() +{ + # 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. + # Moreover, need to do this after the final compiler is built: on targets + # that use elf2flt, the core compilers cannot find ld when running elf2flt. + CT_MultilibFixupLDSO + + if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then + CT_InstallConfigurationFile "${CT_LIBC_UCLIBC_CONFIG_FILE}" libc + fi +} diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh deleted file mode 100644 index 43285426..00000000 --- a/scripts/build/libc/uClibc.sh +++ /dev/null @@ -1,437 +0,0 @@ -# This file declares functions to install the uClibc C library -# Copyright 2007 Yann E. MORIN -# Licensed under the GPL v2. See COPYING in the root of this package - -# Build and install headers and start files -uClibc_start_files() -{ - # Start files and Headers should be configured the same way as the - # final libc, but built and installed differently. - uClibc_backend libc_mode=startfiles -} - -# This function builds and install the full C library -uClibc_main() -{ - uClibc_backend libc_mode=final -} - -# Common backend for 1st and 2nd passes. -uClibc_backend() -{ - local libc_mode - local arg - - 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 - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" - CT_IterateMultilibs uClibc_backend_once multilib libc_mode="${libc_mode}" - CT_Popd - CT_EndStep -} - -# Common backend for 1st and 2nd passes, once per multilib. -uClibc_backend_once() -{ - local libc_mode - 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:+${CT_JOBSFLAGS}} - local -a make_args - local extra_cflags f cfg_cflags cf - local hdr_install_subdir - local uClibc_name - - for arg in "$@"; do - eval "${arg// /\\ }" - done - - if [ "${CT_UCLIBC_USE_UCLIBC_NG_ORG}" = "y" ]; then - uClibc_name="uClibc-ng" - elif [ "${CT_UCLIBC_USE_UCLIBC_ORG}" = "y" ]; then - uClibc_name="uClibc" - fi - - CT_DoStep INFO "Building for multilib ${multi_index}/${multi_count}: '${multi_flags}'" - - 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}-" \ - HOSTCC="${CT_BUILD}-gcc" \ - PREFIX="${multi_root}/" \ - MULTILIB_DIR="${multilib_dir}" \ - STRIPTOOL=true \ - ${CT_LIBC_UCLIBC_VERBOSITY} \ - ) - - # 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/." . - - # 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}/packages/${uClibc_name}/config" - fi - - manage_uClibc_config "${CT_LIBC_UCLIBC_CONFIG_FILE}" .config "${multi_flags}" - CT_DoExecLog ALL make "${make_args[@]}" olddefconfig - - # 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 - - # 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 - - if [ "${CT_SHARED_LIBS}" = "y" ]; then - # 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}-${CT_CC}" -nostdlib -nostartfiles \ - -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 \ - "${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_SHARED_LIBS == y - 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 install_utils - fi # libc_mode == final - - # 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 - - CT_EndStep -} - -# Initialises the .config file to sensible values -# $1: original file -# $2: modified file -manage_uClibc_config() -{ - src="$1" - dst="$2" - flags="$3" - - # Start with fresh files - CT_DoExecLog ALL cp "${src}" "${dst}" - - case "${CT_ARCH_ENDIAN}" in - big|big,little) - CT_KconfigDisableOption "ARCH_LITTLE_ENDIAN" "${dst}" - CT_KconfigDisableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}" - CT_KconfigEnableOption "ARCH_BIG_ENDIAN" "${dst}" - CT_KconfigEnableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}" - ;; - little|little,big) - CT_KconfigDisableOption "ARCH_BIG_ENDIAN" "${dst}" - CT_KconfigDisableOption "ARCH_WANTS_BIG_ENDIAN" "${dst}" - CT_KconfigEnableOption "ARCH_LITTLE_ENDIAN" "${dst}" - CT_KconfigEnableOption "ARCH_WANTS_LITTLE_ENDIAN" "${dst}" - ;; - esac - - if [ "${CT_ARCH_USE_MMU}" = "y" ]; then - CT_KconfigEnableOption "ARCH_USE_MMU" "${dst}" - else - CT_KconfigDisableOption "ARCH_USE_MMU" "${dst}" - CT_KconfigDisableOption "UCLIBC_FORMAT_FDPIC" "${dst}" - CT_KconfigDisableOption "UCLIBC_FORMAT_FLAT" "${dst}" - CT_KconfigDisableOption "UCLIBC_FORMAT_SHARED_FLAT" "${dst}" - case "${CT_ARCH_BINFMT_FLAT},${CT_ARCH_BINFMT_FDPIC},${CT_SHARED_LIBS}" in - y,,y) CT_KconfigEnableOption "UCLIBC_FORMAT_SHARED_FLAT" "${dst}";; - y,,) CT_KconfigEnableOption "UCLIBC_FORMAT_FLAT" "${dst}";; - ,y,*) CT_KconfigEnableOption "UCLIBC_FORMAT_FDPIC" "${dst}";; - *) CT_Abort "Unsupported binary format";; - esac - fi - - if [ "${CT_SHARED_LIBS}" = "y" ]; then - CT_KconfigEnableOption "HAVE_SHARED" "${dst}" - else - CT_KconfigDisableOption "HAVE_SHARED" "${dst}" - fi - - # Accomodate for old and new uClibc version, where the - # way to select between hard/soft float has changed - case "${CT_ARCH_FLOAT}" in - hard|softfp) - CT_KconfigEnableOption "UCLIBC_HAS_FPU" "${dst}" - CT_KconfigEnableOption "UCLIBC_HAS_FLOATS" "${dst}" - ;; - soft) - CT_KconfigDisableOption "UCLIBC_HAS_FPU" "${dst}" - CT_KconfigEnableOption "UCLIBC_HAS_FLOATS" "${dst}" - CT_KconfigEnableOption "DO_C99_MATH" "${dst}" - ;; - esac - if [ "${CT_LIBC_UCLIBC_FENV}" = "y" ]; then - CT_KconfigEnableOption "UCLIBC_HAS_FENV" "${dst}" - else - CT_KconfigDisableOption "UCLIBC_HAS_FENV" "${dst}" - fi - if [ "${CT_LIBC_UCLIBC_RPC}" = "y" ]; then - CT_KconfigEnableOption "UCLIBC_HAS_RPC" "${dst}" - else - CT_KconfigDisableOption "UCLIBC_HAS_RPC" "${dst}" - fi - - # We always want ctor/dtor - CT_KconfigEnableOption "UCLIBC_CTOR_DTOR" "${dst}" - - # Change paths to work with crosstool-NG - # - # DEVEL_PREFIX is left as '/usr/' because it is post-pended to $PREFIX, - # which is the correct value of ${PREFIX}/${TARGET}. - CT_KconfigSetOption "DEVEL_PREFIX" "\"/usr/\"" "${dst}" - CT_KconfigSetOption "RUNTIME_PREFIX" "\"/\"" "${dst}" - CT_KconfigSetOption "KERNEL_HEADERS" "\"${CT_HEADERS_DIR}\"" "${dst}" - - # Locales support - # Note that the two PREGEN_LOCALE and the XLOCALE lines may be missing - # entirely if LOCALE is not set. If LOCALE was already set, we'll - # assume the user has already made all the appropriate generation - # arrangements. Note that having the uClibc Makefile download the - # pregenerated locales is not compatible with crosstool. - if [ -z "${CT_LIBC_UCLIBC_LOCALES}" ]; then - CT_KconfigDisableOption "UCLIBC_HAS_LOCALE" "${dst}" - else - CT_KconfigEnableOption "UCLIBC_HAS_LOCALE" "${dst}" - CT_KconfigDeleteOption "UCLIBC_PREGENERATED_LOCALE_DATA" "${dst}" - CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA" "${dst}" - fi - - # WCHAR support - if [ "${CT_LIBC_UCLIBC_WCHAR}" = "y" ]; then - CT_KconfigEnableOption "UCLIBC_HAS_WCHAR" "${dst}" - else - CT_KconfigDisableOption "UCLIBC_HAS_WCHAR" "${dst}" - fi - - # IPv6 support - if [ "${CT_LIBC_UCLIBC_IPV6}" = "y" ]; then - CT_KconfigEnableOption "UCLIBC_HAS_IPV6" "${dst}" - else - CT_KconfigDisableOption "UCLIBC_HAS_IPV6" "${dst}" - fi - - # Iconv support - if [ "${CT_LIBC_UCLIBC_LIBICONV}" = "y" ]; then - CT_KconfigEnableOption "UCLIBC_HAS_LIBICONV" "${dst}" - else - CT_KconfigDisableOption "UCLIBC_HAS_LIBICONV" "${dst}" - fi - - # Force on options needed for C++ if we'll be making a C++ compiler. - # I'm not sure locales are a requirement for doing C++... Are they? - if [ "${CT_CC_LANG_CXX}" = "y" ]; then - CT_KconfigEnableOption "DO_C99_MATH" "${dst}" - CT_KconfigEnableOption "UCLIBC_HAS_GNU_GETOPT" "${dst}" - fi - - # Stack Smash Protection (SSP) - if [ "${CT_LIBC_UCLIBC_HAS_SSP}" = "y" ]; then - CT_KconfigEnableOption "UCLIBC_HAS_SSP" "${dst}" - else - CT_KconfigDisableOption "UCLIBC_HAS_SSP" "${dst}" - fi - if [ "${CT_LIBC_UCLIBC_BUILD_SSP}" = "y" ]; then - CT_KconfigEnableOption "UCLIBC_BUILD_SSP" "${dst}" - else - CT_KconfigDisableOption "UCLIBC_BUILD_SSP" "${dst}" - 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:) - ;; - linuxthreads:) - # Newer version of uClibc-ng, no old/new dichotomy - CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" - CT_KconfigEnableOption "UCLIBC_HAS_LINUXTHREADS" "${dst}" - ;; - linuxthreads:old) - CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" - CT_KconfigEnableOption "LINUXTHREADS_OLD" "${dst}" - ;; - linuxthreads:new) - CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" - CT_KconfigEnableOption "LINUXTHREADS_NEW" "${dst}" - ;; - nptl:) - CT_KconfigEnableOption "UCLIBC_HAS_THREADS" "${dst}" - CT_KconfigEnableOption "UCLIBC_HAS_THREADS_NATIVE" "${dst}" - ;; - *) - CT_Abort "Incorrect thread settings: CT_THREADS='${CT_THREAD}' CT_LIBC_UCLIBC_LNXTHRD='${CT_LIBC_UCLIBC_LNXTHRD}'" - ;; - esac - - # Always build the libpthread_db - 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) - ;; - 1) - CT_KconfigEnableOption "DODEBUG" "${dst}" - ;; - 2) - CT_KconfigEnableOption "DODEBUG" "${dst}" - CT_KconfigEnableOption "DOASSERTS" "${dst}" - CT_KconfigEnableOption "SUPPORT_LD_DEBUG" "${dst}" - CT_KconfigEnableOption "UCLIBC_MALLOC_DEBUGGING" "${dst}" - ;; - 3) - CT_KconfigEnableOption "DODEBUG" "${dst}" - CT_KconfigEnableOption "DODEBUG_PT" "${dst}" - CT_KconfigEnableOption "DOASSERTS" "${dst}" - CT_KconfigEnableOption "SUPPORT_LD_DEBUG" "${dst}" - CT_KconfigEnableOption "SUPPORT_LD_DEBUG_EARLY" "${dst}" - 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}" - CT_DoArchUClibcCflags "${dst}" "${flags}" - - # Preserve the config we created (before uclibc's `make olddefconfig` - # overrides anything). - CT_DoExecLog ALL cp "${dst}" "${dst}.created-by-ct-ng" -} - -uClibc_post_cc() -{ - # 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. - # Moreover, need to do this after the final compiler is built: on targets - # that use elf2flt, the core compilers cannot find ld when running elf2flt. - CT_MultilibFixupLDSO - - if [ -n "${CT_LIBC_UCLIBC_CONFIG_FILE}" ]; then - CT_InstallConfigurationFile "${CT_LIBC_UCLIBC_CONFIG_FILE}" libc - fi -} -- cgit v1.2.3 From 93be629f2b255e348d0139558c5cd346a13787d2 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 8 Feb 2022 15:52:48 -0800 Subject: Fold libc_start_files into libc After 557b9d4, libc_start_files and libc_main steps are performed one after another. It doesn't make sense, especially since some of the libcs (glibc, uClibc-ng) go to great lengths to first install start files in the first step, libc_start_files, only to remove them immediately in the second step, libc_main. Current build steps also break in the xtensa newlib configurations, as it needs to install the custom xtensa headers before building the libgcc and after 557b9d4, the headers are not installed before libgcc is built in pass-1. Therefore, finish what 557b9d4 mentioned but did not do: move header installation into a new step, libc_headers, and combine libc_start_files and libc_main into a single step. This also allows to combine the core pass-1/pass-2 steps, to be done in a subsequent commit. Signed-off-by: Alexey Neyman --- ct-ng.in | 3 +- scripts/build/libc.sh | 6 +- scripts/build/libc/bionic.sh | 2 +- scripts/build/libc/glibc.sh | 201 +++++++--------------------------------- scripts/build/libc/mingw-w64.sh | 2 +- scripts/build/libc/moxiebox.sh | 4 +- scripts/build/libc/musl.sh | 101 ++++++-------------- scripts/build/libc/newlib.sh | 7 +- scripts/build/libc/uClibc-ng.sh | 97 ++----------------- 9 files changed, 84 insertions(+), 339 deletions(-) (limited to 'scripts/build/libc') diff --git a/ct-ng.in b/ct-ng.in index 05ca29d3..e0ec0f86 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -268,6 +268,7 @@ build.%: # but are actual steps for canadian and cross-native. # Please keep the last line with a '\' and keep the following empty line: # it helps when diffing and merging. +# TBD move kernel headers and unify pass_1/pass_2? CT_STEPS := \ companion_tools_for_build \ companion_libs_for_build \ @@ -275,9 +276,9 @@ CT_STEPS := \ companion_tools_for_host \ companion_libs_for_host \ binutils_for_host \ + libc_headers \ cc_core_pass_1 \ kernel_headers \ - libc_start_files \ cc_core_pass_2 \ libc_main \ cc_for_build \ diff --git a/scripts/build/libc.sh b/scripts/build/libc.sh index 0d03bf00..5f5aa6f3 100644 --- a/scripts/build/libc.sh +++ b/scripts/build/libc.sh @@ -6,7 +6,7 @@ # The actual implementation can override just what it needs then. eval "${CT_LIBC//[^A-Za-z0-9]/_}_get() { CT_Fetch \"\${CT_LIBC_${CT_LIBC_CHOICE_KSYM}_PKG_KSYM}\"; }" eval "${CT_LIBC//[^A-Za-z0-9]/_}_extract() { CT_ExtractPatch \"\${CT_LIBC_${CT_LIBC_CHOICE_KSYM}_PKG_KSYM}\"; }" -for _m in start_files main post_cc; do +for _m in headers main post_cc; do eval "${CT_LIBC//[^A-Za-z0-9]/_}_${_m}() { :; }" done @@ -23,9 +23,9 @@ do_libc_extract() eval "${CT_LIBC//[^A-Za-z0-9]/_}_extract" } -do_libc_start_files() +do_libc_headers() { - eval "${CT_LIBC//[^A-Za-z0-9]/_}_start_files" + eval "${CT_LIBC//[^A-Za-z0-9]/_}_headers" } do_libc_main() diff --git a/scripts/build/libc/bionic.sh b/scripts/build/libc/bionic.sh index e122d860..0ffd4d8c 100644 --- a/scripts/build/libc/bionic.sh +++ b/scripts/build/libc/bionic.sh @@ -3,7 +3,7 @@ # Licensed under the GPL v2. See COPYING in the root of this package # Install Unified headers -bionic_start_files() +bionic_headers() { CT_DoStep INFO "Installing C library headers" CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/android-ndk/sysroot/usr" "${CT_SYSROOT_DIR}" diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 0db7c1c0..c78f0698 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -30,48 +30,14 @@ glibc_extract() fi } -# Build and install headers and start files -glibc_start_files() -{ - # Start files and Headers should be configured the same way as the - # final libc, but built and installed differently. - glibc_backend libc_mode=startfiles -} - # This function builds and install the full C library glibc_main() { - glibc_backend libc_mode=final -} - -# This backend builds the C library once for each multilib -# variant the compiler gives us -# Usage: glibc_backend param=value [...] -# Parameter : Definition : Type : Default -# libc_mode : 'startfiles' or 'final' : string : (none) -glibc_backend() -{ - local libc_mode local arg - 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 - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" - CT_IterateMultilibs glibc_backend_once multilib libc_mode="${libc_mode}" + CT_DoStep INFO "Installing C library" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc" + CT_IterateMultilibs glibc_backend_once multilib CT_Popd CT_EndStep } @@ -79,13 +45,14 @@ glibc_backend() # This backend builds the C library once # Usage: glibc_backend_once param=value [...] # Parameter : Definition : Type -# libc_mode : 'startfiles' or 'final' : string : (empty) # multi_* : as defined in CT_IterateMultilibs : (varies) : glibc_backend_once() { + # 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. local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count multi_target local build_cflags build_cppflags build_ldflags - local startfiles_dir local src_dir="${CT_SRC_DIR}/glibc" local -a extra_config local -a extra_make_args @@ -104,29 +71,9 @@ glibc_backend_once() # 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 - # here, though, for the first pass where we install crt*.o and a dummy - # libc.so; we therefore install it to the most specific location of - # //usr/lib/ where it is least likely to clash - # with other multilib variants. We then remove these temporary files at - # the beginning of the libc-final step and allow glibc to install them - # where it thinks is proper. - startfiles_dir="${multi_root}/usr/lib/${multi_os_dir}" - CT_SanitizeVarDir startfiles_dir - - if [ "${libc_mode}" = "final" ]; then - CT_DoLog EXTRA "Cleaning up start files" - CT_DoExecLog ALL rm -f "${startfiles_dir}/crt1.o" \ - "${startfiles_dir}/crti.o" \ - "${startfiles_dir}/crtn.o" \ - "${startfiles_dir}/libc.so" - fi - CT_DoLog EXTRA "Configuring C library" - # Also, if those two are missing, iconv build breaks + # If those two are missing, iconv build breaks extra_config+=( --disable-debug --disable-sanity-checks ) if [ "${CT_GLIBC_ENABLE_OBSOLETE_RPC}" = "y" ]; then @@ -259,7 +206,6 @@ glibc_backend_once() CT_DoLog DEBUG "Configuring with addons : '$(glibc_add_ons_list ,)'" 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 : '${multi_target}'" # CFLAGS are only applied when compiling .c files. .S files are compiled with ASFLAGS, @@ -324,111 +270,34 @@ glibc_backend_once() extra_make_args+=( "BUILD_CPPFLAGS=${build_cppflags}" ) extra_make_args+=( "BUILD_LDFLAGS=${build_ldflags}" ) - if [ "${libc_mode}" = "startfiles" -a ! -r "${multi_root}/.libc_headers_installed" ]; then - CT_DoLog EXTRA "Installing C library headers" - CT_DoExecLog ALL touch "${multi_root}/.libc_headers_installed" - - # use the 'install-headers' makefile target to install the - # headers - CT_DoExecLog ALL make ${CT_JOBSFLAGS} \ - install_root=${multi_root} \ - install-bootstrap-headers=yes \ - "${extra_make_args[@]}" \ - install-headers - - # Two headers -- stubs.h and features.h -- aren't installed by install-headers, - # so do them by hand. We can tolerate an empty stubs.h for the moment. - # See e.g. http://gcc.gnu.org/ml/gcc/2002-01/msg00900.html - mkdir -p "${CT_HEADERS_DIR}/gnu" - CT_DoExecLog ALL touch "${CT_HEADERS_DIR}/gnu/stubs.h" - CT_DoExecLog ALL cp -v "${CT_SRC_DIR}/glibc/include/features.h" \ - "${CT_HEADERS_DIR}/features.h" - - # Building the bootstrap gcc requires either setting inhibit_libc, or - # having a copy of stdio_lim.h... see - # http://sources.redhat.com/ml/libc-alpha/2003-11/msg00045.html - CT_DoExecLog ALL cp -v bits/stdio_lim.h "${CT_HEADERS_DIR}/bits/stdio_lim.h" - - # Following error building gcc-4.0.0's gcj: - # error: bits/syscall.h: No such file or directory - # solved by following copy; see http://sourceware.org/ml/crossgcc/2005-05/msg00168.html - # but it breaks arm, see http://sourceware.org/ml/crossgcc/2006-01/msg00091.html - # Of course, only copy it if it does not already exist - case "${CT_ARCH}" in - arm) ;; - *) if [ -f "${CT_HEADERS_DIR}/bits/syscall.h" ]; then - CT_DoLog ALL "Not over-writing existing bits/syscall.h" - elif [ -f "misc/bits/syscall.h" ]; then - CT_DoExecLog ALL cp -v "misc/bits/syscall.h" \ - "${CT_HEADERS_DIR}/bits/syscall.h" - else - # "Old" glibces do not have the above file, - # but provide this one: - CT_DoExecLog ALL cp -v "misc/syscall-list.h" \ - "${CT_HEADERS_DIR}/bits/syscall.h" - fi - ;; - esac - elif [ "${libc_mode}" = "final" -a -r "${multi_root}/.libc_headers_installed" ]; then - CT_DoExecLog ALL rm -f "${multi_root}/.libc_headers_installed" - fi # installing headers - - if [ "${libc_mode}" = "startfiles" ]; then - if [ "${CT_THREADS}" = "nptl" ]; then - CT_DoLog EXTRA "Installing C library start files" - - # there are a few object files needed to link shared libraries, - # which we build and install by hand - CT_DoExecLog ALL mkdir -p "${startfiles_dir}" - CT_DoExecLog ALL make ${CT_JOBSFLAGS} \ - "${extra_make_args[@]}" \ - csu/subdir_lib - CT_DoExecLog ALL cp csu/crt1.o csu/crti.o csu/crtn.o \ - "${startfiles_dir}" - - # Finally, 'libgcc_s.so' requires a 'libc.so' to link against. - # However, since we will never actually execute its code, - # it doesn't matter what it contains. So, treating '/dev/null' - # as a C source file, we produce a dummy 'libc.so' in one step - CT_DoExecLog ALL "${CT_TARGET}-${CT_CC}" ${multi_flags} \ - -nostdlib \ - -nostartfiles \ - -shared \ - -x c /dev/null \ - -o "${startfiles_dir}/libc.so" - fi # threads == nptl - fi # libc_mode = startfiles - - if [ "${libc_mode}" = "final" ]; then - CT_DoLog EXTRA "Building C library" - CT_DoExecLog ALL make ${CT_JOBSFLAGS} \ - "${extra_make_args[@]}" \ - all - - CT_DoLog EXTRA "Installing C library" - CT_DoExecLog ALL make ${CT_JOBSFLAGS} \ - "${extra_make_args[@]}" \ - install_root="${multi_root}" \ - install - - 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. - CT_DoLog EXTRA "Building and installing the C library manual" - # Omit CT_JOBSFLAGS as GLIBC has problems building the - # manuals in parallel - CT_DoExecLog ALL make pdf html - CT_DoExecLog ALL mkdir -p ${CT_PREFIX_DIR}/share/doc - CT_DoExecLog ALL cp -av manual/*.pdf \ - manual/libc \ - ${CT_PREFIX_DIR}/share/doc - fi - - if [ "${CT_GLIBC_LOCALES}" = "y" -a "${multi_index}" = "${multi_count}" ]; then - glibc_locales - fi - fi # libc_mode = final + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} \ + "${extra_make_args[@]}" \ + all + + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} \ + "${extra_make_args[@]}" \ + install_root="${multi_root}" \ + install + + 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. + CT_DoLog EXTRA "Building and installing the C library manual" + # Omit CT_JOBSFLAGS as GLIBC has problems building the + # manuals in parallel + CT_DoExecLog ALL make pdf html + CT_DoExecLog ALL mkdir -p ${CT_PREFIX_DIR}/share/doc + CT_DoExecLog ALL cp -av manual/*.pdf \ + manual/libc \ + ${CT_PREFIX_DIR}/share/doc + fi + + if [ "${CT_GLIBC_LOCALES}" = "y" -a "${multi_index}" = "${multi_count}" ]; then + glibc_locales + fi CT_EndStep } diff --git a/scripts/build/libc/mingw-w64.sh b/scripts/build/libc/mingw-w64.sh index 60f514af..54e8d07c 100644 --- a/scripts/build/libc/mingw-w64.sh +++ b/scripts/build/libc/mingw-w64.sh @@ -9,7 +9,7 @@ mingw_w64_set_install_prefix() fi } -mingw_w64_start_files() { +mingw_w64_headers() { local -a sdk_opts CT_DoStep INFO "Installing C library headers" diff --git a/scripts/build/libc/moxiebox.sh b/scripts/build/libc/moxiebox.sh index 25ef6e7f..35e2ea4d 100644 --- a/scripts/build/libc/moxiebox.sh +++ b/scripts/build/libc/moxiebox.sh @@ -14,9 +14,9 @@ moxiebox_extract() CT_ExtractPatch MOXIEBOX } -moxiebox_start_files() +moxiebox_headers() { - newlib_start_files + newlib_headers } moxiebox_main() diff --git a/scripts/build/libc/musl.sh b/scripts/build/libc/musl.sh index 05da1d40..bc2a2e64 100644 --- a/scripts/build/libc/musl.sh +++ b/scripts/build/libc/musl.sh @@ -2,42 +2,18 @@ # Copyright 2013 Timo Teräs # Licensed under the GPL v2. See COPYING in the root of this package -# Build and install headers and start files -musl_start_files() +musl_post_cc() { - # Start files and Headers should be configured the same way as the - # final libc, but built and installed differently. - musl_backend libc_mode=startfiles -} - -# This function builds and install the full C library -musl_main() -{ - musl_backend libc_mode=final -} - -musl_post_cc() { # MUSL creates dynamic linker symlink with absolute path - which works on the # target but not on the host. We want our cross-ldd tool to work. CT_MultilibFixupLDSO } -musl_backend() { - local libc_mode - local arg - - 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 - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" - CT_IterateMultilibs musl_backend_once multilib libc_mode="${libc_mode}" +musl_main() +{ + CT_DoStep INFO "Installing C library" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc" + CT_IterateMultilibs musl_backend_once multilib CT_Popd CT_EndStep } @@ -45,9 +21,9 @@ musl_backend() { # This backend builds the C library # Usage: musl_backend param=value [...] # Parameter : Definition : Type : Default -# libc_mode : 'startfiles' or 'final' : string : (none) -musl_backend_once() { - local libc_mode +# multi_* : as defined in CT_IterateMultilibs : (varies) : +musl_backend_once() +{ local -a extra_cflags local -a extra_config local src_dir="${CT_SRC_DIR}/musl" @@ -110,45 +86,26 @@ musl_backend_once() { --disable-gcc-wrapper \ "${extra_config[@]}" - if [ "${libc_mode}" = "startfiles" ]; then - CT_DoLog EXTRA "Installing C library headers" - CT_DoExecLog ALL make DESTDIR="${multi_root}" install-headers - CT_DoLog EXTRA "Building C library start files" - CT_DoExecLog ALL make DESTDIR="${multi_root}" \ - obj/crt/crt1.o obj/crt/crti.o obj/crt/crtn.o - CT_DoLog EXTRA "Installing C library start files" - CT_DoExecLog ALL cp -av obj/crt/crt*.o "${multi_root}${multilib_dir}" - CT_DoExecLog ALL ${CT_TARGET}-${CT_CC} -nostdlib \ - -nostartfiles -shared -x c /dev/null -o "${multi_root}${multilib_dir}/libc.so" - fi - if [ "${libc_mode}" = "final" ]; then - CT_DoLog EXTRA "Cleaning up start files" - CT_DoExecLog ALL rm -f "${multi_root}${multilib_dir}/crt1.o" \ - "${multi_root}${multilib_dir}/crti.o" \ - "${multi_root}${multilib_dir}/crtn.o" \ - "${multi_root}${multilib_dir}/libc.so" - - CT_DoLog EXTRA "Building C library" - CT_DoExecLog ALL make ${CT_JOBSFLAGS} - - CT_DoLog EXTRA "Installing C library" - CT_DoExecLog ALL make DESTDIR="${multi_root}" install - - # Convert /lib/ld-* symlinks to relative paths so that they are valid - # both on the host and on the target. - for f in ${multi_root}/ld-musl-*; do - [ -L "${f}" ] || continue - l=$( readlink ${f} ) - case "${l}" in - ${multilib_dir}/*) - CT_DoExecLog ALL ln -sf "../${l}" "${f}" - ;; - esac - done - - # Any additional actions for this architecture - CT_DoArchMUSLPostInstall - fi + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} + + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL make DESTDIR="${multi_root}" install + + # Convert /lib/ld-* symlinks to relative paths so that they are valid + # both on the host and on the target. + for f in ${multi_root}/ld-musl-*; do + [ -L "${f}" ] || continue + l=$( readlink ${f} ) + case "${l}" in + ${multilib_dir}/*) + CT_DoExecLog ALL ln -sf "../${l}" "${f}" + ;; + esac + done + + # Any additional actions for this architecture + CT_DoArchMUSLPostInstall CT_EndStep } diff --git a/scripts/build/libc/newlib.sh b/scripts/build/libc/newlib.sh index ddecdb19..72111a93 100644 --- a/scripts/build/libc/newlib.sh +++ b/scripts/build/libc/newlib.sh @@ -5,11 +5,10 @@ # Edited by Martin Lund # -newlib_start_files() +newlib_headers() { - CT_DoStep INFO "Installing C library headers & start files" - CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib/newlib/libc/include/." \ - "${CT_HEADERS_DIR}" + CT_DoStep INFO "Installing C library headers" + CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/newlib/newlib/libc/include/." "${CT_HEADERS_DIR}" if [ "${CT_ARCH_XTENSA}" = "y" ]; then CT_DoLog EXTRA "Installing Xtensa headers" CT_DoExecLog ALL cp -r "${CT_SRC_DIR}/newlib/newlib/libc/sys/xtensa/include/." \ diff --git a/scripts/build/libc/uClibc-ng.sh b/scripts/build/libc/uClibc-ng.sh index 16ebc2c9..5b260495 100644 --- a/scripts/build/libc/uClibc-ng.sh +++ b/scripts/build/libc/uClibc-ng.sh @@ -2,38 +2,12 @@ # Copyright 2007 Yann E. MORIN # Licensed under the GPL v2. See COPYING in the root of this package -# Build and install headers and start files -uClibc_ng_start_files() -{ - # Start files and Headers should be configured the same way as the - # final libc, but built and installed differently. - uClibc_ng_backend libc_mode=startfiles -} - # This function builds and install the full C library uClibc_ng_main() { - uClibc_ng_backend libc_mode=final -} - -# Common backend for 1st and 2nd passes. -uClibc_ng_backend() -{ - local libc_mode - local arg - - 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 - - CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc-${libc_mode}" - CT_IterateMultilibs uClibc_ng_backend_once multilib libc_mode="${libc_mode}" + CT_DoStep INFO "Installing C library" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc" + CT_IterateMultilibs uClibc_ng_backend_once multilib CT_Popd CT_EndStep } @@ -41,7 +15,6 @@ uClibc_ng_backend() # Common backend for 1st and 2nd passes, once per multilib. uClibc_ng_backend_once() { - local libc_mode local multi_dir multi_os_dir multi_root multi_flags multi_index multi_count local multilib_dir startfiles_dir local jflag=${CT_JOBSFLAGS} @@ -129,65 +102,11 @@ uClibc_ng_backend_once() 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 - - # 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 - - if [ "${CT_SHARED_LIBS}" = "y" ]; then - # 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}-${CT_CC}" -nostdlib -nostartfiles \ - -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 \ - "${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_SHARED_LIBS == y - 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 install_utils - fi # libc_mode == final + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL make "${make_args[@]}" pregen + CT_DoExecLog ALL make ${jflag} "${make_args[@]}" all + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL make "${make_args[@]}" install install_utils # Now, if installing headers into a subdirectory, put everything in its place. # Remove the header subdirectory if it existed already. -- cgit v1.2.3 From 5a0be8b4ec0f1b7ff4fe30c8caaa5285b4f11ae4 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Tue, 8 Feb 2022 17:25:12 -0800 Subject: Unify core passes With libc_headers step before pass-1, there is no need to distinguish pass-1 and pass-2; they are configured identically (note that with the current configuration, core pass-2 is only used for win32 - hence, uses build_libgcc=yes and mode=static). Signed-off-by: Alexey Neyman --- TODO | 2 +- config/cc.in | 5 +-- config/cc/gcc.in | 2 +- config/libc/glibc.in | 2 +- config/libc/mingw-w64.in | 2 +- config/libc/moxiebox.in | 2 +- config/libc/musl.in | 2 +- config/libc/newlib.in | 2 +- config/libc/uClibc-ng.in | 2 +- ct-ng.in | 4 +- scripts/build/cc/gcc.sh | 85 ++++++++--------------------------------- scripts/build/libc/uClibc-ng.sh | 2 +- 12 files changed, 26 insertions(+), 86 deletions(-) (limited to 'scripts/build/libc') diff --git a/TODO b/TODO index 52d0637e..d030a9c3 100644 --- a/TODO +++ b/TODO @@ -75,7 +75,7 @@ A (slightly) ordered set of tasks for crosstool-NG. Written in a cryptic languag [ ] add passthrough to configure, for host/target [ ] Read/spellcheck configs & scripts [ ] 'ct-ng olddefconfig' -[ ] Install a "trap" C++ compiler as ${CT_TARGET}-g++ during pass-1/pass-2 to trap attempts to compile target code with g++ (currently glibc detects host g++ and warns that it uses g++ w/o target triplet) +[ ] Install a "trap" C++ compiler as ${CT_TARGET}-g++ during core compiler build to trap attempts to compile target code with g++ (currently glibc detects host g++ and warns that it uses g++ w/o target triplet) [ ] Somehow it needs to be functional during the configure step - export env var while running in CT_DoExecLog with CFG level, and forward it to host compiler? [ ] elf2flt not compatible with multiple linkers enabled in binutils (ld.bfd + ld.gold) - fix upstream? [ ] Companion libs diff --git a/config/cc.in b/config/cc.in index 0890cc20..3a168055 100644 --- a/config/cc.in +++ b/config/cc.in @@ -2,10 +2,7 @@ menu "C compiler" -config CC_CORE_PASS_1_NEEDED - bool - -config CC_CORE_PASS_2_NEEDED +config CC_CORE_NEEDED bool config CC_SUPPORT_CXX diff --git a/config/cc/gcc.in b/config/cc/gcc.in index 742d563f..a708bb82 100644 --- a/config/cc/gcc.in +++ b/config/cc/gcc.in @@ -55,7 +55,7 @@ config CC_GCC_ENABLE_CXX_FLAGS config CC_GCC_CORE_EXTRA_CONFIG_ARRAY string "Core gcc extra config" default "" - depends on CC_CORE_PASS_1_NEEDED || CC_CORE_PASS_2_NEEDED + depends on CC_CORE_NEEDED help Extra flags to pass onto ./configure when configuring the core gcc. diff --git a/config/libc/glibc.in b/config/libc/glibc.in index 39c2c20b..3da38bdb 100644 --- a/config/libc/glibc.in +++ b/config/libc/glibc.in @@ -3,7 +3,7 @@ ## depends on ! WINDOWS && ! BARE_METAL && ARCH_USE_MMU ## select LIBC_SUPPORT_THREADS_NATIVE -## select CC_CORE_PASS_1_NEEDED +## select CC_CORE_NEEDED # TBD: select GETTEXT for build only, not for host ## select GETTEXT_NEEDED ## select BINUTILS_FORCE_LD_BFD_DEFAULT diff --git a/config/libc/mingw-w64.in b/config/libc/mingw-w64.in index 1880f082..2531fef7 100644 --- a/config/libc/mingw-w64.in +++ b/config/libc/mingw-w64.in @@ -4,7 +4,7 @@ ## ## select LIBC_SUPPORT_THREADS_NATIVE ## select LIBC_SUPPORT_THREADS_POSIX -## select CC_CORE_PASS_2_NEEDED +## select CC_CORE_NEEDED ## select BINUTILS_FORCE_LD_BFD_DEFAULT ## ## help The de-facto standard for Mingw distributions. diff --git a/config/libc/moxiebox.in b/config/libc/moxiebox.in index aa6ff534..07fc3335 100644 --- a/config/libc/moxiebox.in +++ b/config/libc/moxiebox.in @@ -10,7 +10,7 @@ ## select LIBC_SUPPORT_THREADS_NONE ## select COMP_TOOLS_AUTOCONF if !CONFIGURE_has_autoconf_2_65_or_newer || !CONFIGURE_has_autoreconf_2_64_or_newer ## select COMP_TOOLS_AUTOMAKE if !CONFIGURE_has_automake_1_15_or_newer -## select CC_CORE_PASS_1_NEEDED +## select CC_CORE_NEEDED ## select LIBELF_NEEDED ## ## help Secure execution runtime for Moxie architecture. diff --git a/config/libc/musl.in b/config/libc/musl.in index 0ea388e4..db7abb7a 100644 --- a/config/libc/musl.in +++ b/config/libc/musl.in @@ -3,7 +3,7 @@ ## depends on ! WINDOWS && ! BARE_METAL ## depends on EXPERIMENTAL ## select LIBC_SUPPORT_THREADS_NATIVE -## select CC_CORE_PASS_1_NEEDED +## select CC_CORE_NEEDED ## help Musl is a new standard library to power a new generation of Linux-based ## help devices. musl is lightweight, fast, simple, free, and strives to be diff --git a/config/libc/newlib.in b/config/libc/newlib.in index 83ae4b15..f1cb29be 100644 --- a/config/libc/newlib.in +++ b/config/libc/newlib.in @@ -3,7 +3,7 @@ ## depends on BARE_METAL ## select LIBC_PROVIDES_CXA_ATEXIT ## select LIBC_SUPPORT_THREADS_NONE -## select CC_CORE_PASS_1_NEEDED +## select CC_CORE_NEEDED ## help Newlib is a C library intended for use on embedded systems. It is a ## help conglomeration of several library parts, all under free software diff --git a/config/libc/uClibc-ng.in b/config/libc/uClibc-ng.in index 705c0d46..dc83ca7e 100644 --- a/config/libc/uClibc-ng.in +++ b/config/libc/uClibc-ng.in @@ -5,7 +5,7 @@ ## select LIBC_SUPPORT_THREADS_LT ## select LIBC_SUPPORT_THREADS_NONE ## select LIBC_SUPPORT_THREADS_NATIVE -## select CC_CORE_PASS_1_NEEDED +## select CC_CORE_NEEDED ## ## help The de-facto standard for embeded linux systems. ## help diff --git a/ct-ng.in b/ct-ng.in index e0ec0f86..75e09ac5 100644 --- a/ct-ng.in +++ b/ct-ng.in @@ -268,7 +268,6 @@ build.%: # but are actual steps for canadian and cross-native. # Please keep the last line with a '\' and keep the following empty line: # it helps when diffing and merging. -# TBD move kernel headers and unify pass_1/pass_2? CT_STEPS := \ companion_tools_for_build \ companion_libs_for_build \ @@ -277,9 +276,8 @@ CT_STEPS := \ companion_libs_for_host \ binutils_for_host \ libc_headers \ - cc_core_pass_1 \ kernel_headers \ - cc_core_pass_2 \ + cc_core \ libc_main \ cc_for_build \ cc_for_host \ diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh index ab66f413..9623d6ca 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -134,7 +134,7 @@ evaluate_multilib_cflags() # 1. On MIPS target, gcc (or rather, ld, which it invokes under the hood) chokes # if supplied with two -mabi=* options. I.e., 'gcc -mabi=n32' and 'gcc -mabi=32' both # work, but 'gcc -mabi=32 -mabi=n32' produces an internal error in ld. Thus we do -# not supply target's CFLAGS in multilib builds - and after compiling pass-1 gcc, +# not supply target's CFLAGS in multilib builds - and after compiling core gcc, # attempt to determine which CFLAGS need to be filtered out. # # 2. If "demultilibing" is in effect, create top-level directories for any @@ -186,11 +186,10 @@ cc_gcc_multilib_housekeeping() { } #------------------------------------------------------------------------------ -# Core gcc pass 1 -do_cc_core_pass_1() { +do_cc_core() { local -a core_opts - if [ "${CT_CC_CORE_PASS_1_NEEDED}" != "y" ]; then + if [ "${CT_CC_CORE_NEEDED}" != "y" ]; then return 0 fi @@ -201,62 +200,12 @@ do_cc_core_pass_1() { core_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" ) core_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" ) core_opts+=( "lang_list=c" ) - core_opts+=( "build_step=core1" ) + core_opts+=( "build_step=core" ) core_opts+=( "mode=static" ) core_opts+=( "build_libgcc=yes" ) - CT_DoStep INFO "Installing pass-1 core C gcc compiler" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-1" - - do_gcc_core_backend "${core_opts[@]}" - - CT_Popd - CT_EndStep -} - -# Core gcc pass 2 -do_cc_core_pass_2() { - local -a core_opts - - if [ "${CT_CC_CORE_PASS_2_NEEDED}" != "y" ]; then - return 0 - fi - - # Common options: - core_opts+=( "host=${CT_BUILD}" ) - core_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" ) - core_opts+=( "complibs=${CT_BUILDTOOLS_PREFIX_DIR}" ) - core_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" ) - core_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" ) - core_opts+=( "lang_list=c" ) - core_opts+=( "build_step=core2" ) - - # Different conditions are at stake here: - # - In case the threading model is NPTL, we need a shared-capable core - # gcc; in all other cases, we need a static-only core gcc. - # - In case the threading model is NPTL or win32, or gcc is 4.3 or - # later, we need to build libgcc - case "${CT_THREADS}" in - nptl) - if [ "${CT_SHARED_LIBS}" = "y" ]; then - core_opts+=( "mode=shared" ) - else - core_opts+=( "mode=static" ) - fi - core_opts+=( "build_libgcc=yes" ) - ;; - win32) - core_opts+=( "mode=static" ) - core_opts+=( "build_libgcc=yes" ) - ;; - *) - core_opts+=( "mode=static" ) - core_opts+=( "build_libgcc=yes" ) - ;; - esac - - CT_DoStep INFO "Installing pass-2 core C gcc compiler" - CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core-pass-2" + CT_DoStep INFO "Installing core C gcc compiler" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-cc-gcc-core" do_gcc_core_backend "${core_opts[@]}" @@ -281,9 +230,8 @@ do_cc_core_pass_2() { # build_manuals : whether to build manuals or not : bool : no # cflags : cflags to use : string : (empty) # ldflags : ldflags to use : string : (empty) -# build_step : build step 'core1', 'core2', 'gcc_build', -# 'libstdcxx' -# or 'gcc_host' : string : (none) +# build_step : build step 'core', 'gcc_build', +# 'libstdcxx' or 'gcc_host' : string : (none) # Usage: do_gcc_core_backend mode=[static|shared|baremetal] build_libgcc=[yes|no] build_staticlinked=[yes|no] do_gcc_core_backend() { local mode @@ -321,7 +269,7 @@ do_gcc_core_backend() { # This function gets called in case of a bare metal compiler for the final gcc, too. case "${build_step}" in - core1|core2) + core) CT_DoLog EXTRA "Configuring core C gcc compiler" log_txt="gcc" extra_config+=( "${CT_CC_CORE_SYSROOT_ARG[@]}" ) @@ -351,7 +299,7 @@ do_gcc_core_backend() { build_libgcc=no ;; *) - CT_Abort "Internal Error: 'build_step' must be one of: 'core1', 'core2', 'gcc_build', 'gcc_host' or 'libstdcxx', not '${build_step:-(empty)}'" + CT_Abort "Internal Error: 'build_step' must be one of: 'core', 'gcc_build', 'gcc_host' or 'libstdcxx', not '${build_step:-(empty)}'" ;; esac @@ -501,8 +449,6 @@ do_gcc_core_backend() { if [ "${CT_LIBC_GLIBC}" = "y" ]; then # Report GLIBC's version to GCC, it affects the defaults on other options. - # Pass-2 should be able to get it from the headers, but for some options - # (such as --with-long-double-128) we need to get it right even in pass-1. # GCC expects just two numbers separated by a dot. local glibc_version @@ -571,11 +517,10 @@ do_gcc_core_backend() { # Some versions of gcc have a defective --enable-multilib. # Since that's the default, only pass --disable-multilib. For multilib, - # also enable multiarch. Without explicit --enable-multiarch, pass-1 - # compiler is configured as multilib/no-multiarch and pass-2/final - # are multilib/multiarch (because gcc autodetects multiarch based on - # multiple instances of crt*.o in the install directory - which do - # not exist in pass-1). + # also enable multiarch. Without explicit --enable-multiarch, core + # compiler is configured as multilib/no-multiarch (because gcc autodetects + # multiarch based on multiple instances of crt*.o in the install directory + # which do not exist in the core pass). if [ "${CT_MULTILIB}" != "y" ]; then extra_config+=("--disable-multilib") else @@ -609,7 +554,7 @@ do_gcc_core_backend() { fi # For non-sysrooted toolchain, GCC doesn't search except at the installation - # prefix; in core-1/2 stage we use a temporary installation prefix - but + # prefix; in core stage we use a temporary installation prefix - but # we may have installed something into the final prefix. This is less than ideal: # in the installation prefix GCC also handles subdirectories for multilibs # (e.g. first trying ${prefix}/include/${arch-triplet}) but diff --git a/scripts/build/libc/uClibc-ng.sh b/scripts/build/libc/uClibc-ng.sh index 5b260495..7b81d92c 100644 --- a/scripts/build/libc/uClibc-ng.sh +++ b/scripts/build/libc/uClibc-ng.sh @@ -34,7 +34,7 @@ uClibc_ng_backend_once() # 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 + # tools to use. Since it requires core compiler, 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 -- cgit v1.2.3