Cross-compile with LDC

Jacob Carlborg via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Fri Feb 19 04:06:15 PST 2016


On 2016-02-19 09:51, Joakim wrote:

> As in linux/AArch64?  There are two steps to cross-compiling with ldc:

No, as in Linux x86_64.

> 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?

What is RT_CFLAGS for?

> 2. Specify a linker for your OS/arch when cross-compiling with ldc.  If
> you have a C compiler already configured to use that linker, as elcc
> might provide, all that requires is setting CC to that C compiler before
> running ldc, as shown above.  Otherwise, you can cross-compile to object
> files using ldc and the -c flag, then run your linker by hand, as I do
> with the Android NDK
> (https://gist.github.com/joakim-noah/63693ead3aa62216e1d9#file-ldc_android_arm-L3164).

That seems pretty simple.

-- 
/Jacob Carlborg


More information about the digitalmars-d-ldc mailing list