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: (), and fiddled around to build something that is partially working.
This is the command I am using:
-
git clone https://github.com/llvm/llvm-project.git llvm-v9
-
cd …
-
mkdir llvm-install && mkdir llvm-build && cd llvm-build
-
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/
-
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
() 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