OS in D language

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
User avatar
AndreaOrru
Member
Member
Posts: 50
Joined: Fri Apr 25, 2008 2:50 pm
Location: New York

Re: OS in D language

Post by AndreaOrru »

Does LDC support D 2.0?
Close the world, txEn eht nepO
User avatar
steveklabnik
Member
Member
Posts: 72
Joined: Wed Jan 28, 2009 4:30 pm

Re: OS in D language

Post by steveklabnik »

I'm pretty sure that it doesn't currently.
User avatar
AndreaOrru
Member
Member
Posts: 50
Joined: Fri Apr 25, 2008 2:50 pm
Location: New York

Re: OS in D language

Post by AndreaOrru »

You are right. I have tried to compile LDC with the D 2.0 option enabled, and the compilation failed pretty soon.

EDIT:
In fact, it failed even with the D 1.0 option!

Code: Select all

[ 74%] Building CXX object CMakeFiles/ldc.dir/gen/tollvm.cpp.o
/home/andrew/ldc/ldc/gen/tollvm.cpp: In function ‘size_t getTypePaddedSize(const llvm::Type*)’:
/home/andrew/ldc/ldc/gen/tollvm.cpp:723: error: ‘const class llvm::TargetData’ has no member named ‘getTypePaddedSize’
make[2]: *** [CMakeFiles/ldc.dir/gen/tollvm.cpp.o] Error 1
make[1]: *** [CMakeFiles/ldc.dir/all] Error 2
make: *** [all] Error 2
Close the world, txEn eht nepO
User avatar
steveklabnik
Member
Member
Posts: 72
Joined: Wed Jan 28, 2009 4:30 pm

Re: OS in D language

Post by steveklabnik »

Strange? Did you follow the steps outlined exactly? wilkie just did it (strange coincidence) and the latest version compiled on his machine.
User avatar
Wilkie
Member
Member
Posts: 44
Joined: Tue Aug 26, 2008 10:02 pm
Location: Land of the Dead
Contact:

Re: OS in D language

Post by Wilkie »

That I did... several times. :D

Follow the instructions here. Do not deviate.

You will need the LLVM from source control. (not LLVM 2.5). That has been tripping people up the last few weeks. If you have further trouble, refer to #ldc on irc.freenode.net.

Any D 2 stuff will be mostly experimental. Give it a few more months. D 1.0 is much much more stable and has a lot more support. If you need something kernel-like to refer to or to test LDC, you can look at our kernel bare bones, on-topic here and #xomb on irc.freenode.net.
User avatar
AndreaOrru
Member
Member
Posts: 50
Joined: Fri Apr 25, 2008 2:50 pm
Location: New York

Re: OS in D language

Post by AndreaOrru »

Thank you very much!
Close the world, txEn eht nepO
User avatar
AndreaOrru
Member
Member
Posts: 50
Joined: Fri Apr 25, 2008 2:50 pm
Location: New York

Re: OS in D language

Post by AndreaOrru »

I'd want to use llvm-ld as linker, but it seems that it can't be configured through linker scripts. So is it useless for OSdev?
Close the world, txEn eht nepO
User avatar
Wilkie
Member
Member
Posts: 44
Joined: Tue Aug 26, 2008 10:02 pm
Location: Land of the Dead
Contact:

Re: OS in D language

Post by Wilkie »

Here is a manual for llvm-ld. It takes LLVM bitcode, which LDC should (?) produce, but I am not completely sure. LDC should have a linker, itself, though, but it will probably just use ld in the background. Considering LDC produces native executables from source, I'm sure it has a linking stage.
wilsonk
Posts: 3
Joined: Sat Jun 20, 2009 10:34 pm

Re: OS in D language

Post by wilsonk »

Hey Wilkie et al.,

LDC is pretty stable now on x86 (x86-64) and should be able to compile most programs. The devs are mostly working on optimizations for speed and code size during compilation (heavily templated code can be a problem for using a lot of memory). There are the odd errors now but half the time those end up being bad code that dmd lets through ;)

LDC does output llvm bitcode but it usually uses ld to link after getting an object file from gcc. You can stop at most stages like outputting LLVM_IR (output-ll), bitcode (output-bc), assembly (output-s) or object code (output-o)...whichever you prefer.

Please, please, if anyone his having trouble building LDC, direct them to #ldc on irc.freenode.net, because there have been some issues with a changing cmake environment and whether someone uses Tango0.99.8 or not.

There is a stable release of ldc that is statically linked here:
http://www.digitalmars.com/d/archives/d ... 16110.html

in case someone can't build it. Ubuntu and a couple other OS's, I think, have nightly builds available somewhere.

Thanks,
K.Wilson
User avatar
steveklabnik
Member
Member
Posts: 72
Joined: Wed Jan 28, 2009 4:30 pm

Re: OS in D language

Post by steveklabnik »

Good to see you here, wilsonk!

For those of you who don't know (or couldn't tell), he's one of the ldc devs, and has been very helpful over the last few months.
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Re: OS in D language

Post by Zenith »

Congrats to the LDC devs! Proper support for x86-64 is what I've been waiting for before switching to LDC from GDC for my OS. Though to be honest, the only really compelling reason for me to switch is the lack of maintainers and development for GDC (though the last commit was "only" five months ago). :lol:

But I'm wondering, is LDC buildable on Cygwin/Windows as it is? If not, will it ever be supported in the future?
"Sufficiently advanced stupidity is indistinguishable from malice."
wilsonk
Posts: 3
Joined: Sat Jun 20, 2009 10:34 pm

Re: OS in D language

Post by wilsonk »

Hey Zenith,

Sorry to take so long answering this...I am not really a regular here :)

Yes LDC builds on mingw, but it is still missing exceptions on windows. This means that it isn't totally useful yet. We have been trying to get exceptions working, but there is no support for sjlj (setjump/longjump) on x86 and no support for windows SEH (Structured Exception Handling) at all.

Hang in there to all those waiting for mingw/LDC...we are trying to get exceptions working (we have even tried the newest gcc-4.4 with dwarf2 exceptions but that may be just as difficult as SEH...darnit!!!).

Thanks,
K.Wilson
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Re: OS in D language

Post by Zenith »

Awesome! I only use GDC for my OS right now under Cygwin/Windows for targeting the x86-64, and DMD 2.* for userspace development. I guess soon I can switch both of them to LDC. :D

Though I'm sorry to bug you a bit more, but I was really specifically wondering about future support with Cygwin as opposed to Mingw? IIRC the build script for LDC actually detects the Cygwin installation and explicitly stops the build. :?
"Sufficiently advanced stupidity is indistinguishable from malice."
wilsonk
Posts: 3
Joined: Sat Jun 20, 2009 10:34 pm

Re: OS in D language

Post by wilsonk »

Sorry Zenith,

No cygwin support is in the works here. We'll see if someone steps up to do it soon....

Thanks,
K.Wilson
BuRnEr
Posts: 2
Joined: Wed Aug 05, 2009 2:40 pm

Re: OS in D language

Post by BuRnEr »

I have been trying to get the D Barebone from the wiki to run, using the ldc compiler.
Linking failed, due to the fact that ldc always imports object.d at compile-time even with -nodefaultlib -noruntime.
So I joined the irc channel of the ldc project to asked for advice. I seems ldc imports object.d by default and there is nothing you can do about it.
Unwilling to import object from XOmb or even tango, I tried to write one my own.

Code: Select all

module object;
class Object {}
class ClassInfo : Object{}


gave me a seg. fault with both ldc and dmd.

So I was wondering if, somebody knows how to write a really small object.d so linking doesn't fail?
Post Reply