Scripts and tools for building LLVM based toolchain. Forked from https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm
APACHE-2.0 License
This repository contains build scripts and auxiliary material for building a bare-metal LLVM based toolchain targeting Arm based on:
The goal is to provide an LLVM based bare-metal toolchain that can target the Arm architecture family from Armv6-M and newer. The toolchain follows the ABI for the Arm Architecture and attempts to provide typical features needed for embedded and realtime operating systems.
C++ is partially supported with the use of libc++ and libc++abi from LLVM. Features that are not supported include:
The LLVM Embedded Toolchain for Arm relies on the following upstream components
Component | Link |
---|---|
LLVM | https://github.com/llvm/llvm-project |
picolibc | https://github.com/picolibc/picolibc |
Content of this repository is licensed under Apache-2.0. See LICENSE.txt.
The resulting binaries are covered under their respective open source licenses, see component links above.
LLVM Embedded Toolchain for Arm is built and tested on Ubuntu 18.04 LTS.
The Windows version is built on Windows Server 2019 and lightly tested on Windows 10.
Building on macOS is functional for x86_64 and Apple Silicon.
Binary packages are provided for major LLVM releases for Linux and Windows.
Download a release of the toolchain for your platform from Github releases and extract the archive into an arbitrary directory.
On Ubuntu 20.04 and later libtinfo5
is required: apt install libtinfo5
.
(This requirement will be removed in LLVM Embedded Toolchain for Arm 17.)
On macOS the toolchain binaries are quarantined by com.apple.quarantine. To run the executables change directory to bin and run the following command to remove the com.apple.quarantine:
find . -type f -perm +0111 | xargs xattr -d com.apple.quarantine
To use the toolchain, on the command line you need to provide:
--config
, or a suitable set of command line options including thecrt0
library to use - see-T
.picolibcpp.ld
& picolibc.ld
scripts are provided and can be usedFor example:
$ PATH=<install-dir>/LLVMEmbeddedToolchainForArm-<revision>/bin:$PATH
$ clang --config armv6m_soft_nofp_semihost.cfg -T picolibc.ld -o example example.c
The available configuration files can be listed using:
$ ls <install-dir>/LLVMEmbeddedToolchainForArm-<revision>/bin/*.cfg
Note: If you are using the toolchain in a shared environment with untrusted input, make sure it is sufficiently sandboxed.
Instead of using a config file you can directly specify options. The following options are required:
crt0
library - either crt0
or crt0-semihost
crt0-semihost
.For example:
$ clang \
--target=armv6m-none-eabi \
-fno-exceptions \
-fno-rtti \
-lcrt0-semihost \
-lsemihost \
-T picolibc.ld \
-o example example.c
clang
's multilib system will automatically select an appropriate set of
libraries based on your compile flags. clang
will emit a warning if no
appropriate set of libraries can be found.
To display the directory selected by the multilib system, add the flag
-print-multi-directory
to your clang
command line options.
To display all available multilibs run clang
with the flag -print-multi-lib
and a target triple like --target=aarch64-none-elf
or --target=arm-none-eabi
.
It's possible that clang
will choose a set of libraries that are not the ones
you want to use. In this case you can bypass the multilib system by providing a
--sysroot
option specifying the directory containing the include
and lib
directories of the libraries you want to use. For example:
$ clang \
--sysroot=<install-dir>/LLVMEmbeddedToolchainForArm-<revision>/lib/clang-runtimes/arm-none-eabi/armv6m_soft_nofp \
--target=armv6m-none-eabi \
-fno-exceptions \
-fno-rtti \
-lcrt0-semihost \
-lsemihost \
-T picolibc.ld \
-o example example.c
LLVM Embedded Toolchain for Arm is an open source project and thus can be built from source. Please see the Building from source guide for detailed instructions.
Please raise an issue via Github issues.
Please see the Contribution Guide for details.