cmake, ldc, and cross compiling

Kai Nacke kai at redstar.de
Tue Jan 21 09:35:07 PST 2014


Hi Dan!

On Tuesday, 21 January 2014 at 08:23:45 UTC, Dan Olson wrote:
> When I build ldc as cross compiler to iOS (armv7-apple-darwin), 
> I'd like
> to:
>
> - use gcc-4.8 to compile ldc to host
> - use clang llvm to cross compile runtime C code to iOS
>
> cmake seems to only have room from one C compiler.  Is there a 
> way
> around this?

You want to use a target compiler and a host compiler. This is 
possible with CMake. See here: 
http://www.cmake.org/Wiki/CMake_Cross_Compiling

The bad news is that the current CMake files do not support this 
setup. (This is issue #490, 
https://github.com/ldc-developers/ldc/issues/490.)

> I was initially able to get away with using clang for both 
> since I built
> it with all targets enabled.  Now I switched from clang to gcc 
> for ldc
> build since llvm trunk insists on a newer stdc++.  Installing 
> gcc-4.8
> from macports was my solution.

clang 3.3 should suffice, too. (But I don't know if it is 
available in precompiled form.)

> I think supporting different compilers for ldc and 
> runtime/phobos should
> be expected when cross compiling though.

Yes, it is common setup. See above.

> Also, I'd like to add something like CACHE to RT_CFLAGS so that 
> it can
> be set with cmake.  This will let the runtime C compiler be 
> invoked with
> cross compile flags  like this:
>
> set(RT_CFLAGS "-target armv7-apple-darwin -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk")
>

Also a reasonable wish.

> I have just been editing the CMakeLists.txt for now to set 
> these flags.

We currently have no concept how to setup a cross compiler chain. 
All your thoughts are reasonable but not yet integrated into our 
CMake files.

Regards,
Kai


More information about the digitalmars-d-ldc mailing list