Create a self contained object file like fat jars from java

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Sun Jan 14 12:35:14 UTC 2024


On 15/01/2024 1:23 AM, pizza_dox_9999 wrote:
> On Sunday, 14 January 2024 at 11:54:09 UTC, Richard (Rikki) Andrew 
> Cattermole wrote:
>> On 15/01/2024 12:47 AM, pizza_dox_9999 wrote:
>>> OK to make it clear. I wanted to call d from c so that I can write a 
>>> n64 game with d. But compiling the d object files while using higher 
>>> features like classes, resulted in missing dependencys. So because 
>>> GCC doesnt understands d I need an object file which has everything 
>>> included d needs to run. Thats my understanding of this situation.
>>
>> My understanding is druntime is not ported to that platform.
>>
>> Too limited in resources.
>>
>> Getting a static library with all dependencies would not help you here.
>>
>> But yes, GCC does understand D, using GDC which is built on top (same 
>> frontend as DMD and LDC).
>>
>> You are either stuck using -betterC which does not support 
>> ``extern(D)`` classes, but does have ``extern(C++)`` classes. Or by 
>> using a custom runtime which you will likely have to write yourself 
>> and will likely break between compiler releases.
> 
> Thank you for the clarification.
> Are such things as string so platform dependent in d or the stuff for 
> the class and interface declarations that they aren't cross platform? I 
> meant the gcc used by the n64 toolchain (libdragon).

A string in D is a slice. A pointer + length. This is entirely platform 
agnostic.

A dynamic array, is a slice, backed by the GC. This requires the GC and 
with that druntime. Which means you cannot append to a slice without 
druntime.

Classes require a ton of infrastructure to work. They are not purely a 
compilation construct.


More information about the D.gnu mailing list