Minimal D Cross Compiler
Gregor Richards
Richards at codu.org
Wed Sep 12 15:04:50 PDT 2007
Brian Madden wrote:
> Hi all,
>
> I'd just like to preface this with saying that I'm sorry if this doesn't quite
> belong here, I wasn't sure where to post it, and it is a repost from the D
> group which looks like it hadn't received any activity for 2 months prior to
> my post.
>
> A few students at the University of Pittsburgh have been gathering and coding
> up a new operating system. We've played in C, gotten some bootable code, etc,
> but we'd really like to write this all in D (save the asm parts that need to
> be done at the low level). We're trying to target the x86_64 architecture,
> but not everyone has 64bit machines (myself included).
>
> We're working on building our cross compiler toolchains BUT we're running in
> to problems left and right. Most of us are on non-windows boxen, (about half
> are on macs, the other are running linux).
>
> I've read a few different instructions on how to compile a D cross compiler,
> however since we're writing an OS we don't need any of the standard libraries,
> just the basics.
>
> Can anyone help walk through the steps of this. I've been trying to combine
> two different methods (the method for just building gcc with an x86_64 target,
> and then trying to build D too), and when I finally got a build, just
> compiling the following code:
>
> void main() {
> return 1;
> }
>
> The compiler barfed with the following error:
>
> ~/bin/x86_64-pc-elf-gdc test.d
> <built-in>:0: internal compiler error: Bus error
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL:http://gcc.gnu.org/bugs.html> for instructions.
>
> I have tried to recompile my xcompiler since then and am having no luck (now
> I'm getting language glue errors hehe). I figure rather than keep beating my
> head off of the wall I'd just ask if anyone else had done something similar,
> or could help out with this!
>
> Thanks much in advance!
>
> -Brian
The only complicated part in making a cross-compiler of GDC is Phobos.
Since you don't WANT Phobos (and you certainly don't want Phobos with a
non-OS target), you can actually disable that entirely. I believe the
flag is just --disable-libphobos, but I'm not positive, I've never had
to do it. Suffice to say it can be done :).
At the very least, you should be able to make only the compiler
component and its dependencies (you don't need any of the other garbage
GCC comes with) with something like:
$ make SUBDIRS="gcc"
$ make install-gcc
I believe that that will build GDC and not build libphobos. But the
configuration --disable flag is probably the way to go.
If you can reliably produce cross-compilers that crashes on a simple
test case like the one you provided, that's probably a compiler bug.
- Gregor Richards
More information about the Digitalmars-d
mailing list