diff --git a/configs/arc.config b/configs/arc.config index 4e13eb01..b08f0642 100644 --- a/configs/arc.config +++ b/configs/arc.config @@ -19,6 +19,7 @@ CT_LIBC_NEWLIB_LITE_EXIT=y # CT_LIBC_NEWLIB_WIDE_ORIENT is not set CT_LIBC_NEWLIB_NANO_MALLOC=y CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y +CT_LIBC_NEWLIB_NANO_SPEC=y CT_CC_GCC_EXTRA_CONFIG_ARRAY="--with-gnu-ld --with-gnu-as --enable-initfini-array" CT_CC_LANG_CXX=y CT_DEBUG_GDB=y diff --git a/configs/arm.config b/configs/arm.config index 9b77df54..42dee92d 100644 --- a/configs/arm.config +++ b/configs/arm.config @@ -19,6 +19,7 @@ CT_LIBC_NEWLIB_LITE_EXIT=y # CT_LIBC_NEWLIB_WIDE_ORIENT is not set CT_LIBC_NEWLIB_NANO_MALLOC=y CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y +CT_LIBC_NEWLIB_NANO_SPEC=y CT_CC_GCC_EXTRA_CONFIG_ARRAY="--with-gnu-ld --with-gnu-as --enable-initfini-array" CT_CC_GCC_MULTILIB_LIST="rmprofile" CT_CC_LANG_CXX=y diff --git a/configs/i586.config b/configs/i586.config index 330a3809..9afb463c 100644 --- a/configs/i586.config +++ b/configs/i586.config @@ -20,6 +20,7 @@ CT_LIBC_NEWLIB_LITE_EXIT=y # CT_LIBC_NEWLIB_WIDE_ORIENT is not set CT_LIBC_NEWLIB_NANO_MALLOC=y CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y +CT_LIBC_NEWLIB_NANO_SPEC=y CT_CC_GCC_EXTRA_CONFIG_ARRAY="--with-gnu-ld --with-gnu-as --enable-initfini-array" CT_CC_LANG_CXX=y CT_DEBUG_GDB=y diff --git a/configs/iamcu.config b/configs/iamcu.config index 09d00079..ddd53a39 100644 --- a/configs/iamcu.config +++ b/configs/iamcu.config @@ -20,6 +20,7 @@ CT_LIBC_NEWLIB_LITE_EXIT=y # CT_LIBC_NEWLIB_WIDE_ORIENT is not set CT_LIBC_NEWLIB_NANO_MALLOC=y CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y +CT_LIBC_NEWLIB_NANO_SPEC=y CT_CC_GCC_EXTRA_CONFIG_ARRAY="--with-gnu-ld --with-gnu-as --enable-initfini-array" CT_CC_LANG_CXX=y CT_DEBUG_GDB=y diff --git a/configs/mips.config b/configs/mips.config index 60afa871..8afbd28e 100644 --- a/configs/mips.config +++ b/configs/mips.config @@ -18,6 +18,7 @@ CT_LIBC_NEWLIB_LITE_EXIT=y # CT_LIBC_NEWLIB_WIDE_ORIENT is not set CT_LIBC_NEWLIB_NANO_MALLOC=y CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y +CT_LIBC_NEWLIB_NANO_SPEC=y CT_CC_GCC_EXTRA_CONFIG_ARRAY="--with-gnu-ld --with-gnu-as --enable-initfini-array" CT_CC_LANG_CXX=y CT_DEBUG_GDB=y diff --git a/configs/nios2.config b/configs/nios2.config index 6e1fba49..60a63723 100644 --- a/configs/nios2.config +++ b/configs/nios2.config @@ -19,6 +19,7 @@ CT_LIBC_NEWLIB_LITE_EXIT=y # CT_LIBC_NEWLIB_WIDE_ORIENT is not set CT_LIBC_NEWLIB_NANO_MALLOC=y CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y +CT_LIBC_NEWLIB_NANO_SPEC=y CT_CC_GCC_EXTRA_CONFIG_ARRAY="--with-gnu-ld --with-gnu-as --enable-initfini-array" CT_CC_LANG_CXX=y CT_DEBUG_GDB=y diff --git a/configs/riscv64.config b/configs/riscv64.config index 26d75e92..d808c71e 100644 --- a/configs/riscv64.config +++ b/configs/riscv64.config @@ -22,6 +22,7 @@ CT_LIBC_NEWLIB_LITE_EXIT=y # CT_LIBC_NEWLIB_WIDE_ORIENT is not set CT_LIBC_NEWLIB_NANO_MALLOC=y CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y +CT_LIBC_NEWLIB_NANO_SPEC=y CT_CC_GCC_EXTRA_CONFIG_ARRAY="--with-gnu-ld --with-gnu-as --enable-initfini-array" CT_CC_LANG_CXX=y CT_DEBUG_GDB=y diff --git a/configs/x86_64-zephyr-elf.config b/configs/x86_64-zephyr-elf.config index 88c112c0..23e45654 100644 --- a/configs/x86_64-zephyr-elf.config +++ b/configs/x86_64-zephyr-elf.config @@ -18,6 +18,7 @@ CT_LIBC_NEWLIB_LITE_EXIT=y # CT_LIBC_NEWLIB_WIDE_ORIENT is not set CT_LIBC_NEWLIB_NANO_MALLOC=y CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y +CT_LIBC_NEWLIB_NANO_SPEC=y CT_CC_GCC_EXTRA_CONFIG_ARRAY="--with-gnu-ld --with-gnu-as --enable-initfini-array --with-cpu-32=i586 --with-arch-32=i586 --with-cpu-64=generic --with-arch-64=x86-64" # CT_CC_GCC_LIBMPX is not set CT_CC_LANG_CXX=y diff --git a/configs/xtensa_sample_controller.config b/configs/xtensa_sample_controller.config index 1a5b5155..26a03dda 100644 --- a/configs/xtensa_sample_controller.config +++ b/configs/xtensa_sample_controller.config @@ -24,6 +24,7 @@ CT_LIBC_NEWLIB_LITE_EXIT=y # CT_LIBC_NEWLIB_WIDE_ORIENT is not set CT_LIBC_NEWLIB_NANO_MALLOC=y CT_LIBC_NEWLIB_NANO_FORMATTED_IO=y +CT_LIBC_NEWLIB_NANO_SPEC=y CT_CC_GCC_EXTRA_CONFIG_ARRAY="--with-gnu-ld --with-gnu-as --enable-initfini-array" CT_CC_LANG_CXX=y CT_DEBUG_GDB=y diff --git a/go.sh b/go.sh index 0118d074..b9dc10a7 100755 --- a/go.sh +++ b/go.sh @@ -54,6 +54,7 @@ if [ ! -d "crosstool-ng" ]; then echo "Patching tree" pushd crosstool-ng git checkout ${COMMIT} + patch -p1 < ${GITDIR}/patches/0001-Add-config-option-to-setup-files-according-to-nano.s.patch popd fi diff --git a/patches/0001-Add-config-option-to-setup-files-according-to-nano.s.patch b/patches/0001-Add-config-option-to-setup-files-according-to-nano.s.patch new file mode 100644 index 00000000..76ffaeb1 --- /dev/null +++ b/patches/0001-Add-config-option-to-setup-files-according-to-nano.s.patch @@ -0,0 +1,90 @@ +From 4b07cb34a3f292c78f63069dcfe63f0e57195b9f Mon Sep 17 00:00:00 2001 +From: Kumar Gala +Date: Tue, 27 Aug 2019 08:55:41 -0500 +Subject: [PATCH] Add config option to setup files according to nano.spec + +Introduce config option LIBC_NEWLIB_NANO_SPEC that will have the build +setup file layout as aspected by nano.spec. This renames +lib{c,g,rdimon,stdc++,supc++}.a -> lib{c,g,rdimon,stdc++,supc++}_nano.a. +It also installs newlib.h in newlib-nano/newlib.h + +Signed-off-by: Kumar Gala +--- + config/libc/newlib.in | 9 +++++++++ + scripts/build/libc/newlib.sh | 36 ++++++++++++++++++++++++++++++++++++ + 2 files changed, 45 insertions(+) + +diff --git a/config/libc/newlib.in b/config/libc/newlib.in +index 268f9564..29dd5149 100644 +--- a/config/libc/newlib.in ++++ b/config/libc/newlib.in +@@ -209,6 +209,15 @@ config LIBC_NEWLIB_NANO_FORMATTED_IO + with size constraint issues. This option does not affect wide-char + formatted I/O functions. + ++config LIBC_NEWLIB_NANO_SPEC ++ bool ++ prompt "Enable Nano SPEC layout" ++ depends on LIBC_NEWLIB_NANO_MALLOC || LIBC_NEWLIB_NANO_FORMATTED_IO ++ help ++ Layout files according to what the nano.spec file expects. This renames ++ lib{c,g,rdimon,stdc++,supc++}.a to have a nano postfix (ie libc_nano.a). ++ Also moves newlib.h to newlib-nano/newlib.h. ++ + config LIBC_NEWLIB_EXTRA_CONFIG_ARRAY + string + prompt "Extra config for newlib" +diff --git a/scripts/build/libc/newlib.sh b/scripts/build/libc/newlib.sh +index 95ab7910..e12adde5 100644 +--- a/scripts/build/libc/newlib.sh ++++ b/scripts/build/libc/newlib.sh +@@ -5,6 +5,30 @@ + # Edited by Martin Lund + # + ++newlib_nano_movelibs() ++{ ++ local multi_flags multi_dir multi_os_dir multi_os_dir_gcc multi_root multi_index multi_count ++ ++ for arg in "$@"; do ++ eval "${arg// /\\ }" ++ done ++ ++ CT_DoExecLog ALL mv "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/libc.a" \ ++ "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/libc_nano.a" ++ CT_DoExecLog ALL mv "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/libg.a" \ ++ "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/libg_nano.a" ++ if [ -f ${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/librdimon.a ]; then ++ CT_DoExecLog ALL mv "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/librdimon.a" \ ++ "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/librdimon_nano.a" ++ fi ++ if [ "${CT_CC_GCC_STATIC_LIBSTDCXX}" = "y" ]; then ++ CT_DoExecLog ALL mv "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/libstdc++.a" \ ++ "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/libstdc++_nano.a" ++ CT_DoExecLog ALL mv "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/libsupc++.a" \ ++ "${CT_PREFIX_DIR}/${CT_TARGET}/lib/${multi_dir}/libsupc++_nano.a" ++ fi ++} ++ + newlib_start_files() + { + CT_DoStep INFO "Installing C library headers & start files" +@@ -131,3 +155,15 @@ ENABLE_TARGET_OPTSPACE:target-optspace + CT_Popd + CT_EndStep + } ++ ++newlib_post_cc() ++{ ++ if [ "${CT_LIBC_NEWLIB_NANO_SPEC}" = "y" ]; then ++ CT_DoLog EXTRA "Move files to match nano.spec layout" ++ CT_IterateMultilibs newlib_nano_movelibs newlib_nano_libs ++ ++ CT_DoExecLog ALL mkdir -p "${CT_PREFIX_DIR}/${CT_TARGET}/include/newlib-nano" ++ CT_DoExecLog ALL mv "${CT_PREFIX_DIR}/${CT_TARGET}/include/newlib.h" \ ++ "${CT_PREFIX_DIR}/${CT_TARGET}/include/newlib-nano" ++ fi ++} +-- +2.20.1 +