Concept: druntime getting rid of libc dependency - #23498
Conversation
|
When I was considering the same, I found that
|
If we are talking about CLI options for setting up the GC, then in my practice, completely replacing the parser with something of my own (hardcoded values, for example :-)) has worked well. You can take your own We must keep in mind that the command line from which the options are taken is an optional thing. So I think this can be solved like this: f20ede3 |
2c01216 to
8266c00
Compare
|
I do like the idea of this. It could make porting the runtime to new platforms much easier. The lack of feedback from the core team has me quite concerned for this PR's future, though... |
DMD perf check
|
|
@Herringway Thank you very much! |
Well, right now I'm not aware of any easy way to opt-out of being able to configure the runtime...at runtime (via ENV or cli args). Even configuring at compile time with It'd be nice if there was an easy way to version all of that out, AND to configure the various |
| } | ||
|
|
||
| /// C-formatted print | ||
| static void printf(T...)(scope const char[] fmt, T vals) nothrow @nogc |
There was a problem hiding this comment.
Is this being kept long term (i.e. will freestanding platforms have to write their own printf)?
There was a problem hiding this comment.
Yes.
In fact, I've almost written started to write a simple replacement. It's will be enough for tasks not related to hardcore druntime debugging at first time
I plan to add it to debug builds so that when testing I can make sure it responds similarly as current libc versions
That's what will happen. But we don't need to do it right away. It is just need to give anyone opportunity to do it if necessary. |
Good point! We can try to substitute |
It turned out that it was convenient to be able to import only certain functions, so I had to get rid of Mem structure
|
Great project! However, regarding memory handling, it makes the same mistake by using a global allocator. While I understand this is a huge undertaking, finalizing the custom allocator API would be a better first step imo, that would allow the runtime to benefit from it right away, making APIs much nicer to use and to port. |
|
@xoxorwr thank you for support! But I'm completely against the approach you're proposing: doing it right the first time is difficult. Thus, in my opinion, it is much better to first take out and "contour" memory dealing in the same format in which libc offers it (i.e. using malloc, free & Co) Then, as the second stage, we can try to implement something lower-level (or highter-level?) using knowledges about one or two well-known OSes, then it will become clear what API we want. This is, of course, if I understood your proposal correctly. upd:
There's another reason I'm doing it by this way: I have successfully tested this approach on my own druntime branch |
The names of the members of the
Memstructure are deliberately chosen so as not to appear to be names functions of one well-known OS or library.Actually I make names and locations without much thought - please suggest better choices!
upd: maybe,
rt.backend?upd2: together with the
core.thread.*_implmodules and some similar changes incore.sync.*(not implemented for now, but it is not so difficult) this approach provides interface to easy porting druntime to any system