www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Writing your own runtime, runtime hooks, etc.

reply solidstate1991 <laszloszeremi outlook.com> writes:
I'm thinking about writing, or well, rather modifying the 
existing default runtime of D, mainly by stripping out the GC and 
moving memory management to a primarily manual one. Option for 
refcounting etc. will be added (especially as it exists in 
Phobos, I just need to modify it), reworking D arrays for manual 
management will be a wild ride though.

I will try to catalogue the runtime hooks too during my process, 
however I don't really see any info about how to use a custom 
made runtime. Is it enough to just use betterC, then include the 
newly created runtime as a dependency? Do I need to mess with 
compiler configurations?
Dec 11
next sibling parent reply GrimMaple <grimmaple95 gmail.com> writes:
On Wednesday, 11 December 2024 at 18:16:24 UTC, solidstate1991 
wrote:
 I'm thinking about writing, or well, rather modifying the 
 existing default runtime of D, mainly by stripping out the GC 
 and moving memory management to a primarily manual one. Option 
 for refcounting etc. will be added (especially as it exists in 
 Phobos, I just need to modify it), reworking D arrays for 
 manual management will be a wild ride though.

 I will try to catalogue the runtime hooks too during my 
 process, however I don't really see any info about how to use a 
 custom made runtime. Is it enough to just use betterC, then 
 include the newly created runtime as a dependency? Do I need to 
 mess with compiler configurations?
All you need to do is have an `object.d` file in your build, that's where the runtime is, effectively. If you have a non-standard `object.d` supplied, the druntime is ignored and your custom runtime is used. `betterC` disables any runtime in general, so that's not what you want.
Dec 11
parent reply "H. S. Teoh" <hsteoh qfbox.info> writes:
On Thu, Dec 12, 2024 at 06:52:27AM +0000, GrimMaple via Digitalmars-d-learn
wrote:
 On Wednesday, 11 December 2024 at 18:16:24 UTC, solidstate1991 wrote:
 I'm thinking about writing, or well, rather modifying the existing
 default runtime of D, mainly by stripping out the GC and moving
 memory management to a primarily manual one. Option for refcounting
 etc. will be added (especially as it exists in Phobos, I just need
 to modify it), reworking D arrays for manual management will be a
 wild ride though.
 
 I will try to catalogue the runtime hooks too during my process,
 however I don't really see any info about how to use a custom made
 runtime. Is it enough to just use betterC, then include the newly
 created runtime as a dependency? Do I need to mess with compiler
 configurations?
All you need to do is have an `object.d` file in your build, that's where the runtime is, effectively. If you have a non-standard `object.d` supplied, the druntime is ignored and your custom runtime is used.
[...] It's not quite so simple in practice, though. You also need to know exactly which symbols need to be defined in order for the custom runtime to actually work. Some of these symbols are non-obvious, but missing them will cause the compile to fail with rather unhelpful error messages. T -- People who are more than casually interested in computers should have at least some idea of what the underlying hardware is like. Otherwise the programs they write will be pretty weird. -- D. Knuth
Dec 12
next sibling parent solidstate1991 <laszloszeremi outlook.com> writes:
On Thursday, 12 December 2024 at 15:56:55 UTC, H. S. Teoh wrote:
 It's not quite so simple in practice, though.  You also need to 
 know exactly which symbols need to be defined in order for the 
 custom runtime to actually work.  Some of these symbols are 
 non-obvious, but missing them will cause the compile to fail 
 with rather unhelpful error messages.


 T
I know and I might abandon the project halfway through it in favor of already existing solutions, but at least I can see if I can make it work for my usecase, and already found at least one deprecated symbol for the wiki, and some newly introduced ones. At the moment I want to do something out of my comfort zone for a bit, and while there might be some more immediately useful ideas on that front (like finishing my improved SDLang library), I don't really know, just recovered from a relatively long illness and haven't coded for a while.
Dec 12
prev sibling parent Kagamin <spam here.lot> writes:
On Thursday, 12 December 2024 at 15:56:55 UTC, H. S. Teoh wrote:
 It's not quite so simple in practice, though.  You also need to 
 know exactly which symbols need to be defined in order for the 
 custom runtime to actually work.  Some of these symbols are 
 non-obvious, but missing them will cause the compile to fail 
 with rather unhelpful error messages.
I use stock object.d, only replaced switch.d with old hook.
Dec 12
prev sibling parent Kagamin <spam here.lot> writes:
On Wednesday, 11 December 2024 at 18:16:24 UTC, solidstate1991 
wrote:
 I will try to catalogue the runtime hooks too during my 
 process, however I don't really see any info about how to use a 
 custom made runtime.
Just link programs with your runtime instead of druntime.
Dec 12