How can I use ldc2 and link to full runtime on arm with no OS

kinke via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 20 12:44:46 PDT 2017


On Tuesday, 20 June 2017 at 17:52:59 UTC, Dan Walmsley wrote:
> How do I link in the run time and gc, etc?

In your case, you firstly need to cross-compile druntime to your 
target. This means compiling most files in the src subdirectory 
of LDC's druntime [1], excluding obvious ones like 
src\test_runner.d, src\core\sys, src\core\stdcpp etc. There are 
also a bunch of C and assembly files which need to be 
cross-compiled with a matching gcc. You'll need to do this 
manually via something along these lines:

cross-gcc -c <.c files and .asm/S files>
ldc2 -mtriple=... -lib -betterC -release -boundscheck=off <.o 
files generated above> <list of D source modules> 
-of=libdruntime.a

Then try linking your minimal code against that druntime (and 
static C libs, as druntime is built on top of the C runtime, see 
[2]). Depending on what features you make use of in your code, 
you'll need to patch linked-in druntime modules to remove the OS 
dependencies and possibly reduce the C runtime dependencies as 
well.

[1] https://github.com/ldc-developers/druntime.
[2] 
http://forum.dlang.org/thread/mojmxbjwtfmioevuoggb@forum.dlang.org


More information about the Digitalmars-d mailing list