www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Writting SO kernel in D

reply Javi <javier.valcarce gmail.com> writes:
Hi,
I would like to know the main issues about writting OS kernels in D.

My (hobby) kernel is composed by 2 files: startup.S and kernel.d, neither
startup.S nor kernel.d make system calls, of cource.

But kernel.o references the symbol __gdc_persolnality_v0 
Where is It? It seems a kind  of runtime for garbage collector, etc. How can I
turn it off? 

Thanks, and sorry for my poor english.
Javi
Apr 19 2007
next sibling parent reply Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Javi wrote:
 Hi,
 I would like to know the main issues about writting OS kernels in D.
 
 My (hobby) kernel is composed by 2 files: startup.S and kernel.d, neither
startup.S nor kernel.d make system calls, of cource.
 
 But kernel.o references the symbol __gdc_persolnality_v0 
 Where is It? It seems a kind  of runtime for garbage collector, etc. How can I
turn it off? 
Actually, that looks like exception support. Try compiling with "-fno-exceptions" to turn it off. Though if you ever want to use exceptions in your kernel you'll have to eventually copy the code from the runtime or reimplement it yourself. (I have no idea what it requires, for all I know the default implementation could work just fine in a kernel)
Apr 19 2007
parent speal <charliemc86 gREmOVEailCAPS.com> writes:
That's helpful.  I was dealing with that same issue in my kernel project.  I've
got some other undefined symbols I'd like to take care of so I can go to OO
code,
but there seems to be a lack of documentation for D's inner workings.  Maybe I'm
just missing it?

What specifically is involved in declaring, instantiating, and calling member
functions for classes, as far as the runtime is concerned?  None of this is in
dynamic memory yet, of course.

How about static constructors?  How are the calls to static constructors stored
in
the binary?  Is it the same as for C++ (array of static constructor pointers),
are
they put in the .bss section, or is it something else entirely?
Aug 17 2007
prev sibling parent reply Javi <javier.valcarce gmail.com> writes:
Frits van Bommel Wrote:

 Actually, that looks like exception support. Try compiling with 
 "-fno-exceptions" to turn it off.
 Though if you ever want to use exceptions in your kernel you'll have to 
 eventually copy the code from the runtime or reimplement it yourself. (I 
 have no idea what it requires, for all I know the default implementation 
 could work just fine in a kernel)
Thank you very much! I works fine now. Another question: Where is the runtime code localted on disk? And If this code resides in a big file, how can I extract only the relevant routines? Sorry, but I'm not a compiler expert.
Apr 19 2007
next sibling parent BCS <BCS pathlink.com> writes:
Javi wrote:
 Frits van Bommel Wrote:
 
 
Actually, that looks like exception support. Try compiling with 
"-fno-exceptions" to turn it off.
Though if you ever want to use exceptions in your kernel you'll have to 
eventually copy the code from the runtime or reimplement it yourself. (I 
have no idea what it requires, for all I know the default implementation 
could work just fine in a kernel)
Thank you very much! I works fine now. Another question: Where is the runtime code localted on disk? And If this code resides in a big file, how can I extract only the relevant routines? Sorry, but I'm not a compiler expert.
I think it's in libphobos.a (or the .lib equivalent on Win32)
Apr 19 2007
prev sibling parent reply Sean Kelly <sean f4.ca> writes:
Javi wrote:
 
 Another question: 
 Where is the runtime code localted on disk? And If this code resides in a big
file, how can I extract only the relevant routines?
 Sorry, but I'm not a compiler expert.
It's in Phobos in the /internal directory. Under that is the /gc directory, which contains the garbage collector implementation. If you're using Tango, the compiler runtime is in /lib/compiler/gdc or /lib/compiler/dmd, and the garbage collector is in /lib/gc/basic. Sean
Apr 19 2007
parent reply Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Sean Kelly wrote:
 Javi wrote:
 Another question: Where is the runtime code localted on disk? And If 
 this code resides in a big file, how can I extract only the relevant 
 routines?
 Sorry, but I'm not a compiler expert.
It's in Phobos in the /internal directory. Under that is the /gc directory, which contains the garbage collector implementation. If you're using Tango, the compiler runtime is in /lib/compiler/gdc or /lib/compiler/dmd, and the garbage collector is in /lib/gc/basic.
And since he's using GDC[1] some of it is in d/phobos/gcc/ in the GDC source tree, or include/d/*/gcc/ in the installed version. Specifically, look at deh.d for exceptions. [1]: and presumably not Tango, since he's coding a kernel. Though he could of course use that version just as well.
Apr 19 2007
parent Sean Kelly <sean f4.ca> writes:
Frits van Bommel wrote:
 Sean Kelly wrote:
 Javi wrote:
 Another question: Where is the runtime code localted on disk? And If 
 this code resides in a big file, how can I extract only the relevant 
 routines?
 Sorry, but I'm not a compiler expert.
It's in Phobos in the /internal directory. Under that is the /gc directory, which contains the garbage collector implementation. If you're using Tango, the compiler runtime is in /lib/compiler/gdc or /lib/compiler/dmd, and the garbage collector is in /lib/gc/basic.
And since he's using GDC[1] some of it is in d/phobos/gcc/ in the GDC source tree, or include/d/*/gcc/ in the installed version. Specifically, look at deh.d for exceptions.
Oops, good point. In Tango all of this is in the same place, and I'd forgotten GPhobos was different.
 [1]: and presumably not Tango, since he's coding a kernel. Though he 
 could of course use that version just as well.
As a shameless plug, building kernels against Tango should actually be easier than doing so against Phobos, since the runtime can be used completely separately from all user-level code, the GC more easily replaced or customized, etc. Kernel development was actually one of my primary inspirations for the Tango design, since most of the vocal Ares users were working on kernel projects :-) Sean
Apr 19 2007