Anthony Merlino via llvm-dev
2021-Jan-15 17:51 UTC
[llvm-dev] Cross Compiling Runtime Libraries with Freestanding Toolchain
Hello everyone,
So here's my situation - I am running an RTOS on an embedded system with an
ARM Cortex M7. I have a freestanding GCC toolchain built for this target.
What I would like to do is cross-compile LLVM to produce only the static
runtime libraries: libcxxabi, libcxx, compiler-rt, and libunwind using that
toolchain.
Here is my attempt to configure LLVM to get what I want:
```
#!/bin/bash
mkdir build-arm
cd build-arm
cmake -DCMAKE_TOOLCHAIN_FILE=../arm-toolchain.cmake \
-DCMAKE_CROSSCOMPILING=True \
-DCMAKE_INSTALL_PREFIX=output \
-DLLVM_TABLEGEN=../build-host/bin/llvm-tblgen \
-DCLANG_TABLEGEN=../build-host/bin/clang-tblgen \
-DLLVM_DEFAULT_TARGET_TRIPLE=arm-none-eabi \
-DLLVM_TARGET_ARCH=ARM \
-DLLVM_TARGETS_TO_BUILD=ARM \
-DLLVM_BUILD_STATIC=True \
-DLLVM_ENABLE_PROJECTS="compiler-rt;libcxx;libcxxabi;libunwind"
../llvm
```
However, this results in the following error:
```
CMake Error at cmake/modules/CheckAtomic.cmake:56 (message):
Host compiler must support std::atomic!
Call Stack (most recent call first):
cmake/config-ix.cmake:364 (include)
CMakeLists.txt:681 (include)
```
Is what I'm trying to do supported? Could someone help me chip away at
this? I'm really trying to get a full LLVM stack running on this thing!
Any help would be appreciated!
Best,
Anthony
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20210115/78a55c21/attachment.html>
Peter Smith via llvm-dev
2021-Jan-15 18:27 UTC
[llvm-dev] Cross Compiling Runtime Libraries with Freestanding Toolchain
Hello Anthony,
In my experience I've had most success with building the static runtime
libraries standalone, i.e. building each library one at a time by pointing cmake
at the directory rather than using the integrated build in the top level llvm
dir. In my case I do:
compiler-rt built-ins (limited support for sanitizers on a Cortex-M7)
libunwind
libcxxabi
libcxx
Any remaining components of compiler-rt.
There have been posts on llvm-dev about cross-compiling for Arm, hopefully
others may be able to share their experiences as well.
Apologies not got a lot of time left today, have to leave the virtual office.
Arm does have a recipe for building a LLVM toolchain (initially targeting
cortex-m0), this is likely doing both more and less than you want, but it may be
possible to get some ideas from it
https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/
Peter
________________________________________
From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Anthony
Merlino via llvm-dev <llvm-dev at lists.llvm.org>
Sent: 15 January 2021 17:51
To: llvm-dev at lists.llvm.org
Subject: [llvm-dev] Cross Compiling Runtime Libraries with Freestanding
Toolchain
Hello everyone,
So here's my situation - I am running an RTOS on an embedded system with an
ARM Cortex M7. I have a freestanding GCC toolchain built for this target. What
I would like to do is cross-compile LLVM to produce only the static runtime
libraries: libcxxabi, libcxx, compiler-rt, and libunwind using that toolchain.
Here is my attempt to configure LLVM to get what I want:
```
#!/bin/bash
mkdir build-arm
cd build-arm
cmake -DCMAKE_TOOLCHAIN_FILE=../arm-toolchain.cmake \
-DCMAKE_CROSSCOMPILING=True \
-DCMAKE_INSTALL_PREFIX=output \
-DLLVM_TABLEGEN=../build-host/bin/llvm-tblgen \
-DCLANG_TABLEGEN=../build-host/bin/clang-tblgen \
-DLLVM_DEFAULT_TARGET_TRIPLE=arm-none-eabi \
-DLLVM_TARGET_ARCH=ARM \
-DLLVM_TARGETS_TO_BUILD=ARM \
-DLLVM_BUILD_STATIC=True \
-DLLVM_ENABLE_PROJECTS="compiler-rt;libcxx;libcxxabi;libunwind"
../llvm
```
However, this results in the following error:
```
CMake Error at cmake/modules/CheckAtomic.cmake:56 (message):
Host compiler must support std::atomic!
Call Stack (most recent call first):
cmake/config-ix.cmake:364 (include)
CMakeLists.txt:681 (include)
```
Is what I'm trying to do supported? Could someone help me chip away at this?
I'm really trying to get a full LLVM stack running on this thing!
Any help would be appreciated!
Best,
Anthony