LLVM Embedded Toolchain for Arm uses picolibc
as the standard C library. For compatibility with existing projects using
newlib
, a separate package of newlib
-based
library variants is provided.
NOTE:
newlib
support in LLVM Embedded Toolchain for Arm is experimental and may change in following releases.
-
Install LLVM Embedded Toolchain for Arm
-
Download corresponding
LLVM-ET-Arm-newlib-overlay
package and extract it on top of the main toolchain folder.- Note: The overlay package copies all the
newlib
library variants into thelib/clang-runtimes/newlib
subdirectory, so that they do not collide with thepicolibc
variants inlib/clang-runtimes
. It also adds thenewlib.cfg
into thebin
directory, which switches the--sysroot
to thenewlib
subdirectory above.
- Note: The overlay package copies all the
-
Add the
newlib.cfg
config file to the command line to usenewlib
library variants instead ofpicolibc
. -
Add
-lrdimon
and-lcrt0-rdimon
to the command line to use semihosting or-lnosys
and-lcrt0-nosys
otherwise. -
You may use the provided default linker script by adding
-T redboot.ld
to the command line.
Example:
$ clang --config=newlib.cfg --target=arm-none-eabi -march=armv7m -T redboot.ld -lrdimon -lcrt0-rdimon -o hello hello.c
NOTE: Building
newlib
package is only supported on Linux and macOS.
Configure the toolchain with the CMake setting
-DLLVM_TOOLCHAIN_C_LIBRARY=newlib
to build a newlib-based version of
the toolchain.
If you also add -DLLVM_TOOLCHAIN_LIBRARY_OVERLAY_INSTALL=on
then the
package-llvm-toolchain
CMake target will generate the newlib
overlay package.
Note that the -DLLVM_TOOLCHAIN_LIBRARY_OVERLAY_INSTALL=on
option
only generates the newlib
package, but does not install it as part
of the install
CMake target.