D.gnu - Compiling DMD frontend in Linux
- Burton Radons (5/5) Jul 22 2002 I'm working on getting DMD to compile in Linux using GCC. I've had to
- Jan Knepper (5/10) Jul 22 2002 Cool!
- Burton Radons (8/18) Jul 22 2002 Oh, it just took this night anyway, unless if you have other code. It's...
- Jan Knepper (10/19) Jul 22 2002 Well, it only took me an hour or two... So it's not that bad...
- Burton Radons (15/39) Jul 22 2002 Ah, I was wondering why I needed to add so many includes. The only
- Jan Knepper (10/49) Jul 22 2002 Are you sure?
- Walter (5/7) Jul 22 2002 few static
- Jan Knepper (3/10) Jul 22 2002 Thanks!
- Burton Radons (25/87) Jul 23 2002 I meant stringtable there. The rest are for the backend, with a couple
- Jan Knepper (10/46) Jul 23 2002 OK, let's check into that too!
- Jonathan Andrew (8/16) Jul 23 2002 Is there any information about the output that the D front end creates?
- Jan Knepper (5/16) Jul 23 2002 I am working on that and as soon as I have it all done (just compile I m...
- Jonathan Andrew (3/9) Jul 23 2002 Fantastic! I'm really looking forward to it.
- Burton Radons (9/24) Jul 24 2002 It's not too complex - it's a bunch of fully formed structs, unlike
- Jonathan Andrew (6/18) Jul 24 2002 This is one thing that I was unsure of, from what I've read, the RTL
- Walter (4/7) Jul 23 2002 Those dependencies are bugs, could you send me the file/line of them?
- Burton Radons (7/16) Jul 24 2002 In lexer.c search for "case '\\':" and the StringConstant functions.
- Steven Shaw (9/48) Jul 24 2002 trick
- Jan Knepper (5/10) Jul 24 2002 You can do the same with GCC.
- Richard Levitte (7/10) Jan 12 2003 Actually, I'm rather glad he does, it'll show me how to do it on other
- Walter (3/7) Jan 13 2003 Glad to have you join us! -Walter
- Burton Radons (11/11) Jul 27 2002 Status update. The last few days I've been looking into various
- Jan Knepper (2/13) Jul 27 2002
- Burton Radons (14/14) Aug 03 2002 It's that time again. Classes are working, as is TypeInfo. TypeInfo
I'm working on getting DMD to compile in Linux using GCC. I've had to change quite a lot of stuff - differences in compilers, missing code, things like that. I'll be giving a more detailed report later. It's currently compiling all the objects, but I haven't tried linking them. There's a lot of stub functions to write.
Jul 22 2002
Cool! It would have been great when you would have reported this before as I also already have done some of this. Jan Burton Radons wrote:I'm working on getting DMD to compile in Linux using GCC. I've had to change quite a lot of stuff - differences in compilers, missing code, things like that. I'll be giving a more detailed report later. It's currently compiling all the objects, but I haven't tried linking them. There's a lot of stub functions to write.
Jul 22 2002
Jan Knepper wrote:It would have been great when you would have reported this before as I also already have done some of this.Oh, it just took this night anyway, unless if you have other code. It's (DMD, that is) now compiling a test properly and is throwing an unimplemented on Module::genobjfile, which is supposed to do everything in the backend. So everything past that point is backend. I'm not interested in working on BrightD, so I'm now going ahead with writing my own backend. I'll put down lots of documentation as I figure out things and make a zip sometime.Burton Radons wrote:I'm working on getting DMD to compile in Linux using GCC. I've had to change quite a lot of stuff - differences in compilers, missing code, things like that. I'll be giving a more detailed report later. It's currently compiling all the objects, but I haven't tried linking them. There's a lot of stub functions to write.
Jul 22 2002
Burton Radons wrote:Well, it only took me an hour or two... So it's not that bad... One of the cute things to know is that Walter seems to use a compiler trick in DMC++ where he includes total.h as first header for every source file.It would have been great when you would have reported this before as I also already have done some of this.Oh, it just took this night anyway, unless if you have other code. It's (DMD, that is) now compiling a test properly and is throwing an unimplemented on Module::genobjfile, which is supposed to do everything in the backend. So everything past that point is backend.I'm not interested in working on BrightD, so I'm now going ahead with writing my own backend. I'll put down lots of documentation as I figure out things and make a zip sometime.You mean, you are not interested in the GLUE layer for the D-front-end and the GCC-back-end? What are you writing a back-end for? If you want to make if 'public' we might be able to setup a newsgroup or add it to http://www.opend.org/ Jan
Jul 22 2002
Jan Knepper wrote:Burton Radons wrote:Ah, I was wondering why I needed to add so many includes. The only frontend code that's missing was stringbuffer.Well, it only took me an hour or two... So it's not that bad... One of the cute things to know is that Walter seems to use a compiler trick in DMC++ where he includes total.h as first header for every source file.It would have been great when you would have reported this before as I also already have done some of this.Oh, it just took this night anyway, unless if you have other code. It's (DMD, that is) now compiling a test properly and is throwing an unimplemented on Module::genobjfile, which is supposed to do everything in the backend. So everything past that point is backend.Entertainment, education. Also, using GNU as a backend doesn't fit in my long-term plan of a compiler-in-a-library. I want to eventually convert DMD, with the backend, into D, and allow getting the parse tree using a single method call. I'd convert it to D now but I'm sick of Windows.I'm not interested in working on BrightD, so I'm now going ahead with writing my own backend. I'll put down lots of documentation as I figure out things and make a zip sometime.You mean, you are not interested in the GLUE layer for the D-front-end and the GCC-back-end? What are you writing a back-end for?If you want to make if 'public' we might be able to setup a newsgroup or add it to http://www.opend.org/A bit premature but thanks for the offer. The code: int main () { return 45; } Now creates a correct object file. I'm 0.01% done. :-)
Jul 22 2002
Burton Radons wrote:Jan Knepper wrote:Are you sure? I am pretty sure the following header files were missing... cc.h, cgcv.h, code.h, context.h, dt.h, el.h, global.h, id.h, oper.h, outbuf.h, port.h, stringtable.h, type.h. Most significant is id.h as I think it contains "class Id" with quite a few static members used throughout the code.Burton Radons wrote:Ah, I was wondering why I needed to add so many includes. The only frontend code that's missing was stringbuffer.Well, it only took me an hour or two... So it's not that bad... One of the cute things to know is that Walter seems to use a compiler trick in DMC++ where he includes total.h as first header for every source file.It would have been great when you would have reported this before as I also already have done some of this.Oh, it just took this night anyway, unless if you have other code. It's (DMD, that is) now compiling a test properly and is throwing an unimplemented on Module::genobjfile, which is supposed to do everything in the backend. So everything past that point is backend.<g>Entertainment, education. Also, using GNU as a backend doesn't fit in my long-term plan of a compiler-in-a-library. I want to eventually convert DMD, with the backend, into D, and allow getting the parse tree using a single method call. I'd convert it to D now but I'm sick of Windows.I'm not interested in working on BrightD, so I'm now going ahead with writing my own backend. I'll put down lots of documentation as I figure out things and make a zip sometime.You mean, you are not interested in the GLUE layer for the D-front-end and the GCC-back-end? What are you writing a back-end for?Are you just having a lot of time on your hands? JanIf you want to make if 'public' we might be able to setup a newsgroup or add it to http://www.opend.org/A bit premature but thanks for the offer. The code: int main () { return 45; } Now creates a correct object file. I'm 0.01% done. :-)
Jul 22 2002
"Jan Knepper" <jan smartsoft.cc> wrote in message news:3D3C3E84.D8F932DC smartsoft.cc...Most significant is id.h as I think it contains "class Id" with quite afew staticmembers used throughout the code.id.h and id.c are generated by the file idgen.c, which should be included with the source code.
Jul 22 2002
Walter wrote:"Jan Knepper" <jan smartsoft.cc> wrote in message news:3D3C3E84.D8F932DC smartsoft.cc...Thanks! JanMost significant is id.h as I think it contains "class Id" with quite afew staticmembers used throughout the code.id.h and id.c are generated by the file idgen.c, which should be included with the source code.
Jul 22 2002
Jan Knepper wrote:Burton Radons wrote:I meant stringtable there. The rest are for the backend, with a couple pieces that appear to have been moved to other files (global and outbuf). dchar is another one (I don't know what header file it's from), and a source of a small problem - the code assumes wchar_t is two bytes at several points. Not a large thing, but if your produced strings are nonsensical, you now know why.Jan Knepper wrote:Are you sure? I am pretty sure the following header files were missing... cc.h, cgcv.h, code.h, context.h, dt.h, el.h, global.h, id.h, oper.h, outbuf.h, port.h, stringtable.h, type.h.Burton Radons wrote:Ah, I was wondering why I needed to add so many includes. The only frontend code that's missing was stringbuffer.Well, it only took me an hour or two... So it's not that bad... One of the cute things to know is that Walter seems to use a compiler trick in DMC++ where he includes total.h as first header for every source file.It would have been great when you would have reported this before as I also already have done some of this.Oh, it just took this night anyway, unless if you have other code. It's (DMD, that is) now compiling a test properly and is throwing an unimplemented on Module::genobjfile, which is supposed to do everything in the backend. So everything past that point is backend.Most significant is id.h as I think it contains "class Id" with quite a few static members used throughout the code.Walter noted that it's generated. impcnvtab.c is also generated, from impcnvgen.c.I would be willing to have an internal API that can be matched up with GCC, but I could only compromise with generating RTI, since producing this machine-specific code (the syntax is inspecific, but you need to know the machine and calling structure to use it) is not a great inconvenience and I'll have to move towards that eventually anyway. For BrightD, OpenD, GLUE, or whatever you want to call it, converting D's node tree to GCC's is more your ideal, but for me it adds too much complexity.Entertainment, education. Also, using GNU as a backend doesn't fit in my long-term plan of a compiler-in-a-library. I want to eventually convert DMD, with the backend, into D, and allow getting the parse tree using a single method call. I'd convert it to D now but I'm sick of Windows.I'm not interested in working on BrightD, so I'm now going ahead with writing my own backend. I'll put down lots of documentation as I figure out things and make a zip sometime.You mean, you are not interested in the GLUE layer for the D-front-end and the GCC-back-end? What are you writing a back-end for?At times. Hello, world! is now working; that makes it about 0.1%. Walter, I found that the code: printf ("Hello, world!", "Foo foo foo!"); Was producing the most unexpected: printf ("Hello, world!", (wchar [] [12]) (wchar [12]) "Foo foo foo!"); I guess the code generator is assuming the parser knows what it's doing and is producing nonsense as a result. I've previously clocked it as being the same as "(wchar *)".Are you just having a lot of time on your hands?If you want to make if 'public' we might be able to setup a newsgroup or add it to http://www.opend.org/A bit premature but thanks for the offer. The code: int main () { return 45; } Now creates a correct object file. I'm 0.01% done. :-)
Jul 23 2002
Burton Radons wrote:I think Walter will give you dchar.h...Are you sure? I am pretty sure the following header files were missing... cc.h, cgcv.h, code.h, context.h, dt.h, el.h, global.h, id.h, oper.h, outbuf.h, port.h, stringtable.h, type.h.I meant stringtable there. The rest are for the backend, with a couple pieces that appear to have been moved to other files (global and outbuf). dchar is another one (I don't know what header file it's from), and a source of a small problem - the code assumes wchar_t is two bytes at several points. Not a large thing, but if your produced strings are nonsensical, you now know why.OK, let's check into that too!Most significant is id.h as I think it contains "class Id" with quite a few static members used throughout the code.Walter noted that it's generated. impcnvtab.c is also generated, from impcnvgen.c.OK, you're using the D-front-end to target a different architecture. Understood.I would be willing to have an internal API that can be matched up with GCC, but I could only compromise with generating RTI, since producing this machine-specific code (the syntax is inspecific, but you need to know the machine and calling structure to use it) is not a great inconvenience and I'll have to move towards that eventually anyway. For BrightD, OpenD, GLUE, or whatever you want to call it, converting D's node tree to GCC's is more your ideal, but for me it adds too much complexity.Entertainment, education. Also, using GNU as a backend doesn't fit in my long-term plan of a compiler-in-a-library. I want to eventually convert DMD, with the backend, into D, and allow getting the parse tree using a single method call. I'd convert it to D now but I'm sick of Windows.<g> I guess that is part of the deal with a compiler that is in progress. I don't think there is anything else the code generator can do. It is being called by the front-end and lives on data provided by the front-end. The parse should deliver the correct 'tree' structure to the code generator to generate the code from. JanAre you just having a lot of time on your hands?At times. Hello, world! is now working; that makes it about 0.1%. Walter, I found that the code: printf ("Hello, world!", "Foo foo foo!"); Was producing the most unexpected: printf ("Hello, world!", (wchar [] [12]) (wchar [12]) "Foo foo foo!"); I guess the code generator is assuming the parser knows what it's doing and is producing nonsense as a result. I've previously clocked it as being the same as "(wchar *)".
Jul 23 2002
<g> I guess that is part of the deal with a compiler that is in progress. I don't think there is anything else the code generator can do. It is being called by the front-end and lives on data provided by the front-end. The parse should deliver the correct 'tree' structure to the code generator to generate the code from. JanIs there any information about the output that the D front end creates? I know the gcc tree structure is woefully undocumented. Also, if anybody has gotten the D front end to compile under Linux, any chance of posting a zip or tarball of the ported code on opend.org so others (like me) can play around with it without reinventing the wheel? (albeit a complicated wheel.) Thanks, -Jon
Jul 23 2002
Jonathan Andrew wrote:It's called Walter Bright <g><g> I guess that is part of the deal with a compiler that is in progress. I don't think there is anything else the code generator can do. It is being called by the front-end and lives on data provided by the front-end. The parse should deliver the correct 'tree' structure to the code generator to generate the code from.Is there any information about the output that the D front end creates?I know the gcc tree structure is woefully undocumented. Also, if anybody has gotten the D front end to compile under Linux, any chance of posting a zip or tarball of the ported code on opend.org so others (like me) can play around with it without reinventing the wheel? (albeit a complicated wheel.)I am working on that and as soon as I have it all done (just compile I mean) it indeed will appear on opend.org. Actually it will be in CVS and a HEAD tarball will be created daily. Jan
Jul 23 2002
Jan Knepper wrote:I am working on that and as soon as I have it all done (just compile I mean) it indeed will appear on opend.org. Actually it will be in CVS and a HEAD tarball will be created daily. JanFantastic! I'm really looking forward to it. -Jon
Jul 23 2002
Jonathan Andrew wrote:It's not too complex - it's a bunch of fully formed structs, unlike GCC's generic LISPish. But I'm adding header documentation as I go.<g> I guess that is part of the deal with a compiler that is in progress. I don't think there is anything else the code generator can do. It is being called by the front-end and lives on data provided by the front-end. The parse should deliver the correct 'tree' structure to the code generator to generate the code from.Is there any information about the output that the D front end creates?I know the gcc tree structure is woefully undocumented. Also, if anybody has gotten the D front end to compile under Linux, any chance of posting a zip or tarball of the ported code on opend.org so others (like me) can play around with it without reinventing the wheel? (albeit a complicated wheel.)Oh, sure: http://amateur-scrolls.sourceforge.net/old/dli-0.0.1.tar.gz My additions, outside of fixing it to compile and behave properly in Linux, is mostly restrained to "machine.h" and "machine-i386.cc". If you strip off the backend entirely, the main thing you'll need to fix up is the stringtable implementation, which I just stubbed as a linear list.
Jul 24 2002
Burton Radons wrote:It's not too complex - it's a bunch of fully formed structs, unlike GCC's generic LISPish. But I'm adding header documentation as I go.This is one thing that I was unsure of, from what I've read, the RTL is LISPish, but before that comes a syntax tree, which should just be a bunch of tree structs, right? Maybe I am confused on this.Oh, sure: http://amateur-scrolls.sourceforge.net/old/dli-0.0.1.tar.gz My additions, outside of fixing it to compile and behave properly in Linux, is mostly restrained to "machine.h" and "machine-i386.cc". If you strip off the backend entirely, the main thing you'll need to fix up is the stringtable implementation, which I just stubbed as a linear list.Thanks! -Jon
Jul 24 2002
"Burton Radons" <loth users.sourceforge.net> wrote in message news:3D3D3B83.60203 users.sourceforge.net...dchar is another one (I don't know what header file it's from), and a source of a small problem - the code assumes wchar_t is two bytes at several points.Those dependencies are bugs, could you send me the file/line of them? dchar is more or less my failed attempt at a unified char/wchar/mbcs header.
Jul 23 2002
Walter wrote:"Burton Radons" <loth users.sourceforge.net> wrote in message news:3D3D3B83.60203 users.sourceforge.net...In lexer.c search for "case '\\':" and the StringConstant functions. Also, there are a couple uses of writeword where writedchar is intended, and a couple "/ 2" snippets should be "/ sizeof (wchar_t)", or perhaps "dchar". Also charConstant, but that's dead code anyway. Sorry that I can't be more specific, but I passed the file through indent.dchar is another one (I don't know what header file it's from), and a source of a small problem - the code assumes wchar_t is two bytes at several points.Those dependencies are bugs, could you send me the file/line of them?dchar is more or less my failed attempt at a unified char/wchar/mbcs header.I'd assumed it was a failed attempt at UTF-8, actually. :-)
Jul 24 2002
"Burton Radons" <loth users.sourceforge.net> wrote in message news:3D3C378A.3050508 users.sourceforge.net...Jan Knepper wrote:trickBurton Radons wrote:Well, it only took me an hour or two... So it's not that bad... One of the cute things to know is that Walter seems to use a compilerIt would have been great when you would have reported this before as I also already have done some of this.Oh, it just took this night anyway, unless if you have other code. It's (DMD, that is) now compiling a test properly and is throwing an unimplemented on Module::genobjfile, which is supposed to do everything in the backend. So everything past that point is backend.file.in DMC++ where he includes total.h as first header for every sourceAh, I was wondering why I needed to add so many includes. The only frontend code that's missing was stringbuffer.andI'm not interested in working on BrightD, so I'm now going ahead with writing my own backend. I'll put down lots of documentation as I figure out things and make a zip sometime.You mean, you are not interested in the GLUE layer for the D-front-endaddthe GCC-back-end? What are you writing a back-end for?Entertainment, education. Also, using GNU as a backend doesn't fit in my long-term plan of a compiler-in-a-library. I want to eventually convert DMD, with the backend, into D, and allow getting the parse tree using a single method call. I'd convert it to D now but I'm sick of Windows.If you want to make if 'public' we might be able to setup a newsgroup orYou might want to consider Gnu lightning or cgen (http://sources.redhat.com/cgen/) as starting points. Althought that will be less educational!it to http://www.opend.org/A bit premature but thanks for the offer. The code: int main () { return 45; } Now creates a correct object file. I'm 0.01% done. :-)
Jul 24 2002
Burton Radons wrote:You can do the same with GCC. I do not know which compiler you are using. Just use as compiler switch -include total.h and safe yourself a lot of changes! JanWell, it only took me an hour or two... So it's not that bad... One of the cute things to know is that Walter seems to use a compiler trick in DMC++ where he includes total.h as first header for every source file.Ah, I was wondering why I needed to add so many includes. The only frontend code that's missing was stringbuffer.
Jul 24 2002
Jan Knepper wrote:You mean, you are not interested in the GLUE layer for the D-front-end and the GCC-back-end? What are you writing a back-end for?Actually, I'm rather glad he does, it'll show me how to do it on other platforms, hopefully. Hi, BTW. I stumbled into this yesterday, and decided D is definitely worth looking at, and I'm already thinking of porting to a different operating system (VMS, and that's why an already written backend might be a good thing to have around).
Jan 12 2003
"Richard Levitte" <levitte stacken.kth.se> wrote in message news:avt0vk$u7q$1 digitaldaemon.com...Hi, BTW. I stumbled into this yesterday, and decided D is definitely worth looking at, and I'm already thinking of porting to a different operating system (VMS, and that's why an already written backend might be a good thing to have around).Glad to have you join us! -Walter
Jan 13 2003
Status update. The last few days I've been looking into various intermediate representation systems. I'll be going to some variety in the future, but for now I decided to stick with the crappy stack-based code it's currently producing. I was actually interested in LCC's system, but when I looked at the produced code I saw that it was really horrible. This is good, as it's comparable to GCC in the computer language shootout, so producing cruddy code is not a death knell by any means, although it has a bad worst-case. All integer arithmetic is done, and some of floating-point. Locals are in and I'm just now working on arrays and my next hurdle is to start to port, compile and use Phobos.
Jul 27 2002
Which compiler are you using to compile the d-font-end? Burton Radons wrote:Status update. The last few days I've been looking into various intermediate representation systems. I'll be going to some variety in the future, but for now I decided to stick with the crappy stack-based code it's currently producing. I was actually interested in LCC's system, but when I looked at the produced code I saw that it was really horrible. This is good, as it's comparable to GCC in the computer language shootout, so producing cruddy code is not a death knell by any means, although it has a bad worst-case. All integer arithmetic is done, and some of floating-point. Locals are in and I'm just now working on arrays and my next hurdle is to start to port, compile and use Phobos.
Jul 27 2002
It's that time again. Classes are working, as is TypeInfo. TypeInfo took quite a bit of code and looking-into to get operational; you have to look for a VarExp referring to a TypeInfoDeclaration and output it in the module, generating at least an instance. I go all out and generate both the instance and a subclass of TypeInfo to make everything on-the-level; partial subtyping works (creating a specialised vtable but using TypeInfo as the class), but is just asking for problems to show up in low-level user code. The milestone I'm aiming for here is to finish up the arrays without doing any stubbing on the way. Once that is done and I put up version 0.0.2, the only missing language features will be exceptions and threading concerns, long, complex, and associative arrays, switch, and other things. This would make me about 30% finished, so the body is already done, with the easier gaps ahead.
Aug 03 2002