diff mbox series

[meta-zephyr] zephyr-core/zephyr-kernel: specify newlib capability with cross-compile toolchain

Message ID PH0PR10MB700766691D9D809FDAB3B7BEF3A92@PH0PR10MB7007.namprd10.prod.outlook.com
State New
Headers show
Series [meta-zephyr] zephyr-core/zephyr-kernel: specify newlib capability with cross-compile toolchain | expand

Commit Message

Nicholas Lowell April 4, 2025, 7:09 p.m. UTC
Zephyr upstream reconfigurations now require either the CMake variable
TOOLCHAIN_HAS_NEWLIB or Kconfig NEWLIB_LIBC_SUPPORTED in order to build
with FULL_LIBC_SUPPORTED and NEWLIB.

This cross-compile toolchain does indeed have full newlib support available
so we need to now specify that so it can be used.

Signed-off-by: Nicholas Lowell <Nicholas.Lowell@lexmark.com>
---
 .../zephyr-kernel/zephyr-toolchain-cross-compile.inc             | 1 +
 1 file changed, 1 insertion(+)

--
2.43.0

Lexmark Confidential

Comments

Khem Raj April 5, 2025, 5:03 a.m. UTC | #1
On 4/4/25 12:09 PM, Nicholas Lowell via lists.yoctoproject.org wrote:
> Zephyr upstream reconfigurations now require either the CMake variable
> TOOLCHAIN_HAS_NEWLIB or Kconfig NEWLIB_LIBC_SUPPORTED in order to build
> with FULL_LIBC_SUPPORTED and NEWLIB.
> 
> This cross-compile toolchain does indeed have full newlib support available
> so we need to now specify that so it can be used.
> 
> Signed-off-by: Nicholas Lowell <Nicholas.Lowell@lexmark.com>
> ---
>   .../zephyr-kernel/zephyr-toolchain-cross-compile.inc             | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc
> index 2f1ea37..f26683e 100644
> --- a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc
> +++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc
> @@ -6,6 +6,7 @@ SYSROOT_DIR="${STAGING_DIR_TARGET}"
>   EXTRA_OECMAKE:append = " \
>       -DCROSS_COMPILE=${CROSS_COMPILE} \
>       -DSYSROOT_DIR=${SYSROOT_DIR} \
> +    -DTOOLCHAIN_HAS_NEWLIB=ON \

Even if we do have full C library, should this be part of kconfig ? or a 
packageconfig that is left for user to select ? does it impact the size 
of final ELF file if this selection is enabled via CMake

>       "
> 
>   OE_TERMINAL_EXPORTS += "CROSS_COMPILE"
> --
> 2.43.0
> 
> Lexmark Confidential
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#1283): https://lists.yoctoproject.org/g/yocto-patches/message/1283
> Mute This Topic: https://lists.yoctoproject.org/mt/112090624/1997914
> Group Owner: yocto-patches+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/yocto-patches/leave/13340786/1997914/645821814/xyzzy [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
> 
>
Nicholas Lowell April 7, 2025, 6:16 p.m. UTC | #2
If you look in zephyr source, in the cmake/toolchain folder, you will see that the TOOLCHAIN_HAS_NEWLIB cmake variable was set for each toolchain, either true or false, except for cross-compile.  By this convention, I would say any creation/use of a cross-compile toolchain, like the one created by meta-zephyr, should be setting this variable.  So really, it's a question of whether it should be true or false.  Since newlib is available to be used, then we must set the variable to true.  Otherwise, it's not possible to build with newlib--there will be compile errors.  TOOLCHAIN_HAS_NEWLIB is just a gatekeeper for whether newlib can be used to build or not.

As to your question about size, zephyr-philosophers saw a 42 byte increase in ELF file size.  This is most likely from the added #define CONFIG_NEWLIB_LIBC_SUPPORTED 1 in autoconf.h, which should be there and is, again, required in order for CONFIG_NEWLIB_LIBC=y, when desired.
diff mbox series

Patch

diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc
index 2f1ea37..f26683e 100644
--- a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc
+++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-toolchain-cross-compile.inc
@@ -6,6 +6,7 @@  SYSROOT_DIR="${STAGING_DIR_TARGET}"
 EXTRA_OECMAKE:append = " \
     -DCROSS_COMPILE=${CROSS_COMPILE} \
     -DSYSROOT_DIR=${SYSROOT_DIR} \
+    -DTOOLCHAIN_HAS_NEWLIB=ON \
     "

 OE_TERMINAL_EXPORTS += "CROSS_COMPILE"