[llvm-dev] Cross compilation to ARM bare metal is not working
kiwan maeng via llvm-dev
llvm-dev at lists.llvm.org
Thu Oct 10 15:19:09 PDT 2019
I am trying to build an LLVM toolchain so that it can cross-compile code
to my ARMv7EM-based STM32F7 chip (I want to compile the code on an x86
machine and run it on ARM).
However, a lot of the documents in the web is outdated, pointing to
different versions of LLVM (with a different folder structure!) and I am
not skilled enough to deduce a right way to build with the scattered
information.
I am mainly looking into this:
(https://llvm.org/docs/HowToCrossCompileLLVM.html), and fiddled around
to build something that is partially working.
This is the command I am using:
1.
git clone https://github.com/llvm/llvm-project.gitllvm-v9
2.
cd ..
3.
mkdir llvm-install && mkdir llvm-build && cd llvm-build
4.
cmake -G "Unix Makefiles" -DCMAKE_CROSSCOMPILING=True
-DLLVM_OPTIMIZED_TABLEGEN=1 -DCMAKE_BUILD_TYPE=Release
-DLLVM_TARGETS_TO_BUILD=ARM -DLLVM_TARGET_ARCH=ARMV7EM
-DLLVM_DEFAULT_TARGET_TRIPLE=armv7em-none-eabihf
-DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi;compiler-rt;lld;polly"
-DLLVM_BUILD_EXTERNAL_COMPILER_RT=On -DCMAKE_LINKER=/usr/bin/ld.gold
-DCMAKE_INSTALL_PREFIX=../llvm-install/ ../llvm-v9/llvm/
5. make && make install
It compiles, and if I try to compile C code using the compiled clang, it
complains about not having clang_rt on the linking stage (it generates
up to assembly file).
I think it is weird that clang_rt is not there because I enable
compiler-rt as you can see; anyways, I tried to separately compile
clang_rt by looking at
(https://llvm.org/docs/HowToCrossCompileBuiltinsOnArm.html) but it
wasn't successful.
I spent weeks trying out different flag options (some won't even
compile), or using a gcc-arm-none-eabi linker at the last stage, etc.,
but with no luck.
Can anyone guide me to a more concrete example of how to compile LLVM
for ARM cross-compilation, or help me out with what is wrong with the
cmake options I am using?
Alternatively, I just tried downloading clang from apt-get install, but
that again complained about not having clang_rt.
I would not mind using a lower version of LLVM if that is easier.
Any help or insight would be highly appreciated!
Also, kindly let me know if this is a wrong thread to post. I am new, as
you can see.
Thank you,
Best Regards,
Kiwan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191010/3a0a8bf8/attachment.html>
More information about the llvm-dev
mailing list