How do I cross-compile compiler-rt for ARM-Linux with CMake?
Given a directory with sub-directories named 'llvm', 'compiler-rt',
and 'release' (which is a clang build directory), this build succeeds:
$ mkdir -p release-rt
$ cd release-rt
$ cmake ../llvm -G Ninja \
-DCMAKE_INSTALL_PREFIX=ship \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_TARGETS_TO_BUILD=ARM \
-DLLVM_DEFAULT_TARGET_TRIPLE=arm-none-linux-gnueabi \
-DLLVM_TARGET_ARCH=arm-none-linux-gnueabi \
-DCMAKE_C_COMPILER=`which arm-none-linux-gnueabi-gcc` \
-DCMAKE_CXX_COMPILER=`which arm-none-linux-gnueabi-g++` \
-DLLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR=../compiler-rt \
-DCMAKE_CROSSCOMPILING=True \
-DLLVM_TABLEGEN=`pwd`/../release/ship/bin/llvm-tblgen
$ ninja install
As a sanity-check, I was expecting to see a 'lib' directory for the
sanitizers in 'lib/clang/3.5', but there's only an 'include'
directory.
For Android, I've used the toolchain file in llvm/cmake, but for
ARM-Linux I'm attempting a variation of the cross-compiled clang
build:
http://llvm.org/docs/HowToCrossCompileLLVM.html
Are there compiler-rt-specific instructions somewhere?
Thanks,
Greg
Not that I know of, and I always build compiler-rt natively, together with
Clang and LLVM.
Would be great if you could write one, though.
cheers,
--renato
Not that I know of, and I always build compiler-rt natively, together with Clang and LLVM.
Do you mean "natively on ARM" or "natively on X86 with the ARM target enabled"?
If the former, do you have a script to merge the target libs into the
host's install directory? If the latter, that'll only build the X86
versions of the compiler-rt libraries.
Would be great if you could write one, though.
if only I knew what content to add
-Greg
Natively on ARM, and I didn't try to "use" them, just building to test my
changes. (and that was a looong time ago).
Though, I should start using them for real...
cheers,
--renato
Not that I know of, and I always build compiler-rt natively, together with Clang and LLVM.
Do you mean "natively on ARM" or "natively on X86 with the ARM target enabled"?
If the former, do you have a script to merge the target libs into the
host's install directory? If the latter, that'll only build the X86
versions of the compiler-rt libraries.
There are simply no CMake build rules for building compiler-rt
libraries targeting ARM (see compiler-rt/lib/CMakeLists.txt).
I may have used configure, I don't really remember... But that was years
ago, so nothing relevant right now.
--renato
Hi Alexey,
I've added the ARM files on that CMake file but I got nothing compiled on
ARM. Am I missing something?
About the sanitizers, is there anyone that is known to work on ARM? If not,
I should disable all tests on ARM for all sanitizers.
cheers,
--renato
Hi Renato,
There are simply no CMake build rules for building compiler-rt
libraries targeting ARM (see compiler-rt/lib/CMakeLists.txt).
Hi Alexey,
I've added the ARM files on that CMake file but I got nothing compiled on
ARM. Am I missing something?
DId you do this locally? I can't see a commit. I think that to add
support for compiler-rt on ARM you need to:
1) Specify arm_SOURCES and add "arm" to this loop in
compiler-rt/lib/CMakeLists.txt
foreach(arch x86_64 i386)
if(CAN_TARGET_${arch})
add_compiler_rt_static_runtime(clang_rt.${arch} ${arch}
SOURCES ${${arch}_SOURCES}
CFLAGS "-std=c99")
endif()
endforeach()
2) Make sure CAN_TARGET_arm is properly defined in
compiler-rt/CMakeLists.txt. See test_target_arch function
and places where it's called. Note that at the moment the CMake build
uses host compiler (not just-built Clang) to
build compiler-rt libraries, so building compiler-rt targeting arm on
x86_64 host might be a problem.
About the sanitizers, is there anyone that is known to work on ARM? If not,
I should disable all tests on ARM for all sanitizers.
We run AddressSanitizer tests on arm-android. Probably it should work
fine on ARM+Linux, but we don't have a buildbot
or continuous testing for that (and you'd have to add support for
building sanitizers on ARM Linux in a similar way).
DId you do this locally? I can't see a commit.
Locally, yes.
1) Specify arm_SOURCES and add "arm" to this loop in
I did this...
2) Make sure CAN_TARGET_arm is properly defined in
compiler-rt/CMakeLists.txt. See test_target_arch function
and places where it's called.
But not this... Ok, I can now see errors in the cmake invocation, which
hints me I'm in the right direction.
Note that at the moment the CMake build
uses host compiler (not just-built Clang) to
build compiler-rt libraries, so building compiler-rt targeting arm on
x86_64 host might be a problem.
Right, I'll keep that in mind when I get there, thanks!
We run AddressSanitizer tests on arm-android. Probably it should work
fine on ARM+Linux, but we don't have a buildbot
or continuous testing for that (and you'd have to add support for
building sanitizers on ARM Linux in a similar way).
My end goal is to have a buildbot with both compiler-rt and
libc++/libc++abi for ARM+Linux, but that might not come until much later.
Thanks for the references, I'll keep breaking it until it works.
cheers,
--renato