Cross-compile with LDC
Joakim via digitalmars-d-ldc
digitalmars-d-ldc at puremagic.com
Fri Feb 19 09:14:21 PST 2016
On Friday, 19 February 2016 at 12:06:15 UTC, Jacob Carlborg wrote:
> On 2016-02-19 09:51, Joakim wrote:
>> 1. Cross-compile druntime and phobos for the OS/arch combo you
>> want.
>> This is easy to do using the cmake build scripts that come
>> with the ldc
>> source, assuming ldc, druntime and phobos already support the
>> platform
>> you want. Simply set D_FLAGS to the llvm triple and any other
>> specific
>> flags you need, as I do for Android/ARM
>> (https://gist.github.com/joakim-noah/63693ead3aa62216e1d9#file-ldc_android_arm-L3131),
>> and set CC to a C cross-compiler for your target platform
>> (export
>> CC=/home/jacob/elcc-linux-aarch64/bin/clang), as there are a
>> few C files
>> and one asm file that druntime and phobos require. You may
>> also need to
>> set RT_CFLAGS, depending on the C compiler for your platform
>> (can be
>> seen in the link below).
>
> Since this is for Linux x86_64, could I just use the
> pre-compiled libraries from the Linux release?
Probably? Ldc "should" produce the exact same output on another
OS and be able to use a standard library compiled elsewhere,
provided you use the same version of ldc and llvm. I haven't
actually tried it, to see if that theory works out in practice. ;)
> What is RT_CFLAGS for?
As kinke says, those are the flags passed to your C compiler when
building the C parts of druntime and phobos. An example can be
seen in my second link above, when invoking the clang Android/ARM
cross-compiler from the Android NDK.
More information about the digitalmars-d-ldc
mailing list