From 26590a0f6bd82d491a820e7f965096f1ea9b9564 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 10 Oct 2024 14:49:13 -0700 Subject: [PATCH 1/5] picolibc: Enable dual-mode picolibc builds This provides both minsize and release versions of picolibc in the SDK, allowing users to select between them while building their application. Signed-off-by: Keith Packard --- cmake/zephyr/generic.cmake | 1 + configs/common.config | 1 + contrib/linux_build_toolchain.sh | 0 crosstool-ng | 2 +- 4 files changed, 3 insertions(+), 1 deletion(-) mode change 100644 => 100755 contrib/linux_build_toolchain.sh diff --git a/cmake/zephyr/generic.cmake b/cmake/zephyr/generic.cmake index 2c914d8e..f76d5c9d 100644 --- a/cmake/zephyr/generic.cmake +++ b/cmake/zephyr/generic.cmake @@ -31,3 +31,4 @@ set(CROSS_COMPILE ${one_toolchain_root}/${CROSS_COMPILE_TARGET}/bin/${CROSS_COMP set(SYSROOT_DIR ${one_toolchain_root}/${SYSROOT_TARGET}/${SYSROOT_TARGET}) set(TOOLCHAIN_HAS_NEWLIB ON CACHE BOOL "True if toolchain supports newlib") set(TOOLCHAIN_HAS_PICOLIBC ON CACHE BOOL "True if toolchain supports picolibc") +set(TOOLCHAIN_HAS_PICOLIBC_DUAL ON CACHE BOOL "True if toolchain supports --picolibc-buildtype=release") diff --git a/configs/common.config b/configs/common.config index 9c317655..093101da 100644 --- a/configs/common.config +++ b/configs/common.config @@ -71,5 +71,6 @@ CT_COMP_LIBS_PICOLIBC=y CT_PICOLIBC_SRC_CUSTOM=y CT_PICOLIBC_CUSTOM_LOCATION="${GITHUB_WORKSPACE}/picolibc" CT_LIBC_PICOLIBC_GLOBAL_ATEXIT=y +CT_LIBC_PICOLIBC_ENABLE_TARGET_OPTBOTH=y CT_LIBC_PICOLIBC_EXTRA_SECTIONS=y CT_LIBC_PICOLIBC_EXTRA_CONFIG_ARRAY="-Dthread-local-storage=auto -Derrno-function=zephyr -Dsysroot-install=true -Dsysroot-install-skip-checks=true -Dassert-verbose=false" diff --git a/contrib/linux_build_toolchain.sh b/contrib/linux_build_toolchain.sh old mode 100644 new mode 100755 diff --git a/crosstool-ng b/crosstool-ng index 53b5327d..9f07f91c 160000 --- a/crosstool-ng +++ b/crosstool-ng @@ -1 +1 @@ -Subproject commit 53b5327d821a6b6949fa455f14a9631146af897c +Subproject commit 9f07f91c99cce5a0f2ff37986788f57360a9730d From 6fcbb43d61c5565a279cebb1d1f734b01529d5b5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 11 Oct 2024 00:52:00 -0700 Subject: [PATCH 2/5] picolibc: Pull in ARC release build fix In release builds, several targets would get both asm and C versions of strchr included, which is a fatal picolibc build error. Pull in the fix for that. Signed-off-by: Keith Packard --- contrib/linux_build_toolchain.sh | 2 +- picolibc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/linux_build_toolchain.sh b/contrib/linux_build_toolchain.sh index d8fdeacf..386014a2 100755 --- a/contrib/linux_build_toolchain.sh +++ b/contrib/linux_build_toolchain.sh @@ -119,7 +119,7 @@ CT_LOG_EXTRA=y CT_LOG_LEVEL_MAX="EXTRA" CT_GDB_CROSS_PYTHON=y CT_GDB_CROSS_PYTHON_VARIANT=y -CT_GDB_CROSS_PYTHON_BINARY="python3.10" +CT_GDB_CROSS_PYTHON_BINARY="python3.12" CT_EXPERIMENTAL=y CT_ALLOW_BUILD_AS_ROOT=y CT_ALLOW_BUILD_AS_ROOT_SURE=y diff --git a/picolibc b/picolibc index 21d8fed7..5a0c482e 160000 --- a/picolibc +++ b/picolibc @@ -1 +1 @@ -Subproject commit 21d8fed73c34bfaf406ebedab2db46474baa1f20 +Subproject commit 5a0c482eb59c72dadae52eff54c867d2b3a02b7b From 0724f43e62c9e8ede06febb7907be854c3fa48dd Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 11 Oct 2024 22:22:54 -0700 Subject: [PATCH 3/5] gcc: Include patch to make picolibc dual mode work gcc's spec file processing had a bug where it would truncate the 'release' paths when using a 'sysroot' style install (which uses getenv in spec files). Signed-off-by: Keith Packard --- gcc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc b/gcc index 428d8d7b..5de43199 160000 --- a/gcc +++ b/gcc @@ -1 +1 @@ -Subproject commit 428d8d7b0542338244ca41ac06a5f3fa4f29bb6d +Subproject commit 5de43199689bfea88d99fb580a12d88958556824 From be4757d4034f12bf9730f9c806c9538ea07751c2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 12 Oct 2024 13:20:15 -0700 Subject: [PATCH 4/5] picolibc: Add crt0 path fix Not strictly necessary for Zephyr which doesn't use this for linking, but still nice to have a working toolchain anyways. Signed-off-by: Keith Packard --- picolibc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/picolibc b/picolibc index 5a0c482e..15aa9b23 160000 --- a/picolibc +++ b/picolibc @@ -1 +1 @@ -Subproject commit 5a0c482eb59c72dadae52eff54c867d2b3a02b7b +Subproject commit 15aa9b23074324b69fd1fe2f6ca1713c8cc4696e From f1db2e216fe7c7cd99e87f99b1b20a8240a57552 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 12 Oct 2024 13:21:11 -0700 Subject: [PATCH 5/5] contrib: Show actual default build dir in linux_build_toolchain.sh Need to use BUILD_DIR instead of WORKSPACE as the latter hasn't been set at this point. Signed-off-by: Keith Packard --- contrib/linux_build_toolchain.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/linux_build_toolchain.sh b/contrib/linux_build_toolchain.sh index 386014a2..d4a11395 100755 --- a/contrib/linux_build_toolchain.sh +++ b/contrib/linux_build_toolchain.sh @@ -21,7 +21,7 @@ function usage() echo " Default is ${SDK_DIR}" echo "" echo " -o Build directory, for building artifacts and final output. Optional." - echo " Default is ${WORKSPACE}" + echo " Default is ${BUILD_DIR}" echo "" echo " -h This help." echo ""