On Thursday, 6 June 2024 at 18:00:56 UTC, Sebastiaan Koppe wrote:
>On Wednesday, 5 June 2024 at 23:58:14 UTC, Adam Wilson wrote:
>[...]
I think DRT only needs to concern itself with supporting language features. Anything else needs to go elsewhere.
Where then?
A runtime is a collection of code that is executed, at runtime, by applications. The compiler doesn't execute code in the DRT while it's compiling, so it's not really a compiler support library. The only thing that the compiler needs to know about the runtime is that the symbols:
- Exist.
- Follow the compilers emitted ABI for them so that they'll link.
The compiler is only tangentially interested in the runtime insofar as it emits well-known symbols that are contained in the runtime. There is nothing stopping DMD from emitting Phobos symbols, and indeed, on a few occasions, it does. (std.math
IIRC) So by this definition of "Runtime" all of Phobos is part of DRT since technically any Phobos symbol is a compiler support symbol as well.
Which, consequently, is why Phobos and DRT are built and shipped together. That fact should be enough to end this prattle about keeping DRT solely for the compiler. The hard reality is that the runtime is far more closely associated with the standard library than the compiler. And it always will be. If somebody wanted to link in a new runtime, the compiler would not know or care as long as the symbols it relied on were available and mangled the same. IIRC this is what Tango's runtime did. But if somebody wants to try to make Phobos work with that same new runtime ... well, I guess we'll see them year or two later with a lot less hair.
This becomes a blocker if the goal is to make Phobos "source-only" to ease the transition to Editions, as we must move code out of Phobos and into DRT since we would no longer be able to ensure that the Phobos symbols DMD emits are actually compiled into the binary.
I am not proposing that we get rid of DRT or it's utility in language feature support, only that we accept it's mission for what it is, to be the universal system interface. It's either that or we continue to pretend that the split between DRT and Phobos is an actual thing.
Runtimes do not serve the compiler, they serve the applications that the compiler builds. Yes the compiler needs to be aware of the runtime, but that's it. I think we are trying to hard to keep DRT "small" to make porting easier, when all we've really done is create a situation where we have three runtimes: CRT, DRT, and Phobos.
Mission accomplished in the most uselessly restrictive and excessive way possible. Yay for D!
TL;DR: The runtime is far more important to libraries and applications than it ever will be to the compiler.
So, where should all of this system interface code go?