Remove CRT (C's runtime) from betterC binaries?

Mike Franklin slavo5150 at yahoo.com
Wed Aug 15 09:36:33 UTC 2018


On Wednesday, 15 August 2018 at 06:21:39 UTC, Rel wrote:
>> There are other ways to do minimalist programming in D without 
>> -betterC. See 
>> https://dlang.org/changelog/2.079.0.html#minimal_runtime
>
> Well, what would be the difference between betterC and writing 
> my own minimal runtime?

It depend on what you want to do.  The "minimal runtime" 
approach, for lack of a better description, means you are free to 
implement just the language features you need in a pay-as-you-go 
fashion.  I prefer it as a way to incrementally port D to a new 
platform.

You originally stated that you didn't want to link in the C 
runtime, but I see you are using Windows which seems to have a 
different definition of what the comprises the C Runtime than 
Linux.  In Linux, the C Runtime and the C Standard Library are 
different things, but Windows seems to think they are the same.

I guess I'll stop hear, as I'm probably getting off an a tangent 
you don't really care about.

Just be aware that dmd calls the linker automatically, and 
automatically links in the C Runtime and the C Standard Library.  
If you want to avoid those, you'll probably have to compile with 
-c and link separately.

> For the time being doing betterC looks preferable, so I don't 
> need to reimplement some runtime stuff. Just recompiling the 
> same program with empty object module gives me few errors like 
> size_t, string and etc not implemented in object module.

Yes, you'll need to copy implementation code from 
https://github.com/dlang/druntime/blob/master/src/object.d if you 
want those features.  With this approach you become responsible 
for the runtime implementation, and with great power comes great 
responsibility.

Mike


More information about the Digitalmars-d mailing list