diff options
Diffstat (limited to 'scripts')
29 files changed, 616 insertions, 203 deletions
diff --git a/scripts/build/arch/lm32.sh b/scripts/build/arch/lm32.sh new file mode 100644 index 00000000..77e7c2cb --- /dev/null +++ b/scripts/build/arch/lm32.sh @@ -0,0 +1,6 @@ +# Compute LM32-specific values + +CT_DoArchTupleValues() { + # Do nothing here. Default values are sane. + :; +} diff --git a/scripts/build/arch/openrisc.sh b/scripts/build/arch/openrisc.sh new file mode 100644 index 00000000..7b467540 --- /dev/null +++ b/scripts/build/arch/openrisc.sh @@ -0,0 +1,6 @@ +# Compute OpenRISC-specific values + +CT_DoArchTupleValues() { + CT_TARGET_ARCH="or1k" + :; +} diff --git a/scripts/build/arch/parisc.sh b/scripts/build/arch/parisc.sh new file mode 100644 index 00000000..fce59c31 --- /dev/null +++ b/scripts/build/arch/parisc.sh @@ -0,0 +1,14 @@ +# Compute parisc-specific values + +CT_DoArchTupleValues() +{ + # The architecture part of the tuple: + CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX}" +} + +CT_DoArchUClibcConfig() +{ + local cfg="${1}" + + CT_DoArchUClibcSelectArch "${cfg}" "parisc" +} diff --git a/scripts/build/arch/rx.sh b/scripts/build/arch/rx.sh new file mode 100644 index 00000000..88bdb5f4 --- /dev/null +++ b/scripts/build/arch/rx.sh @@ -0,0 +1,5 @@ +# Compute RX values + +CT_DoArchTupleValues() { + :; +} diff --git a/scripts/build/arch/sh.sh b/scripts/build/arch/sh.sh index 8339b940..6fe2e9e5 100644 --- a/scripts/build/arch/sh.sh +++ b/scripts/build/arch/sh.sh @@ -5,7 +5,7 @@ CT_DoArchTupleValues () { # like 'sheb-unknown-elf' even though GCC does. So keep the tuple just sh-*-elf # unless user wants something specific (either CPU or explicit suffix). if [ "${CT_ARCH_SH_VARIANT}" != "sh" -o -n "${CT_ARCH_SUFFIX}" ]; then - CT_TARGET_ARCH="${CT_ARCH_SH_VARIANT}${CT_ARCH_SUFFIX:-${target_endian_eb}}" + CT_TARGET_ARCH="${CT_ARCH_SH_VARIANT}${CT_ARCH_SUFFIX:-${CT_ARCH_SH_FLOAT_SUFFIX}${target_endian_eb}}" fi # Endianness stuff (uses non-standard CFLAGS). If both are compiled, let the @@ -17,20 +17,9 @@ CT_DoArchTupleValues () { # Instead of -m{soft,hard}-float, uses CPU type CT_ARCH_FLOAT_CFLAG= - case "${CT_ARCH_SH_VARIANT}" in - sh3) CT_ARCH_ARCH_CFLAG=-m3;; - sh4*|sh2*) - # softfp is not possible for SuperH, no need to test for it. - case "${CT_ARCH_FLOAT}" in - hard) - CT_ARCH_ARCH_CFLAG="-m${CT_ARCH_SH_VARIANT##sh}" - ;; - soft) - CT_ARCH_ARCH_CFLAG="-m${CT_ARCH_SH_VARIANT##sh}-nofpu" - ;; - esac - ;; - esac + if [ "${CT_ARCH_SH_VARIANT}" != "sh" ]; then + CT_ARCH_ARCH_CFLAG=-m${CT_ARCH_SH_VARIANT#sh}-${CT_ARCH_SH_FLOAT_SUFFIX#_} + fi } CT_DoArchMultilibList() { @@ -47,11 +36,11 @@ CT_DoArchMultilibList() { # the default CPU configured with --with-cpu (CT_ARCH_CPU). IFS=, for x in ${CT_CC_GCC_MULTILIB_LIST}; do - if [ "${x}" = "${CT_ARCH_SH_VARIANT}" -o "sh${x#m}" = "${CT_ARCH_SH_VARIANT}" ]; then + if [ "${x}" = "${CT_ARCH_ARCH_CFLAG#-}" -o "sh${x#m}" = "${CT_ARCH_ARCH_CFLAG#-}" ]; then CT_DoLog WARN "Ignoring '${x}' in multilib list: it is the default multilib" continue fi - if [ "${x}" = "${CT_ARCH_CPU}" -o "sh${x#m}" = "${CT_ARCH_CPU}" ]; then + if [ "${x}" = "${CT_ARCH_CPU}" -o "sh${x#m}" = "${CT_ARCH_CPU}" -o "m${x#sh}" = "${CT_ARCH_CPU}" ]; then CT_DoLog WARN "Ignoring '${x}' in multilib list: it is the default multilib" continue fi @@ -74,10 +63,7 @@ CT_DoArchMultilibTarget () for m in "${multi_flags[@]}"; do case "${m}" in - -m4*) newcpu=sh4;; - -m3*) newcpu=sh3;; - -m2*) newcpu=sh2;; - -m1*) newcpu=sh1;; + -m[12345]*) newcpu=sh${m#-m}; newcpu=${newcpu/_/-}; newcpu=${newcpu/_/-};; esac done @@ -96,6 +82,7 @@ CT_DoArchMultilibTarget () CT_DoArchGlibcAdjustTuple() { local target_var="${1}" local target_ + local newtarget eval target_=\"\${${target_var}}\" @@ -106,7 +93,10 @@ CT_DoArchGlibcAdjustTuple() { # specified, so the only source of default is CT_ARCH_CPU. # GCC defaults to sh1, but this Glibc cannot compile for it. if [ -n "${CT_ARCH_CPU}" ]; then - target_=${target_/#sh-/${CT_ARCH_CPU}-} + newtarget=${CT_ARCH_CPU/#m/sh} + newtarget=${newtarget/-/_} + newtarget=${newtarget/-/_} + target_="${newtarget}-${target_#*-}" CT_DoLog DEBUG "Adjusted target tuple ${target_}" else CT_Abort "GNU C library cannot build for sh1 (GCC default). " \ @@ -142,10 +132,10 @@ CT_DoArchGlibcAdjustConfigure() { # and it would've been handled above. Our last resort: CT_ARCH_CPU if [ "${#add_args[@]}" = 0 ]; then case "${CT_ARCH_CPU}" in - sh[34]*-nofpu) + sh[24]a-nofpu | m[24]a-nofpu | sh4-nofpu | m4-nofpu) add_args+=( "--without-fp" ) ;; - sh[34]*) + *) add_args+=( "--with-fp" ) ;; esac diff --git a/scripts/build/arch/tricore.sh b/scripts/build/arch/tricore.sh new file mode 100644 index 00000000..1051b56f --- /dev/null +++ b/scripts/build/arch/tricore.sh @@ -0,0 +1,9 @@ +# Compute tricore-specific values + +CT_DoArchTupleValues() +{ + # The architecture part of the tuple: + CT_TARGET_ARCH="${CT_ARCH}${CT_ARCH_SUFFIX}" + CT_ARCH_ENDIAN_CFLAG="" + CT_ARCH_ENDIAN_LDFLAG="" +} diff --git a/scripts/build/binutils/binutils.sh b/scripts/build/binutils/binutils.sh index eff19c46..6ae2f7cb 100644 --- a/scripts/build/binutils/binutils.sh +++ b/scripts/build/binutils/binutils.sh @@ -182,9 +182,15 @@ do_binutils_backend() { extra_config+=("--without-zstd") fi - # Disable usage of glob for higher compatibility. - # Not strictly needed for anything but GDB anyways. - export ac_cv_func_glob=no + # gold links with CXXLINK/g++, not libtool, and does not understand + # -all-static + if [ "${static_build}" = "y" ]; then + case "${CT_BINUTILS_LINKERS_LIST}" in + *gold*) + extra_config+=("--with-gold-ldflags=--static") + ;; + esac + fi CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" @@ -215,6 +221,13 @@ do_binutils_backend() { fi CT_DoLog EXTRA "Building binutils" + if [ "${static_build}" = "y" ]; then + case "${CT_BINUTILS_LINKERS_LIST}" in + *gold*) + CT_DoExecLog ALL make -C gold ${CT_JOBSFLAGS} + ;; + esac + fi CT_DoExecLog ALL make "${extra_make_flags[@]}" ${CT_JOBSFLAGS} CT_DoLog EXTRA "Installing binutils" @@ -295,7 +308,7 @@ do_elf2flt_backend() { --prefix=${prefix} \ --with-bfd-include-dir=${binutils_bld}/bfd \ --with-binutils-include-dir=${binutils_src}/include \ - --with-libbfd=${binutils_bld}/bfd/libbfd.a \ + --with-libbfd=${binutils_bld}/bfd/.libs/libbfd.a \ --with-libiberty=${binutils_bld}/libiberty/libiberty.a \ --disable-werror \ ${elf2flt_opts} \ diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh index 275e239c..57f5f222 100644 --- a/scripts/build/cc/gcc.sh +++ b/scripts/build/cc/gcc.sh @@ -43,7 +43,7 @@ cc_gcc_lang_list() { [ "${CT_CC_LANG_CXX}" = "y" ] && lang_list+=",c++" [ "${CT_CC_LANG_FORTRAN}" = "y" ] && lang_list+=",fortran" [ "${CT_CC_LANG_ADA}" = "y" ] && lang_list+=",ada" - [ "${CT_CC_LANG_D}" = "y" ] && lang_list+=",d" + [ "${CT_CC_LANG_D}" = "y" ] && lang_list+=",d" [ "${CT_CC_LANG_JAVA}" = "y" ] && lang_list+=",java" [ "${CT_CC_LANG_JIT}" = "y" ] && lang_list+=",jit" [ "${CT_CC_LANG_OBJC}" = "y" ] && lang_list+=",objc" @@ -282,6 +282,7 @@ do_gcc_core_backend() { gcc_build|gcc_host) CT_DoLog EXTRA "Configuring final gcc compiler" extra_config+=( "${CT_CC_SYSROOT_ARG[@]}" ) + extra_config+=( "--with-headers=${CT_PREFIX_DIR}/${CT_TARGET}/include" ) extra_user_config=( "${CT_CC_GCC_EXTRA_CONFIG_ARRAY[@]}" ) log_txt="final gcc compiler" # to inhibit the libiberty and libgcc tricks later on @@ -388,16 +389,32 @@ do_gcc_core_backend() { "") extra_config+=("--disable-libstdcxx-verbose");; esac + if [ "${build_libstdcxx}" = "yes" ]; then + if [ "x${CT_CC_GCC_LIBSTDCXX}" = "x" ]; then + build_libstdcxx="no" + elif [ "${CT_CC_GCC_LIBSTDCXX}" = "y" ]; then + extra_config+=("--enable-libstdcxx") + fi + + if [ "${CT_LIBC_AVR_LIBC}" = "y" ]; then + extra_config+=("--enable-cstdio=stdio_pure") + fi + + if [ "${CT_CC_GCC_LIBSTDCXX_HOSTED_DISABLE}" = "y" ]; then + extra_config+=("--disable-libstdcxx-hosted") + fi + fi + if [ "${build_libstdcxx}" = "no" ]; then extra_config+=(--disable-libstdcxx) fi if [ "${CT_LIBC_PICOLIBC}" = "y" ]; then - extra_config+=("--with-default-libc=picolibc") - extra_config+=("--enable-stdio=pure") - if [ "${CT_PICOLIBC_older_than_1_8}" = "y" ]; then - extra_config+=("--disable-wchar_t") - fi + extra_config+=("--with-default-libc=picolibc") + extra_config+=("--enable-stdio=pure") + if [ "${CT_PICOLIBC_older_than_1_8}" = "y" ]; then + extra_config+=("--disable-wchar_t") + fi fi core_LDFLAGS+=("${ldflags}") @@ -494,6 +511,12 @@ do_gcc_core_backend() { *) extra_config+=( "--enable-decimal-float=${CT_CC_GCC_DEC_FLOATS}" );; esac + if [ "${CT_CC_GCC_ENABLE_PLUGINS}" = "y" ]; then + extra_config+=( --enable-plugin ) + else + extra_config+=( --disable-plugin ) + fi + case "${CT_ARCH}" in mips) case "${CT_CC_GCC_mips_llsc}" in @@ -528,6 +551,22 @@ do_gcc_core_backend() { "") extra_config+=("--disable-tls");; esac + # In baremetal, we only build the Ada compiler without its runtime. + # The runtime will need to be provided externaly by the user. + if [ "${mode}" = "baremetal" \ + -a "${CT_CC_LANG_ADA}" = "y" \ + ]; then + extra_config+=("--disable-libada" ) + fi + + # In baremetal, we only build the D compiler without its runtime. + # The runtime will need to be provided externaly by the user. + if [ "${mode}" = "baremetal" \ + -a "${CT_CC_LANG_D}" = "y" \ + ]; then + extra_config+=("--disable-libphobos" ) + fi + # 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, core @@ -680,9 +719,7 @@ do_gcc_core_backend() { else # build_libgcc core_targets=( gcc ) fi # ! build libgcc - if [ "${build_libstdcxx}" = "yes" \ - -a "${CT_CC_LANG_CXX}" = "y" \ - ]; then + if [ "${build_libstdcxx}" = "yes" ]; then core_targets+=( target-libstdc++-v3 ) fi @@ -710,6 +747,14 @@ do_gcc_core_backend() { CT_DoLog EXTRA "Building ${log_txt}" CT_DoExecLog ALL make ${CT_JOBSFLAGS} ${core_targets_all} + # In case of baremetal, the gnat* tools are not built automatically. + if [ "${mode}" = "baremetal" \ + -a "${CT_CC_LANG_ADA}" = "y" \ + ]; then + CT_DoLog EXTRA "Building gnattools for baremetal" + CT_DoExecLog ALL make -C gcc ${CT_JOBSFLAGS} cross-gnattools + fi + # Do not pass ${CT_JOBSFLAGS} here: recent GCC builds have been failing # in parallel 'make install' at random locations: libitm, libcilk, # always for the files that are installed more than once to the same @@ -785,9 +830,7 @@ do_cc_for_build() { # lack of such a compiler, but better safe than sorry... build_final_opts+=( "mode=baremetal" ) build_final_opts+=( "build_libgcc=yes" ) - if [ "${CT_LIBC_NONE}" != "y" ]; then - build_final_opts+=( "build_libstdcxx=yes" ) - fi + build_final_opts+=( "build_libstdcxx=yes" ) build_final_opts+=( "build_libgfortran=yes" ) if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then build_final_opts+=( "build_staticlinked=yes" ) @@ -870,15 +913,14 @@ do_cc_for_host() { final_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" ) final_opts+=( "lang_list=$( cc_gcc_lang_list )" ) final_opts+=( "build_step=gcc_host" ) + final_opts+=( "extra_cxxflags_for_target=${CT_CC_GCC_LIBSTDCXX_TARGET_CXXFLAGS}" ) if [ "${CT_BUILD_MANUALS}" = "y" ]; then final_opts+=( "build_manuals=yes" ) fi if [ "${CT_BARE_METAL}" = "y" ]; then final_opts+=( "mode=baremetal" ) final_opts+=( "build_libgcc=yes" ) - if [ "${CT_LIBC_NONE}" != "y" ]; then - final_opts+=( "build_libstdcxx=yes" ) - fi + final_opts+=( "build_libstdcxx=yes" ) final_opts+=( "build_libgfortran=yes" ) if [ "${CT_STATIC_TOOLCHAIN}" = "y" ]; then final_opts+=( "build_staticlinked=yes" ) @@ -1050,16 +1092,24 @@ do_gcc_backend() { "") extra_config+=("--disable-libstdcxx-verbose");; esac - if [ "${build_libstdcxx}" = "no" ]; then + if [ "x${CT_CC_GCC_LIBSTDCXX}" = "x" ]; then extra_config+=(--disable-libstdcxx) - elif [ "${CT_CC_GCC_EXTRA_LIBSTDCXX}" = "y" ]; then + elif [ "${CT_CC_GCC_LIBSTDCXX}" = "y" ]; then extra_config+=(--enable-libstdcxx) fi + if [ "${CT_CC_GCC_LIBSTDCXX_HOSTED_DISABLE}" = "y" ]; then + extra_config+=("--disable-libstdcxx-hosted") + fi + + if [ "${CT_LIBC_AVR_LIBC}" = "y" ]; then + extra_config+=("--enable-cstdio=stdio_pure") + fi + if [ "${CT_LIBC_PICOLIBC}" = "y" ]; then - extra_config+=("--with-default-libc=picolibc") - extra_config+=("--enable-stdio=pure") - extra_config+=("--disable-wchar_t") + extra_config+=("--with-default-libc=picolibc") + extra_config+=("--enable-stdio=pure") + extra_config+=("--disable-wchar_t") fi final_LDFLAGS+=("${ldflags}") @@ -1126,6 +1176,10 @@ do_gcc_backend() { fi fi + if [ "${CT_CC_GCC_ENABLE_DEFAULT_PIE}" = "y" ]; then + extra_config+=("--enable-default-pie") + fi + if [ "${CT_CC_GCC_ENABLE_TARGET_OPTSPACE}" = "y" ] || \ [ "${enable_optspace}" = "yes" ]; then extra_config+=("--enable-target-optspace") diff --git a/scripts/build/companion_libs/050-zlib.sh b/scripts/build/companion_libs/050-zlib.sh index 07c95496..fff326b2 100644 --- a/scripts/build/companion_libs/050-zlib.sh +++ b/scripts/build/companion_libs/050-zlib.sh @@ -92,8 +92,6 @@ do_zlib_backend() { cp -av "${CT_SRC_DIR}/zlib/." . extra_make=( -f win32/Makefile.gcc \ PREFIX="${host}-" \ - SHAREDLIB= \ - IMPLIB= \ LIBRARY_PATH="${prefix}/lib" \ INCLUDE_PATH="${prefix}/include" \ BINARY_PATH="${prefix}/bin" \ diff --git a/scripts/build/companion_libs/070-zstd.sh b/scripts/build/companion_libs/070-zstd.sh index bc334142..d8ef8c2e 100644 --- a/scripts/build/companion_libs/070-zstd.sh +++ b/scripts/build/companion_libs/070-zstd.sh @@ -81,19 +81,9 @@ do_zstd_backend() { done CT_DoLog EXTRA "Building zstd" - CT_DoExecLog ALL make ${CT_JOBSFLAGS} -C "${CT_SRC_DIR}/zstd/lib" libzstd.a BUILD_DIR="${PWD}" CC="${host}-gcc" AS="${host}-as" CFLAGS="${cflags}" LDFLAGS="${ldflags}" - - # TODO: Has to be tested - - #if [ "${CT_COMPLIBS_CHECK}" = "y" ]; then - # if [ "${host}" = "${CT_BUILD}" ]; then - # CT_DoLog EXTRA "Checking zstd" - # CT_DoExecLog ALL make ${CT_JOBSFLAGS} -s check - # else - # # Cannot run host binaries on build in a canadian cross - # CT_DoLog EXTRA "Skipping check for zstd on the host" - # fi - #fi + CT_DoExecLog ALL make ${CT_JOBSFLAGS} -C "${CT_SRC_DIR}/zstd/lib" libzstd.a-nomt-release BUILD_DIR="${PWD}" CC="${host}-gcc" AS="${host}-as" CFLAGS="${cflags}" LDFLAGS="${ldflags}" + + # There is no library only check in zstd CT_DoLog EXTRA "Installing zstd" CT_DoExecLog ALL make -C "${CT_SRC_DIR}/zstd/lib" install-static install-includes BUILD_DIR="${PWD}" PREFIX="$prefix" diff --git a/scripts/build/companion_libs/100-gmp.sh b/scripts/build/companion_libs/100-gmp.sh index 28deff97..4ecaa721 100644 --- a/scripts/build/companion_libs/100-gmp.sh +++ b/scripts/build/companion_libs/100-gmp.sh @@ -122,12 +122,14 @@ do_gmp_backend() { extra_config+=("--with-pic") fi + cflags+=" ${CT_GMP_EXTRA_CFLAGS}" + # GMP's configure script doesn't respect the host parameter # when not cross-compiling, ie when build == host so set # CC_FOR_BUILD and CPP_FOR_BUILD. CT_DoExecLog CFG \ CC_FOR_BUILD="${CT_BUILD}-gcc" \ - CPP_FOR_BUILD="{CT_BUILD}-cpp" \ + CPP_FOR_BUILD="${CT_BUILD}-cpp" \ CC="${host}-gcc" \ CFLAGS="${cflags} -fexceptions" \ LDFLAGS="${ldflags}" \ diff --git a/scripts/build/companion_libs/220-ncurses.sh b/scripts/build/companion_libs/220-ncurses.sh index f1fcd1a1..36aadae6 100644 --- a/scripts/build/companion_libs/220-ncurses.sh +++ b/scripts/build/companion_libs/220-ncurses.sh @@ -133,6 +133,8 @@ do_ncurses_backend() { esac done + ncurses_opts+=("--disable-widec") + if [ "${CT_NCURSES_NEW_ABI}" != "y" ]; then ncurses_opts+=("--with-abi-version=5") fi @@ -150,6 +152,8 @@ do_ncurses_backend() { ncurses_opts+=("--with-shared") fi + cflags+=" ${CT_NCURSES_EXTRA_CFLAGS}" + CT_DoLog EXTRA "Configuring ncurses" CT_DoExecLog CFG \ CFLAGS="${cflags}" \ diff --git a/scripts/build/companion_libs/340-picolibc.sh b/scripts/build/companion_libs/340-picolibc.sh index 0b2038e6..bef72e0f 100644 --- a/scripts/build/companion_libs/340-picolibc.sh +++ b/scripts/build/companion_libs/340-picolibc.sh @@ -26,13 +26,7 @@ do_picolibc_common_install() { yn_args="IO_C99FMT:io-c99-formats IO_LL:io-long-long -REGISTER_FINI:newlib-register-fini NANO_MALLOC:newlib-nano-malloc -ATEXIT_DYNAMIC_ALLOC:newlib-atexit-dynamic-alloc -GLOBAL_ATEXIT:newlib-global-atexit -LITE_EXIT:lite-exit -MULTITHREAD:newlib-multithread -RETARGETABLE_LOCKING:newlib-retargetable-locking " for ynarg in $yn_args; do @@ -48,6 +42,24 @@ RETARGETABLE_LOCKING:newlib-retargetable-locking fi done + # Check how picolibc wants threading support to be specified + + if grep -q single-thread "${CT_SRC_DIR}/picolibc/meson_options.txt"; then + if [ "${CT_LIBC_PICOLIBC_MULTITHREAD}" = "y" ]; then + picolibc_opts+=("-Dsingle-thread=false") + else + picolibc_opts+=("-Dsingle-thread=true") + fi + else + if [ "${CT_LIBC_PICOLIBC_MULTITHREAD}" = "y" ]; then + picolibc_opts+=("-Dnewlib-retargetable-locking=true") + picolibc_opts+=("-Dnewlib-multithread=true") + else + picolibc_opts+=("-Dnewlib-retargetable-locking=false") + picolibc_opts+=("-Dnewlib-multithread=false") + fi + fi + [ "${CT_LIBC_PICOLIBC_EXTRA_SECTIONS}" = "y" ] && \ CT_LIBC_PICOLIBC_TARGET_CFLAGS="${CT_LIBC_PICOLIBC_TARGET_CFLAGS} -ffunction-sections -fdata-sections" @@ -150,12 +162,16 @@ do_cc_libstdcxx_picolibc() final_opts+=( "lang_list=c,c++" ) final_opts+=( "build_step=libstdcxx" ) final_opts+=( "extra_config+=('--enable-stdio=stdio_pure')" ) + final_opts+=( "extra_config+=('--with-headers=${CT_PREFIX_DIR}/picolibc/include')" ) if [ "${CT_PICOLIBC_older_than_1_8}" = "y" ]; then final_opts+=( "extra_config+=('--disable-wchar_t')" ) fi if [ "${CT_LIBC_PICOLIBC_ENABLE_TARGET_OPTSPACE}" = "y" ]; then final_opts+=( "enable_optspace=yes" ) fi + if [ -n "${CT_LIBC_PICOLIBC_GCC_LIBSTDCXX_TARGET_CXXFLAGS}" ]; then + final_opts+=( "extra_cxxflags_for_target=${CT_LIBC_PICOLIBC_GCC_LIBSTDCXX_TARGET_CXXFLAGS}" ) + fi if [ "${CT_BARE_METAL}" = "y" ]; then final_opts+=( "mode=baremetal" ) diff --git a/scripts/build/companion_libs/400-gnuprumcu.sh b/scripts/build/companion_libs/400-gnuprumcu.sh index bba85748..7d17853c 100644 --- a/scripts/build/companion_libs/400-gnuprumcu.sh +++ b/scripts/build/companion_libs/400-gnuprumcu.sh @@ -19,6 +19,22 @@ do_gnuprumcu_extract() { do_gnuprumcu_for_target() { local -a gnuprumcu_opts + local -a cflags + + cflags=${CT_ALL_TARGET_CFLAGS} + + # When building a canadian, newlib is installed + # only in the host' sysroot. Thus the build toolchain + # lacks CRT0 and LibC objects. Consequently the + # gnuprumcu configure script fails with: + # .../ld: cannot find crt0.o: No such file or directory + # configure:3738: error: C compiler cannot create executables + # + # Fix by pointing the build toolchain to the host sysroot, + # where the necessary target runtime files are available. + case "${CT_TOOLCHAIN_TYPE}" in + canadian) cflags="${cflags} --sysroot=${CT_SYSROOT_DIR}";; + esac CT_DoStep INFO "Installing gnuprumcu for the target" CT_mkdir_pushd "${CT_BUILD_DIR}/build-gnuprumcu-target-${CT_TARGET}" @@ -26,7 +42,8 @@ do_gnuprumcu_for_target() { gnuprumcu_opts+=( "destdir=${CT_SYSROOT_DIR}" ) gnuprumcu_opts+=( "host=${CT_TARGET}" ) - gnuprumcu_opts+=( "cflags=${CT_ALL_TARGET_CFLAGS}" ) + gnuprumcu_opts+=( "cflags=${cflags}" ) + gnuprumcu_opts+=( "ldflags=${CT_ALL_TARGET_LDFLAGS}" ) gnuprumcu_opts+=( "prefix=${CT_PREFIX_DIR}" ) do_gnuprumcu_backend "${gnuprumcu_opts[@]}" diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh index 8860b541..508ba25f 100644 --- a/scripts/build/debug/300-gdb.sh +++ b/scripts/build/debug/300-gdb.sh @@ -66,8 +66,8 @@ do_debug_gdb_build() # version of expat and will attempt to link that, despite the -static flag. # The link will fail, and configure will abort with "expat missing or unusable" # message. - extra_config+=("--with-expat") - extra_config+=("--without-libexpat-prefix") + cross_extra_config+=("--with-expat") + cross_extra_config+=("--without-libexpat-prefix") # ct-ng always builds ncurses in cross mode as a static library. # Starting from the patchset 20200718 ncurses defines a special macro @@ -122,6 +122,14 @@ do_debug_gdb_build() native_extra_config+=("--program-prefix=") + # Starting from GDB 11.x, gmp is needed as a dependency to build full + # gdb. And if target GMP gets built, explicitly point to installed library, + # as otherwise host library might be attempted to be used for target binary + # linkage. + if [ "${CT_GMP_TARGET}" = "y" ]; then + native_extra_config+=("--with-libgmp-prefix=${CT_SYSROOT_DIR}") + fi + # gdbserver gets enabled by default with gdb # since gdbserver was promoted to top-level if [ "${CT_GDB_GDBSERVER_TOPLEVEL}" = "y" ]; then @@ -167,17 +175,14 @@ do_debug_gdb_build() # where libexpat for build platform lives, which is # unacceptable for cross-compiling. # - # To prevent this '--without-libexpat-prefix' flag must be passed. - # Thus configure falls back to '-lexpat', which is exactly what we want. - # - # NOTE: DO NOT USE --with-libexpat-prefix (until GDB configure is smarter)!!! - # It conflicts with a static build: GDB's configure script will find the shared - # version of expat and will attempt to link that, despite the -static flag. - # The link will fail, and configure will abort with "expat missing or unusable" - # message. - native_extra_config+=("--with-expat") - native_extra_config+=("--without-libexpat-prefix") + native_extra_config+=("--with-expat=y") + native_extra_config+=("--with-libexpat-prefix=${CT_BUILDTOOLS_PREFIX_DIR}") + # Without specifying libexpat type, configure would look for -lexpat + # and try to link with shared library, set library type explicitly. + if [ "${CT_GDB_NATIVE_STATIC}" = "y" ]; then + native_extra_config+=("--with-libexpat-type=static") + fi do_gdb_backend \ buildtype=native \ subdir=${subdir} \ @@ -348,7 +353,13 @@ do_gdb_backend() "${extra_config[@]}" \ if [ "${static}" = "y" ]; then - extra_make_flags+=("LDFLAGS=${ldflags} -all-static") + if [ "${CT_GDB_CC_LD_LIBTOOL}" = "y" ]; then + # gdb is linked with libtool, but gdbserver is not + # Both linker accept -static --static and create static binaries + extra_make_flags+=("LDFLAGS=${ldflags} -static --static") + else + extra_make_flags+=("LDFLAGS=${ldflags} -static") + fi CT_DoLog EXTRA "Prepare gdb for static build" CT_DoExecLog ALL make ${CT_JOBSFLAGS} configure-host fi diff --git a/scripts/build/kernel/hurd.sh b/scripts/build/kernel/hurd.sh new file mode 100644 index 00000000..fcda95bc --- /dev/null +++ b/scripts/build/kernel/hurd.sh @@ -0,0 +1,71 @@ +# This file declares functions to install the kernel headers for linux +# Copyright 2007 Yann E. MORIN +# Licensed under the GPL v2. See COPYING in the root of this package + +CT_DoKernelTupleValues() +{ + : +} + +# Download the kernel +do_kernel_get() +{ + CT_Fetch HURD + CT_Fetch GNUMACH + CT_Fetch MIG +} + +# Extract kernel +do_kernel_extract() +{ + # TBD verify linux_disable_build_relocs is run + CT_ExtractPatch HURD + CT_ExtractPatch GNUMACH + CT_ExtractPatch MIG +} + +# Install kernel headers using headers_install from kernel sources. +do_kernel_headers() +{ + CT_DoStep INFO "Installing kernel headers" + + for component in gnumach mig hurd; do + local build_dir="${CT_BUILD_DIR}/${component}" + local src_dir="${CT_SRC_DIR}/${component}" + + CT_mkdir_pushd "${build_dir}" + CT_DoLog EXTRA "crupest PATH $PATH" + + case ${component} in + gnumach) + CT_DoLog EXTRA "Installing GNU Mach headers" + CT_DoExecLog ALL \ + ${src_dir}/configure \ + --host="${CT_TARGET}" \ + --prefix="/usr" + CT_DoExecLog ALL make DESTDIR="${CT_SYSROOT_DIR}" install-data + ;; + mig) + CT_DoLog EXTRA "Installing GNU MIG" + CT_DoExecLog ALL \ + ${src_dir}/configure \ + --target="${CT_TARGET}" \ + --prefix="/usr" + CT_DoExecLog ALL \ + make TARGET_CFLAGS="-isysroot ${CT_SYSROOT_DIR}" install + ;; + hurd) + CT_DoLog EXTRA "Installing Hurd headers" + CT_DoExecLog ALL \ + ${src_dir}/configure \ + --host="${CT_TARGET}" \ + --prefix="/usr" + CT_DoExecLog ALL make prefix="${CT_SYSROOT_DIR}/usr" install-data-local-headers + ;; + esac + + CT_Popd + done + + CT_EndStep +} diff --git a/scripts/build/libc/avr-libc.sh b/scripts/build/libc/avr-libc.sh index c13ae39b..4949380a 100644 --- a/scripts/build/libc/avr-libc.sh +++ b/scripts/build/libc/avr-libc.sh @@ -2,7 +2,7 @@ avr_libc_post_cc() { - if [ "${CT_CC_CORE_PASS_2_NEEDED}" != "y" ]; then + if [ "${CT_CC_CORE_NEEDED}" != "y" ]; then CT_DoStep INFO "Installing C library" CT_DoLog EXTRA "Copying sources to build directory" @@ -32,7 +32,7 @@ avr_libc_post_cc() avr_libc_main() { - if [ "${CT_CC_CORE_PASS_2_NEEDED}" = "y" ]; then + if [ "${CT_CC_CORE_NEEDED}" = "y" ]; then CT_DoStep INFO "Installing C library" CT_DoLog EXTRA "Copying sources to build directory" diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 280eb124..043660c1 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -182,6 +182,10 @@ glibc_backend_once() # or even after they get installed... echo "ac_cv_path_BASH_SHELL=/bin/bash" >>config.cache + if [ "${CT_GLIBC_MAKEINFO_WORKAROUND}" = "y" ]; then + echo "ac_cv_prog_MAKEINFO=" >>config.cache + fi + CT_SymlinkToolsMultilib # Configure with --prefix the way we want it on the target... @@ -249,8 +253,8 @@ glibc_backend_once() build_cppflags="${build_cppflags} -I${CT_BUILDTOOLS_PREFIX_DIR}/include/" build_ldflags="${build_ldflags} -lintl -liconv" case "$CT_BUILD" in - *cygwin*|*freebsd*) - # Additionally, stat in FreeBSD, Cygwin, and possibly others + *cygwin*|*freebsd*|aarch64*darwin*) + # Additionally, stat in FreeBSD, Cygwin, Darwin arm64 and possibly others # is always 64bit, so replace struct stat64 with stat. build_cppflags="${build_cppflags} -Dstat64=stat" ;; diff --git a/scripts/build/libc/mingw-w64.sh b/scripts/build/libc/mingw-w64.sh index d4f3634f..6224deba 100644 --- a/scripts/build/libc/mingw-w64.sh +++ b/scripts/build/libc/mingw-w64.sh @@ -208,6 +208,7 @@ mingw_w64_main() --prefix=${MINGW_INSTALL_PREFIX} \ --build=${CT_BUILD} \ --host=${CT_TARGET} \ + --enable-wildcard \ "${crt_opts[@]}" # mingw-w64-crt has a missing dependency occasionally breaking the diff --git a/scripts/build/libc/newlib.sh b/scripts/build/libc/newlib.sh index 72111a93..21d13773 100644 --- a/scripts/build/libc/newlib.sh +++ b/scripts/build/libc/newlib.sh @@ -89,6 +89,9 @@ ENABLE_TARGET_OPTSPACE:target-optspace [ "${CT_LIBC_NEWLIB_LTO}" = "y" ] && \ CT_LIBC_NEWLIB_TARGET_CFLAGS="${CT_LIBC_NEWLIB_TARGET_CFLAGS} -flto" + [ "${CT_GCC_14_or_later}" = "y" ] && \ + CT_LIBC_NEWLIB_TARGET_CFLAGS="${CT_LIBC_NEWLIB_TARGET_CFLAGS} -Wno-error=implicit-function-declaration -Wno-implicit-int" + cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_NEWLIB_TARGET_CFLAGS}" # Note: newlib handles the build/host/target a little bit differently diff --git a/scripts/build/linker.sh b/scripts/build/linker.sh new file mode 100644 index 00000000..235d7cf6 --- /dev/null +++ b/scripts/build/linker.sh @@ -0,0 +1,38 @@ +# Wrapper to build the standalone linkers + +# List all linkers, and parse their scripts +CT_LINKER_LIST= +for f in "${CT_LIB_DIR}/scripts/build/linker/"*.sh; do + _f="$(basename "${f}" .sh)" + _f="${_f#???-}" + __f="CT_LINKER_${_f^^}" + if [ "${!__f}" = "y" ]; then + CT_DoLog DEBUG "Enabling linker '${_f}'" + . "${f}" + CT_LINKER_LIST="${CT_LINKER_LIST} ${_f}" + else + CT_DoLog DEBUG "Disabling linker '${_f}'" + fi +done + +# Download the linkers +do_linker_get() { + for f in ${CT_LINKER_LIST}; do + do_linker_${f}_get + done +} + +# Extract and patch the linkers +do_linker_extract() { + for f in ${CT_LINKER_LIST}; do + do_linker_${f}_extract + done +} + +# Build the linkers +do_linker() { + for f in ${CT_LINKER_LIST}; do + do_linker_${f}_build + done +} + diff --git a/scripts/build/linker/100-mold.sh b/scripts/build/linker/100-mold.sh new file mode 100644 index 00000000..c743c9c7 --- /dev/null +++ b/scripts/build/linker/100-mold.sh @@ -0,0 +1,40 @@ +# Build script for the mold linker + +do_linker_mold_get() { + CT_Fetch MOLD +} + +do_linker_mold_extract() { + CT_ExtractPatch MOLD +} + +do_linker_mold_build() { + local target_dir="${CT_PREFIX_DIR}/${CT_TARGET}" + + CT_DoStep INFO "Installing mold for host" + CT_mkdir_pushd "${CT_BUILD_DIR}/build-mold" + + CT_DoLog EXTRA "Configuring mold for host" + CT_DoExecLog CFG \ + CC="${CT_HOST}-gcc" \ + CXX="${CT_HOST}-g++" \ + CFLAGS="${CT_CFLAGS_FOR_HOST}" \ + LDFLAGS="${CT_LDFLAGS_FOR_HOST}" \ + cmake "${CT_SRC_DIR}/mold" \ + -DBUILD_TESTING=OFF \ + -DMOLD_MOSTLY_STATIC=ON \ + -DCMAKE_BUILD_TYPE=Release + + CT_DoLog EXTRA "Building mold for host" + CT_DoExecLog ALL make ${CT_JOBSFLAGS} + + CT_DoLog EXTRA "Installing mold for host" + mkdir -p "${target_dir}/bin" + cp mold "${target_dir}/bin" + ln -s mold "${target_dir}/bin/ld.mold" + mkdir -p "${target_dir}/lib/mold" + cp mold-wrapper.so "${target_dir}/lib/mold" + + CT_Popd + CT_EndStep +} diff --git a/scripts/build/test_suite/gcc.sh b/scripts/build/test_suite/gcc.sh index 6c6e5a72..25eee5ad 100644 --- a/scripts/build/test_suite/gcc.sh +++ b/scripts/build/test_suite/gcc.sh @@ -21,8 +21,17 @@ do_test_suite_gcc_build() { "${CT_SRC_DIR}/gcc/gcc/testsuite" \ "${CT_TEST_SUITE_DIR}/gcc" - CT_DoExecLog ALL sed -i -r -e "s/@@DG_TARGET@@/${CT_TARGET}/g;" \ - "${CT_TEST_SUITE_DIR}/gcc/Makefile" + DG_QEMU_ARGS=`echo "${CT_TEST_SUITE_GCC_QEMU_ARGS}" | sed 's/@SYSROOT@/$(SYSROOT)/'` + + CT_DoExecLog ALL sed -i -r \ + -e "s/@@DG_TARGET@@/${CT_TARGET}/g" \ + -e "s/@@DG_SSH@@/${CT_TEST_SUITE_GCC_SSH}/g" \ + -e "s/@@DG_QEMU@@/${CT_TEST_SUITE_GCC_QEMU}/g" \ + -e "s/@@DG_TARGET_HOSTNAME@@/${CT_TEST_SUITE_GCC_TARGET_HOSTNAME}/g" \ + -e "s/@@DG_TARGET_USERNAME@@/${CT_TEST_SUITE_GCC_TARGET_USERNAME}/g" \ + -e "s/@@DG_QEMU_PROGRAM@@/${CT_TEST_SUITE_GCC_QEMU_PROGRAM}/g" \ + -e "s/@@DG_QEMU_ARGS@@/${DG_QEMU_ARGS}/g" \ + "${CT_TEST_SUITE_DIR}/gcc/default.cfg" CT_EndStep } diff --git a/scripts/config.guess b/scripts/config.guess index 980b0208..f6d217a4 100755 --- a/scripts/config.guess +++ b/scripts/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2022 Free Software Foundation, Inc. +# Copyright 1992-2024 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2022-09-17' +timestamp='2024-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -47,7 +47,7 @@ me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] -Output the configuration name of the system \`$me' is run on. +Output the configuration name of the system '$me' is run on. Options: -h, --help print this help, then exit @@ -60,13 +60,13 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2022 Free Software Foundation, Inc. +Copyright 1992-2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" -Try \`$me --help' for more information." +Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do @@ -102,8 +102,8 @@ GUESS= # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. +# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still +# use 'HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. @@ -155,6 +155,9 @@ Linux|GNU|GNU/*) set_cc_for_build cat <<-EOF > "$dummy.c" + #if defined(__ANDROID__) + LIBC=android + #else #include <features.h> #if defined(__UCLIBC__) LIBC=uclibc @@ -162,6 +165,8 @@ Linux|GNU|GNU/*) LIBC=dietlibc #elif defined(__GLIBC__) LIBC=gnu + #elif defined(__LLVM_LIBC__) + LIBC=llvm #else #include <stdarg.h> /* First heuristic to detect musl libc. */ @@ -169,6 +174,7 @@ Linux|GNU|GNU/*) LIBC=musl #endif #endif + #endif EOF cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` eval "$cc_set_libc" @@ -459,7 +465,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in UNAME_RELEASE=`uname -v` ;; esac - # Japanese Language versions have a version number like `4.1.3-JL'. + # Japanese Language versions have a version number like '4.1.3-JL'. SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` GUESS=sparc-sun-sunos$SUN_REL ;; @@ -904,7 +910,7 @@ EOF fi ;; *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` + UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in amd64) UNAME_PROCESSOR=x86_64 ;; @@ -976,7 +982,27 @@ EOF GUESS=$UNAME_MACHINE-unknown-minix ;; aarch64:Linux:*:*) - GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __ARM_EABI__ + #ifdef __ARM_PCS_VFP + ABI=eabihf + #else + ABI=eabi + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;; + esac + fi + GUESS=$CPU-unknown-linux-$LIBCABI ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be @@ -1042,6 +1068,15 @@ EOF k1om:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; + kvx:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + kvx:cos:*:*) + GUESS=$UNAME_MACHINE-unknown-cos + ;; + kvx:mbr:*:*) + GUESS=$UNAME_MACHINE-unknown-mbr + ;; loongarch32:Linux:*:* | loongarch64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; @@ -1197,7 +1232,7 @@ EOF GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION ;; i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility + # If we were able to find 'uname', then EMX Unix compatibility # is probably installed. GUESS=$UNAME_MACHINE-pc-os2-emx ;; @@ -1338,7 +1373,7 @@ EOF GUESS=ns32k-sni-sysv fi ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort # says <Richard.M.Bartel@ccMail.Census.GOV> GUESS=i586-unisys-sysv4 ;; @@ -1560,6 +1595,9 @@ EOF *:Unleashed:*:*) GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE ;; + *:Ironclad:*:*) + GUESS=$UNAME_MACHINE-unknown-ironclad + ;; esac # Do we have a guess based on uname results? diff --git a/scripts/config.sub b/scripts/config.sub index baf1512b..128e065c 100755 --- a/scripts/config.sub +++ b/scripts/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2022 Free Software Foundation, Inc. +# Copyright 1992-2024 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2022-09-17' +timestamp='2024-01-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -76,13 +76,13 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright 1992-2022 Free Software Foundation, Inc. +Copyright 1992-2024 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" -Try \`$me --help' for more information." +Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do @@ -130,7 +130,7 @@ IFS=$saved_IFS # Separate into logical components for further validation case $1 in *-*-*-*-*) - echo Invalid configuration \`"$1"\': more than four components >&2 + echo "Invalid configuration '$1': more than four components" >&2 exit 1 ;; *-*-*-*) @@ -145,7 +145,8 @@ case $1 in nto-qnx* | linux-* | uclinux-uclibc* \ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ - | storm-chaos* | os2-emx* | rtmk-nova* | managarm-*) + | storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \ + | windows-* ) basic_machine=$field1 basic_os=$maybe_os ;; @@ -943,7 +944,7 @@ $basic_machine EOF IFS=$saved_IFS ;; - # We use `pc' rather than `unknown' + # We use 'pc' rather than 'unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) @@ -1075,7 +1076,7 @@ case $cpu-$vendor in pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) cpu=i586 ;; - pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) + pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*) cpu=i686 ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) @@ -1180,7 +1181,7 @@ case $cpu-$vendor in case $cpu in 1750a | 580 \ | a29k \ - | aarch64 | aarch64_be \ + | aarch64 | aarch64_be | aarch64c | arm64ec \ | abacus \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ @@ -1199,12 +1200,14 @@ case $cpu-$vendor in | d10v | d30v | dlx | dsp16xx \ | e2k | elxsi | epiphany \ | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | javascript \ | h8300 | h8500 \ | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i*86 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ + | kvx \ | le32 | le64 \ | lm32 \ | loongarch32 | loongarch64 \ @@ -1213,36 +1216,13 @@ case $cpu-$vendor in | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ | m88110 | m88k | maxq | mb | mcore | mep | metag \ | microblaze | microblazeel \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64eb | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r3 | mipsisa32r3el \ - | mipsisa32r5 | mipsisa32r5el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r3 | mipsisa64r3el \ - | mipsisa64r5 | mipsisa64r5el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ + | mips* \ | mmix \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ + | nanomips* \ | nds32 | nds32le | nds32be \ | nfp \ | nios | nios2 | nios2eb | nios2el \ @@ -1260,9 +1240,13 @@ case $cpu-$vendor in | rl78 | romp | rs6000 | rx \ | s390 | s390x \ | score \ - | sh | shl \ + | sh | shl | sh4al \ | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sh[42]a_nofpu | sh4_nofpu | sh[42]a_single | sh4_single \ + | sh[42]a_single_only | sh4_single_only \ + | sh[42]a_nofpue[lb] | sh4_nofpue[lb] | sh[42]a_singlee[lb] | sh4_singlee[lb] \ + | sh[42]a_single_onlye[lb] | sh4_single_onlye[lb] \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ @@ -1270,10 +1254,12 @@ case $cpu-$vendor in | tahoe \ | thumbv7* \ | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tricore \ | tron \ | ubicom32 \ | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ | vax \ + | vc4 \ | visium \ | w65 \ | wasm32 | wasm64 \ @@ -1285,7 +1271,7 @@ case $cpu-$vendor in ;; *) - echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2 exit 1 ;; esac @@ -1306,11 +1292,12 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if test x$basic_os != x +if test x"$basic_os" != x then # First recognize some ad-hoc cases, or perhaps split kernel-os, or else just # set os. +obj= case $basic_os in gnu/linux*) kernel=linux @@ -1510,10 +1497,16 @@ case $os in os=eabi ;; *) - os=elf + os= + obj=elf ;; esac ;; + aout* | coff* | elf* | pe*) + # These are machine code file formats, not OSes + obj=$os + os= + ;; *) # No normalization, but not necessarily accepted, that comes below. ;; @@ -1532,12 +1525,15 @@ else # system, and we'll never get to this point. kernel= +obj= case $cpu-$vendor in score-*) - os=elf + os= + obj=elf ;; spu-*) - os=elf + os= + obj=elf ;; *-acorn) os=riscix1.2 @@ -1547,28 +1543,35 @@ case $cpu-$vendor in os=gnu ;; arm*-semi) - os=aout + os= + obj=aout ;; c4x-* | tic4x-*) - os=coff + os= + obj=coff ;; c8051-*) - os=elf + os= + obj=elf ;; clipper-intergraph) os=clix ;; hexagon-*) - os=elf + os= + obj=elf ;; tic54x-*) - os=coff + os= + obj=coff ;; tic55x-*) - os=coff + os= + obj=coff ;; tic6x-*) - os=coff + os= + obj=coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1590,19 +1593,24 @@ case $cpu-$vendor in os=sunos3 ;; m68*-cisco) - os=aout + os= + obj=aout ;; mep-*) - os=elf + os= + obj=elf ;; mips*-cisco) - os=elf + os= + obj=elf ;; - mips*-*) - os=elf + mips*-*|nanomips*-*) + os= + obj=elf ;; or32-*) - os=coff + os= + obj=coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=sysv3 @@ -1611,7 +1619,8 @@ case $cpu-$vendor in os=sunos4.1.1 ;; pru-*) - os=elf + os= + obj=elf ;; *-be) os=beos @@ -1692,10 +1701,12 @@ case $cpu-$vendor in os=uxpv ;; *-rom68k) - os=coff + os= + obj=coff ;; *-*bug) - os=coff + os= + obj=coff ;; *-apple) os=macos @@ -1713,10 +1724,11 @@ esac fi -# Now, validate our (potentially fixed-up) OS. +# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ). + case $os in # Sometimes we do "kernel-libc", so those need to count as OSes. - musl* | newlib* | relibc* | uclibc*) + llvm* | musl* | newlib* | relibc* | uclibc*) ;; # Likewise for "kernel-abi" eabi* | gnueabi*) @@ -1724,6 +1736,9 @@ case $os in # VxWorks passes extra cpu info in the 4th filed. simlinux | simwindows | spe) ;; + # See `case $cpu-$os` validation below + ghcjs) + ;; # Now accept the basic system types. # The portable systems comes first. # Each alternative MUST end in a * to match a version number. @@ -1732,7 +1747,7 @@ case $os in | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ | hiux* | abug | nacl* | netware* | windows* \ - | os9* | macos* | osx* | ios* \ + | os9* | macos* | osx* | ios* | tvos* | watchos* \ | mpw* | magic* | mmixware* | mon960* | lnews* \ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ | aos* | aros* | cloudabi* | sortix* | twizzler* \ @@ -1741,11 +1756,11 @@ case $os in | mirbsd* | netbsd* | dicos* | openedition* | ose* \ | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ - | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ - | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | bosx* | nextstep* | cxux* | oabi* \ + | ptx* | ecoff* | winnt* | domain* | vsta* \ | udi* | lites* | ieee* | go32* | aux* | hcos* \ | chorusrdb* | cegcc* | glidix* | serenity* \ - | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | cygwin* | msys* | moss* | proelf* | rtems* \ | midipix* | mingw32* | mingw64* | mint* \ | uxpv* | beos* | mpeix* | udk* | moxiebox* \ | interix* | uwin* | mks* | rhapsody* | darwin* \ @@ -1758,62 +1773,116 @@ case $os in | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ - | fiwix* | mlibc* ) + | fiwix* | mlibc* | cos* | mbr* | ironclad* ) ;; # This one is extra strict with allowed versions sco3.2v2 | sco3.2v[4-9]* | sco5v6*) # Don't forget version if it is 3.2v4 or newer. ;; + # This refers to builds using the UEFI calling convention + # (which depends on the architecture) and PE file format. + # Note that this is both a different calling convention and + # different file format than that of GNU-EFI + # (x86_64-w64-mingw32). + uefi) + ;; none) ;; - kernel* ) + kernel* | msvc* ) # Restricted further below ;; + '') + if test x"$obj" = x + then + echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2 + fi + ;; *) - echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2 + exit 1 + ;; +esac + +case $obj in + aout* | coff* | elf* | pe*) + ;; + '') + # empty is fine + ;; + *) + echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2 + exit 1 + ;; +esac + +# Here we handle the constraint that a (synthetic) cpu and os are +# valid only in combination with each other and nowhere else. +case $cpu-$os in + # The "javascript-unknown-ghcjs" triple is used by GHC; we + # accept it here in order to tolerate that, but reject any + # variations. + javascript-ghcjs) + ;; + javascript-* | *-ghcjs) + echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2 exit 1 ;; esac # As a final step for OS-related things, validate the OS-kernel combination # (given a valid OS), if there is a kernel. -case $kernel-$os in - linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \ - | linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* ) +case $kernel-$os-$obj in + linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \ + | linux-mlibc*- | linux-musl*- | linux-newlib*- \ + | linux-relibc*- | linux-uclibc*- ) ;; - uclinux-uclibc* ) + uclinux-uclibc*- ) ;; - managarm-mlibc* | managarm-kernel* ) + managarm-mlibc*- | managarm-kernel*- ) ;; - -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* ) + windows*-msvc*-) + ;; + -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \ + | -uclibc*- ) # These are just libc implementations, not actual OSes, and thus # require a kernel. - echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2 exit 1 ;; - -kernel* ) - echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2 + -kernel*- ) + echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2 exit 1 ;; - *-kernel* ) - echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2 + *-kernel*- ) + echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2 exit 1 ;; - kfreebsd*-gnu* | kopensolaris*-gnu*) + *-msvc*- ) + echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2 + exit 1 ;; - vxworks-simlinux | vxworks-simwindows | vxworks-spe) + kfreebsd*-gnu*- | kopensolaris*-gnu*-) ;; - nto-qnx*) + vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-) ;; - os2-emx) + nto-qnx*-) + ;; + os2-emx-) + ;; + *-eabi*- | *-gnueabi*-) ;; - *-eabi* | *-gnueabi*) + none--*) + # None (no kernel, i.e. freestanding / bare metal), + # can be paired with an machine code file format ;; - -*) + -*-) # Blank kernel with real OS is always fine. ;; - *-*) - echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + --*) + # Blank kernel and OS with real machine code file format is always fine. + ;; + *-*-*) + echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2 exit 1 ;; esac @@ -1896,7 +1965,7 @@ case $vendor in ;; esac -echo "$cpu-$vendor-${kernel:+$kernel-}$os" +echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}" exit # Local variables: diff --git a/scripts/crosstool-NG.sh b/scripts/crosstool-NG.sh index 2269262d..bfada4f6 100644 --- a/scripts/crosstool-NG.sh +++ b/scripts/crosstool-NG.sh @@ -264,7 +264,7 @@ fi # Good, now grab a bit of informations on the system we're being run on, # just in case something goes awok, and it's not our fault: -CT_SYS_USER=$(id -un) +CT_SYS_USER=$(id -un 2>/dev/null || echo "unknown") CT_SYS_HOSTNAME=$(hostname -f 2>/dev/null || true) # Hmmm. Some non-DHCP-enabled machines do not have an FQDN... Fall back to node name. CT_SYS_HOSTNAME="${CT_SYS_HOSTNAME:-$(uname -n)}" @@ -361,10 +361,12 @@ if [ -z "${CT_RESTART}" ]; then # binutils 2.14 and later obey it, older binutils ignore it. # Lets you build a working 32->64 bit cross gcc CT_BINUTILS_SYSROOT_ARG="--with-sysroot=${CT_SYSROOT_DIR}" - # Use --with-headers, else final gcc will define disable_glibc while - # building libgcc, and you'll have no profiling CT_CC_CORE_SYSROOT_ARG=("--without-headers") - CT_CC_SYSROOT_ARG=("--with-headers=${CT_HEADERS_DIR}") + if [ "${CT_LIBC_GLIBC}" = "y" ]; then + # Use --with-headers, else final gcc will define disable_glibc while + # building libgcc, and you'll have no profiling + CT_CC_SYSROOT_ARG=("--with-headers=${CT_HEADERS_DIR}") + fi fi CT_DoExecLog ALL mkdir -p "${CT_SYSROOT_DIR}" CT_DoExecLog ALL mkdir -p "${CT_DEBUGROOT_DIR}" @@ -437,7 +439,7 @@ if [ -z "${CT_RESTART}" ]; then t="${!r}-" fi - for tool in ar as dlltool gcc gcc-ar gcc-nm gcc-ranlib g++ gcj gnatbind gdc gnatmake ld libtool nm objcopy objdump ranlib strip windres; do + for tool in ar as dlltool gcc gcc-ar gcc-nm gcc-ranlib g++ gcj gnatbind gdc gnatmake gnatls gnatlink ld libtool nm objcopy objdump ranlib strip windres; do # First try with prefix + suffix # Then try with prefix only # Then try with suffix only, but only for BUILD, and HOST iff REAL_BUILD == REAL_HOST @@ -485,6 +487,7 @@ if [ -z "${CT_RESTART}" ]; then # If any other is missing, only warn at low level *) # It does not deserve a WARN level. + # TBD Do we want to check for tools required by specific languages here? i.e gnat* if Ada is selected. CT_DoLog DEBUG " Missing: '${t}${tool}${!s}' or '${t}${tool}' or '${tool}' : not required." ;; esac @@ -659,6 +662,7 @@ if [ -z "${CT_RESTART}" ]; then do_companion_libs_get do_binutils_get do_cc_get + do_linker_get do_libc_get do_debug_get do_test_suite_get @@ -676,6 +680,7 @@ if [ -z "${CT_RESTART}" ]; then do_companion_libs_extract do_binutils_extract do_cc_extract + do_linker_extract do_libc_extract do_debug_extract do_test_suite_extract diff --git a/scripts/functions b/scripts/functions index 94fd1e9e..cd15f39b 100644 --- a/scripts/functions +++ b/scripts/functions @@ -25,6 +25,7 @@ CT_LoadConfig() { . "${CT_LIB_DIR}/scripts/build/binutils/${CT_BINUTILS}.sh" . "${CT_LIB_DIR}/scripts/build/libc.sh" . "${CT_LIB_DIR}/scripts/build/cc/${CT_CC}.sh" + . "${CT_LIB_DIR}/scripts/build/linker.sh" . "${CT_LIB_DIR}/scripts/build/debug.sh" . "${CT_LIB_DIR}/scripts/build/test_suite.sh" @@ -956,6 +957,7 @@ CT_GetFile() # Do we already have it in *our* tarballs dir? if [ -r "${CT_TARBALLS_DIR}/${basename}${ext}" ]; then CT_DoLog DEBUG "Already have '${CT_TARBALLS_DIR}/${basename}${ext}'" + touch "${CT_TARBALLS_DIR}/${basename}${ext}" # for CI return 0 fi @@ -1778,6 +1780,7 @@ CT_Mirrors() case "${org}" in GNU) + echo "https://mirrors.tuna.tsinghua.edu.cn/gnu/${project}" echo "https://ftpmirror.gnu.org/gnu/${project}" echo "http://ftpmirror.gnu.org/gnu/${project}" echo "https://ftp.gnu.org/gnu/${project}" @@ -1785,9 +1788,10 @@ CT_Mirrors() echo "ftp://ftp.gnu.org/gnu/${project}" ;; sourceware) + echo "https://sourceware.org/${project}/ftp" echo "ftp://sourceware.org/pub/${project}" - echo "http://mirrors.kernel.org/sourceware/${project}" - echo "http://gcc.gnu.org/pub/${project}" + echo "https://mirrors.kernel.org/sourceware/${project}" + echo "https://gcc.gnu.org/pub/${project}" ;; Linaro) local version="${3}" @@ -2502,7 +2506,7 @@ if [ -r "${CT_LIB_DIR}/paths.sh" ]; then elif [ -r "${CT_TOP_DIR}/paths.sh" ]; then paths_sh_location="${CT_TOP_DIR}/paths.sh" else - CT_Error "Not found: paths.sh" + CT_Abort "Not found: paths.sh" fi . "${paths_sh_location}" @@ -2536,8 +2540,7 @@ CT_InstallConfigurationFile() local path="${1}" local suffix="${2}" - CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/bin" - CT_DoExecLog DEBUG ${install} -m 0755 "${CT_LIB_DIR}/scripts/toolchain-config.in" "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${suffix}.config" - CT_DoExecLog DEBUG ${sed} -i -e 's,@@grep@@,"'"${grep}"'",;' "${CT_PREFIX_DIR}/bin/${CT_TARGET}-${suffix}.config" - bzip2 -c -9 "${path}" >>"${CT_PREFIX_DIR}/bin/${CT_TARGET}-${suffix}.config" + CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/share" + CT_DoExecLog DEBUG ${install} -m 0644 "${path}" "${CT_PREFIX_DIR}/share/${CT_TARGET}-${suffix}.config" + CT_DoExecLog DEBUG bzip2 -9 "${CT_PREFIX_DIR}/share/${CT_TARGET}-${suffix}.config" } diff --git a/scripts/show-config.sh b/scripts/show-config.sh index 36ade9ec..295e29e3 100644 --- a/scripts/show-config.sh +++ b/scripts/show-config.sh @@ -96,6 +96,7 @@ dump_single_sample() dump_pkgs_desc KERNEL "OS" dump_pkgs_desc BINUTILS "Binutils" dump_pkgs_desc CC "Compiler" + dump_pkgs_desc LINKER "Linkers" dump_pkgs_desc LIBC "C library" dump_pkgs_desc DEBUG "Debug tools" dump_pkgs_desc COMP_LIBS "Companion libs" diff --git a/scripts/toolchain-config.in b/scripts/toolchain-config.in deleted file mode 100644 index 14549bc3..00000000 --- a/scripts/toolchain-config.in +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -tail -n+5 "${0}" |bzcat -exit 0 |