DMD as cross-compiler
Elronnd
elronnd at elronnd.net
Thu Nov 12 18:58:56 UTC 2020
On Thursday, 12 November 2020 at 06:42:00 UTC, Jacob Carlborg
wrote:
> Unfortunately it won't be that simple for D. D took the easy
> way out and relies both on the C standard library and other
> platform specific libraries implemented in C. While it's easy
> to cross-compile and object file, linking will not be as easy.
FWIW I started working on some stubs for a pure-d libc a while
back - https://github.com/moon-chilled/dlibc/. If it were
completed and integrated into druntime--or, at least, if enough
of it were completed to support druntime+phobos--then it would
make for a much nicer cross-compiling experience.
> Also, on macOS they're cheating. Because they cannot ship the
> SDK, they solve the linking problem by allowing undefined
> symbols. I don't know if Go does the same.
Perhaps a better solution would be to link to a stub dylib of
libc? (Assuming macos libc has a stable ABI.)
> There's LLD, which works on Windows and Linux, but it doesn't
> work for macOS.
As of about a year and a half ago, its status was
> LLD for Mach-O has bitrotted significantly and isn't really
> functional anymore (beyond the most basic programs). I'd
> recommend sticking with ld64 as the linker.
(From
http://lists.llvm.org/pipermail/cfe-dev/2019-March/061666.html)
so the situation may have improved in the mean time; looking at
the logs
(https://github.com/llvm/llvm-project/commits/master/lld/MachO) I
see a fair amount of activity. (In particular, commit 2e8e1bd
adds support for stub dylibs, relevant to my above proposal.)
More information about the Digitalmars-d
mailing list