[LLVMdev] compiler-rt for ARM-Linux with CMake?

653 views
Skip to first unread message

Greg Fitzgerald

unread,
Dec 17, 2013, 5:09:19 PM12/17/13
to llvmdev@cs.uiuc.edu List
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
_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Renato Golin

unread,
Dec 17, 2013, 5:22:07 PM12/17/13
to Greg Fitzgerald, llvmdev@cs.uiuc.edu List
On 17 December 2013 22:09, Greg Fitzgerald <gar...@gmail.com> wrote:
http://llvm.org/docs/HowToCrossCompileLLVM.html

Are there compiler-rt-specific instructions somewhere?

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

Greg Fitzgerald

unread,
Dec 17, 2013, 5:30:09 PM12/17/13
to Renato Golin, llvmdev@cs.uiuc.edu List
> 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

Renato Golin

unread,
Dec 17, 2013, 5:38:35 PM12/17/13
to Greg Fitzgerald, llvmdev@cs.uiuc.edu List
On 17 December 2013 22:30, Greg Fitzgerald <gar...@gmail.com> wrote:
Do you mean "natively on ARM" or "natively on X86 with the ARM target enabled"?

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

Alexey Samsonov

unread,
Dec 20, 2013, 5:43:36 AM12/20/13
to Greg Fitzgerald, llvmdev@cs.uiuc.edu List
On Wed, Dec 18, 2013 at 2:30 AM, Greg Fitzgerald <gar...@gmail.com> wrote:
>> 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).

>
>
>> Would be great if you could write one, though. ;)
>
> if only I knew what content to add :)
>
> -Greg
>
>
> On Tue, Dec 17, 2013 at 2:22 PM, Renato Golin <renato...@linaro.org> wrote:
>> On 17 December 2013 22:09, Greg Fitzgerald <gar...@gmail.com> wrote:
>>>
>>> http://llvm.org/docs/HowToCrossCompileLLVM.html
>>>
>>> Are there compiler-rt-specific instructions somewhere?
>>
>>
>> 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
> _______________________________________________
> LLVM Developers mailing list
> LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



--
Alexey Samsonov, MSK

Renato Golin

unread,
Dec 20, 2013, 5:49:18 AM12/20/13
to Alexey Samsonov, llvmdev@cs.uiuc.edu List
On 20 December 2013 10:43, Alexey Samsonov <sams...@google.com> wrote:
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

Renato Golin

unread,
Jan 22, 2014, 12:06:59 PM1/22/14
to Alexey Samsonov, llvmdev@cs.uiuc.edu List
On 20 December 2013 10:43, Alexey Samsonov <sams...@google.com> wrote:
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?

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

Alexey Samsonov

unread,
Jan 23, 2014, 3:59:40 AM1/23/14
to Renato Golin, llvmdev@cs.uiuc.edu List
Hi Renato,

On Wed, Jan 22, 2014 at 9:06 PM, Renato Golin <renato...@linaro.org> wrote:
> On 20 December 2013 10:43, Alexey Samsonov <sams...@google.com> wrote:
>>
>> 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).

>
> cheers,
> --renato

Renato Golin

unread,
Jan 23, 2014, 6:06:26 AM1/23/14
to Alexey Samsonov, llvmdev@cs.uiuc.edu List
On 23 January 2014 08:59, Alexey Samsonov <sams...@google.com> wrote:
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
Reply all
Reply to author
Forward
0 new messages