Proposal: configuration for cross compilation

Kai Nacke via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Mon May 5 03:37:30 PDT 2014


Hi all!

More and more people use LDC to cross-compile for other 
architectures. But end-to-end support is still missing. At least 
some basic tools and libraries differ: C compiler/assembler, 
linker, default druntime and phobos libraries.

Thinking about a solution, I came up with the following proposal. 
Currently, the config file is only used to define some command 
line switches. This can be extended to do a multi-level lookup 
for:

- definitions for tools (compiler, linker) and libraries 
(druntime, phobos)
- additional definitions for each target (command line switched, 
...)

The lookup would sue the triple. The lookup order would be triple 
including environment, triple without environment, os only and 
default. The first entry matched is used. The config file would 
look like:

### Start of ldc2.conf
default:
{
     cc = gcc
     cctype = gnu
     ld = gcc
     ldtype = gnu
     switches = [ ... ]
     defaultlib = ...
     debuglib = ...
     linklibs = rt dl pthread m
}

*-*-freebsd:
{
     cc = clang
     linklibs = pthread m
}

*-*-win32:
{
     cc = cl
     cctype = ms
     ld = link
     ldtype = ms
     linkswitches = /NXCOMPAT /DYNAMICBASE
     linklibs = kernel32.lib user32.lib gdi32.lib
}

arm-*-linux-gnuehabi:
{
     cc = arm-unknown-linux-gnu-gcc
     ld = arm-unknown-linux-gnu-gcc
}

mips64-*-linux:
{
     cc = mips64-unknown-linux-gnu-gcc
     ld = mips64-unknown-linux-gnu-gcc
}
### End of ldc2.conf

E.g. compiling for Linux/MIPS64 (-mtriple=mips64-linux) would 
result in use of mips64-unknown-linux-gnu-gcc. Compiling for 
FreeBSD would use clang (because this is the default compiler in 
release 10). Default configuration is to use gcc for 
compiling/linking.

What do you think? Does this scheme cover the common cases 
encountered with cross compilation?

Regards,
Kai


More information about the digitalmars-d-ldc mailing list