Build fully static library by the compiler?
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sun Aug 11 14:27:11 UTC 2024
On 12/08/2024 2:04 AM, kinke wrote:
> Wrt. available options for linking D parts /statically/ into a project
> in another language, I'd go in this order:
>
> 1. Use the D compiler as linker driver.
> 2. With a non-D compiler as linker driver, inject the required linker
> flags for the D parts, something like |-L<path to libs dir>
> -lphobos2-ldc -ldruntime-ldc|, in the correct position.
> 3. Otherwise merge all static D libs incl. druntime+Phobos to a single
> monolithic static lib (still depending on libc etc.) as an extra step.
>
> Solution 3 could potentially be implemented in build systems like dub,
> which would then e.g. also allow you to create a 'standalone' fat static
> lib for a dub project with regular static-lib dub dependencies, merging
> all of them, not just druntime and Phobos.
This touches upon something I've been wanting for a while now, which is
essentially a platform probe switch for D compilers.
It would replace dub's platform probe file, but would aid in cases like
this where you don't want to be guessing locations of files.
But it could also offer:
All target triples, their linker flags (with respect to shared + static
builds), file paths to druntime/phobos, and if the triple is default or
supported by host.
More information about the Digitalmars-d-learn
mailing list