Using D without libphobos
Radu
void at null.pt
Thu Apr 26 06:32:14 UTC 2018
On Thursday, 26 April 2018 at 03:04:55 UTC, A. Nicholi wrote:
> Hello,
>
> I am working on a large cross-platform project, which will be
> written primarily in D, interfacing to C as necessary. To get
> finer control over memory safety, binary size, and use of the
> GC, we would like to disclude libphobos as a dependency in lieu
> of our own code. The project is compiled using LDC.
>
> I am not sure if this is possible though, as it seems there are
> certain things in libphobos that are tightly coupled into the D
> runtime. There are several things in the core namespace that
> would be helpful for us (SIMD, C bindings, etc), but I am not
> sure if that is not also part of libphobos along with the other
> namespaces.
>
> How do I remove libphobos as a runtime dependency with ld and
> MSVC’s link.exe? Is it possible to decouple core from other
> parts of the runtime, and if so, how?
>
> Regards,
> A. Nicholi
LDC allows specifying default libs, something like
`-defaultlib=phobos2-ldc,druntime-ldc`; you can remove phobos
from the list.
I think you can use any symbol that is compile time only from
phobos (like std.traits and std.meta), and you can take stuff
from phobos and adapt it to your own needs. I use the compiler
explorer (https://d.godbolt.org/) to check the generate code for
symbols added.
LDC is flexible enough, from my experience, to allow certain
degree of customization. You can override the default C compiler
and add your own paths, or you can create a custom C compiler
driver that overrides defaults. Check the ldc command line spec
for inspiration https://wiki.dlang.org/Using_LDC
Something to remember though, if you intend to commit to serious
commercial use, you should be prepared to dig in and fix stuff
that doesn't work, or add new functionality, or sponsor the
foundation for support. D and LDC are opensource projects, and
they have mostly good quality implementation, but they are not
commercial grade top of the line products.
More information about the Digitalmars-d
mailing list