Windows --> arm-linux cross compiler and lld

Jacob Carlborg doob at me.com
Thu Apr 19 19:12:26 UTC 2018


On 2018-04-18 23:07, kinke wrote:

> I don't see a huge problem for the compiler (except for quite a bunch of 
> LLVM 'intrinsics' boiling down to a C function call, so LLVM expects 
> some core C libs to be linked in as well - so these C symbols would need 
> to be provided by a D lib).
> 
> Basing druntime on the C runtime layer, abstracting away many OS 
> differences, makes things considerably simpler though; with the current 
> manpower, I see no way to get rid of it and re-implement everything in 
> D, while still supporting all platforms (and new platforms to come with 
> as little hassle as possible). OTOH, libunwind (or for MSVC, the Visual 
> C++ EH personality function used by LDC), libpthread, the math functions 
> (which I'd really like to see all in pure D), I/O, memory management...

Originally Tango, which druntime is based, only used syscalls and (as 
far as I know) a C main function and everything necessary for that. But 
druntime has evolved quite a lot since then with new features and more 
platforms.

> I've never used Go, so how can that experience be further improved?

The standard Go compiler is a cross-compiler. They use a custom linker 
which is a cross-linker as well. In Go you cannot directly link to a C 
function in the same way as you can in D. Go also requires (unless you 
want to mess with the whole reason to use Go) that every call is 
non-blocking. That means they need to reimplement most things and cannot 
rely on the C standard library. Therefore they don't and instead only 
using syscalls as the most basic layer.

Cross-compiling using Go is as simple as:

GOOS=linux GOARCH=arm go build main.go

Since the compiler and linker are cross-tools and they're not relaying 
on any platform SDK it just works if you have the standard Go package. 
No issues with trying to find a cross-linker, no issues of the SDK 
cannot be redistributed for macOS or Windows. It will even generate 
statically linked binaries on macOS which the C standard library doesn't 
even support.

-- 
/Jacob Carlborg


More information about the digitalmars-d-ldc mailing list