Create a self contained object file like fat jars from java

Renato renato at athaydes.com
Sun Jan 14 10:00:18 UTC 2024


On Sunday, 14 January 2024 at 09:36:16 UTC, pizza_dox_9999 wrote:
> On Sunday, 7 January 2024 at 18:14:12 UTC, Renato wrote:
>> On Friday, 5 January 2024 at 22:10:31 UTC, pizza_dox_9999 
>> wrote:
>>> Hi, I am trying with gdc to create the equivalent of a fat 
>>> jar. So for that I would need the standard dlang library 
>>> included in the object or library file. Does somebody know 
>>> the needed gdc flags?
>>> I am using mips64-linux-gnuabi64-gdc-12.
>>> pizza_dox_9999
>>
>> Did you try using dub and specifying 
>> `targetType="staticLibrary"`?
>>
>> See https://dub.pm/dub-reference/build_settings/#targetpath
>>
>> Even if you just want the right flags, this could help as you 
>> can "ask" dub to print the flags it's using with `dub build 
>> -v`.
>
> Thank you for the information. Sadly nothing for gdc directly. 
> But how is dub solving my problem? Is the buildstep creating a 
> "fat jar". So instead of compiling multiple .d files with gdc I 
> would only compile the "fat jar" from dub?

I think you misunderstood me. `dub` is the D's build system and 
it "knows" how to call the D compilers, including gdc.

When you tell dub to build a static library (equivalent to "fat 
jar" for D) it will use whatever compiler options are needed to 
do so... you can run `dub build -v -release --compiler=gdc` to 
see which compiler options it's using to invoke gdc, and then you 
can just drop dub if you don't need it (though it's very useful 
to have).


More information about the D.gnu mailing list