diff options
Diffstat (limited to 'scripts/build')
-rw-r--r-- | scripts/build/arch/arm.sh | 1 | ||||
-rw-r--r-- | scripts/build/arch/powerpc.sh | 4 | ||||
-rw-r--r-- | scripts/build/binutils/binutils.sh | 4 | ||||
-rw-r--r-- | scripts/build/companion_tools/100-m4.sh | 8 | ||||
-rw-r--r-- | scripts/build/debug/300-gdb.sh | 5 | ||||
-rw-r--r-- | scripts/build/libc/glibc.sh | 2 | ||||
-rw-r--r-- | scripts/build/libc/picolibc.sh | 111 | ||||
-rw-r--r-- | scripts/build/libc/uClibc.sh | 1 |
8 files changed, 131 insertions, 5 deletions
diff --git a/scripts/build/arch/arm.sh b/scripts/build/arch/arm.sh index 4873df1..9a53bc4 100644 --- a/scripts/build/arch/arm.sh +++ b/scripts/build/arch/arm.sh @@ -70,6 +70,7 @@ CT_DoArchUClibcConfig() { ;; thumb) CT_KconfigEnableOption "COMPILE_IN_THUMB_MODE" "${cfg}" + CT_KconfigDisableOption "UCLIBC_HAS_CONTEXT_FUNCS" "${cfg}" ;; esac # FIXME: CONFIG_ARM_OABI does not exist in neither uClibc/uClibc-ng diff --git a/scripts/build/arch/powerpc.sh b/scripts/build/arch/powerpc.sh index 36a727a..85c64d1 100644 --- a/scripts/build/arch/powerpc.sh +++ b/scripts/build/arch/powerpc.sh @@ -7,12 +7,12 @@ CT_DoArchTupleValues () { # Only override values when ABI is not the default case "${CT_ARCH_powerpc_ABI}" in eabi) - # EABI is only for bare-metal, so libc ∈ [none,newlib] + # EABI is only for bare-metal, so libc ∈ [none,newlib,picolibc] CT_TARGET_SYS="eabi" ;; spe) case "${CT_LIBC}" in - none|newlib) CT_TARGET_SYS="elfspe";; + none|newlib|picolibc) CT_TARGET_SYS="elfspe";; *glibc) CT_TARGET_SYS="gnuspe";; uClibc) CT_TARGET_SYS="uclibcgnuspe";; esac diff --git a/scripts/build/binutils/binutils.sh b/scripts/build/binutils/binutils.sh index a79bb7e..428a341 100644 --- a/scripts/build/binutils/binutils.sh +++ b/scripts/build/binutils/binutils.sh @@ -177,6 +177,10 @@ do_binutils_backend() { [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && extra_config+=("--disable-nls") + # Disable usage of glob for higher compatibility. + # Not strictly needed for anything but GDB anyways. + export ac_cv_func_glob=no + CT_DoLog DEBUG "Extra config passed: '${extra_config[*]}'" CT_DoExecLog CFG \ diff --git a/scripts/build/companion_tools/100-m4.sh b/scripts/build/companion_tools/100-m4.sh index 4bbe8d3..7d9044f 100644 --- a/scripts/build/companion_tools/100-m4.sh +++ b/scripts/build/companion_tools/100-m4.sh @@ -42,6 +42,7 @@ do_m4_backend() local prefix local cflags local ldflags + local libs for arg in "$@"; do eval "${arg// /\\ }" @@ -54,12 +55,19 @@ do_m4_backend() # it includes system <spawn.h> but expects a locally-built # posix_spawn(). ldflags="${ldflags} -lrt" + ;; + *-mingw32) + # m4 is built with stack smashing protection enabled which + # is not part of mingw-w64 c library in v7.0.0 and later. + libs="${libs} -lssp" + ;; esac CT_DoLog EXTRA "Configuring m4" CT_DoExecLog CFG \ CFLAGS="${cflags}" \ LDFLAGS="${ldflags}" \ + LIBS="${libs}" \ ${CONFIG_SHELL} \ "${CT_SRC_DIR}/m4/configure" \ --host="${host}" \ diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh index 9139331..b0ea29b 100644 --- a/scripts/build/debug/300-gdb.sh +++ b/scripts/build/debug/300-gdb.sh @@ -146,7 +146,7 @@ do_debug_gdb_build() cflags="${CT_ALL_TARGET_CFLAGS}" \ ldflags="${CT_ALL_TARGET_LDFLAGS}" \ static="${CT_GDB_NATIVE_STATIC}" \ - static_libstdc="${CT_GDB_NATIVE_STATIC_LIBSTDC}" \ + static_libstdcxx="${CT_GDB_NATIVE_STATIC_LIBSTDCXX}" \ prefix=/usr \ destdir="${CT_DEBUGROOT_DIR}" \ "${native_extra_config[@]}" @@ -236,7 +236,8 @@ do_gdb_backend() cflags+=" -static" ldflags+=" -static" fi - if [ "${static_libstdc}" = "y" ]; then + if [ "${static_libstdcxx}" = "y" ]; then + ldflags+=" -static-libgcc" ldflags+=" -static-libstdc++" fi diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh index 31fa067..ba6e548 100644 --- a/scripts/build/libc/glibc.sh +++ b/scripts/build/libc/glibc.sh @@ -314,6 +314,8 @@ glibc_backend_once() ;; esac + # Make sure glibc build system respects our provided CFLAGS. + extra_make_args+=( default_cflags= ) extra_make_args+=( "BUILD_CFLAGS=${build_cflags}" ) extra_make_args+=( "BUILD_CPPFLAGS=${build_cppflags}" ) extra_make_args+=( "BUILD_LDFLAGS=${build_ldflags}" ) diff --git a/scripts/build/libc/picolibc.sh b/scripts/build/libc/picolibc.sh new file mode 100644 index 0000000..152125c --- /dev/null +++ b/scripts/build/libc/picolibc.sh @@ -0,0 +1,111 @@ +# This file adds functions to build the Picolibc library +# Copyright © 2020 Keith Packard +# Licensed under the GPL v2 or later. See COPYING in the root of this package +# +# Edited by Keith Packard <keithp@keithp.com> +# + +picolibc_start_files() +{ + CT_DoStep INFO "Installing C library headers & start files" + CT_DoExecLog ALL cp -a "${CT_SRC_DIR}/picolibc/newlib/libc/include/." \ + "${CT_HEADERS_DIR}" + CT_EndStep +} + +picolibc_main() +{ + local -a picolibc_opts + local cflags_for_target + + CT_DoStep INFO "Installing C library" + + CT_mkdir_pushd "${CT_BUILD_DIR}/build-libc" + + CT_DoLog EXTRA "Configuring Picolibc library" + + # Multilib is the default, so if it is not enabled, disable it. + if [ "${CT_MULTILIB}" != "y" ]; then + picolibc_opts+=("-Dmultilib=false") + fi + + 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 + var="CT_LIBC_PICOLIBC_${ynarg%:*}" + eval var=\$${var} + argument=${ynarg#*:} + + + if [ "${var}" = "y" ]; then + picolibc_opts+=( "-D$argument=true" ) + else + picolibc_opts+=( "-D$argument=false" ) + fi + done + + [ "${CT_USE_SYSROOT}" = "y" ] && \ + picolibc_opts+=( "-Dsysroot-install=true" ) + + [ "${CT_LIBC_PICOLIBC_EXTRA_SECTIONS}" = "y" ] && \ + CT_LIBC_PICOLIBC_TARGET_CFLAGS="${CT_LIBC_PICOLIBC_TARGET_CFLAGS} -ffunction-sections -fdata-sections" + + [ "${CT_LIBC_PICOLIBC_LTO}" = "y" ] && \ + CT_LIBC_PICOLIBC_TARGET_CFLAGS="${CT_LIBC_PICOLIBC_TARGET_CFLAGS} -flto" + + cflags_for_target="${CT_ALL_TARGET_CFLAGS} ${CT_LIBC_PICOLIBC_TARGET_CFLAGS}" + + # Note: picolibc handles the build/host/target a little bit differently + # than one would expect: + # build : not used + # host : the machine building picolibc + # target : the machine picolibc runs on + meson_cflags="" + for cflag in ${cflags_for_target}; do + meson_cflags="${meson_cflags} '${cflag}'," + done + cat << EOF > picolibc-cross.txt +[binaries] +c = '${CT_TARGET}-gcc' +ar = '${CT_TARGET}-ar' +as = '${CT_TARGET}-as' +strip = '${CT_TARGET}-strip' + +[host_machine] +system = '${CT_TARGET_VENDOR}' +cpu_family = '${CT_TARGET_ARCH}' +cpu = '${CT_TARGET_ARCH}' +endian = '${CT_ARCH_ENDIAN}' + +[properties] +c_args = [ ${meson_cflags} '-nostdlib', '-fno-common', '-ftls-model=local-exec' ] +needs_exe_wrapper = true +skip_sanity_check = true +EOF + CT_DoExecLog CFG \ + meson \ + --cross-file picolibc-cross.txt \ + --prefix=${CT_SYSROOT_DIR} \ + -Dspecsdir=${CT_SYSROOT_DIR}/lib \ + "${CT_SRC_DIR}/picolibc" \ + "${picolibc_opts[@]}" \ + "${CT_LIBC_PICOLIBC_EXTRA_CONFIG_ARRAY[@]}" + + CT_DoLog EXTRA "Building C library" + CT_DoExecLog ALL ninja + + CT_DoLog EXTRA "Installing C library" + CT_DoExecLog ALL ninja install + + CT_Popd + CT_EndStep +} diff --git a/scripts/build/libc/uClibc.sh b/scripts/build/libc/uClibc.sh index 5c04b32..4328542 100644 --- a/scripts/build/libc/uClibc.sh +++ b/scripts/build/libc/uClibc.sh @@ -303,7 +303,6 @@ manage_uClibc_config() CT_KconfigEnableOption "UCLIBC_HAS_LOCALE" "${dst}" CT_KconfigDeleteOption "UCLIBC_PREGENERATED_LOCALE_DATA" "${dst}" CT_KconfigDeleteOption "UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA" "${dst}" - CT_KconfigDeleteOption "UCLIBC_HAS_XLOCALE" "${dst}" fi # WCHAR support |