A betterC modular standard library?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Dec 20 04:00:43 PST 2016


On 12/18/2016 1:02 PM, Ilya Yaroshenko wrote:
> I need to understand how it is can be done because I did not find a valid solution.
>
> mir-cpuid has global symbols, they are accessed using extern(C) API. If multiple
> libraries trying to initialize it than it will be initialized only once.
>
> extern C API does not solve a problem with DRuntime because current DRuntime is
> not a betterC library and it is huge. A huge betterC library is a problem too
> because it is less portable.

cpuid can be written in a manner that it is self-contained. If so, it doesn't 
matter how large druntime is, as it won't have references to any of the rest of 
it and so the rest won't be pulled in by the linker.

https://github.com/dlang/druntime/blob/master/src/core/cpuid.d

Currently, core.cpuid has no imports. It does have a static constructor, though, 
which references the startup code in druntime. This can be changed so it uses 
the static construction support in the C runtime library. Then it will be 
independent of druntime.


More information about the Digitalmars-d mailing list