www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Porting DMD compiler to haiku OS

reply "iridium" <asargis live.com> writes:
Good day. Sorry for my bad english. I'm trying to build the dmd 
compiler to Haiku OS. At compile time get the following error: 
http://itmages.ru/image/view/1652327/b501e37b

What could be the reason? Thanks.
May 05 2014
next sibling parent reply "Paulo Pinto" <pjmlp progtools.org> writes:
On Tuesday, 6 May 2014 at 06:33:51 UTC, iridium wrote:
 Good day. Sorry for my bad english. I'm trying to build the dmd 
 compiler to Haiku OS. At compile time get the following error: 
 http://itmages.ru/image/view/1652327/b501e37b

 What could be the reason? Thanks.

Have you already updated all "version ()" blocks with Haiku specific code? -- Paulo
May 06 2014
parent reply "Daniel Murphy" <yebbliesnospam gmail.com> writes:
"iridium"  wrote in message news:ltcxhbcqltnltbiddqyy forum.dlang.org...

 Yes. optabtgen now runs correctly. Now another error. I understand the 
 error during assembly: http://itmages.ru/image/view/1652519/5fa513e0

Linker error actually. The first one is saying it can't find Obj::init which is in backend/cgobj.c inside a #if OMFOBJ and backend/elfobj.c inside #if ELFOBJ. I'd guess you need to fix the conditioin in cdef.h to include TARGET_HAIKU -#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS) +#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU) And the rest are probably similar things.
May 06 2014
parent reply Jacob Carlborg <doob me.com> writes:
On 08/05/14 05:54, iridium wrote:

 Which as I collected a druntime. But in the link step, the following:
 http://itmages.ru/image/view/1655530/a5ca9557

You need to link with the C library as well. When compiling with DMD, it uses GCC to link. -- /Jacob Carlborg
May 07 2014
parent Jacob Carlborg <doob me.com> writes:
On 08/05/14 08:53, iridium wrote:

 That's what happens when linking:
 http://itmages.ru/image/view/1655772/669acb30

You need to link with both Phobos and the C standard library. Run "dmd -v main.d" and look at the linking step at the end. -- /Jacob Carlborg
May 08 2014
prev sibling next sibling parent "iridium" <asargis live.com> writes:
On Tuesday, 6 May 2014 at 07:23:47 UTC, Paulo Pinto wrote:
 On Tuesday, 6 May 2014 at 06:33:51 UTC, iridium wrote:
 Good day. Sorry for my bad english. I'm trying to build the 
 dmd compiler to Haiku OS. At compile time get the following 
 error: http://itmages.ru/image/view/1652327/b501e37b

 What could be the reason? Thanks.

Have you already updated all "version ()" blocks with Haiku specific code? -- Paulo

Yes. optabtgen now runs correctly. Now another error. I understand the error during assembly: http://itmages.ru/image/view/1652519/5fa513e0
May 06 2014
prev sibling next sibling parent "iridium" <asargis live.com> writes:
On Wednesday, 7 May 2014 at 06:21:48 UTC, Daniel Murphy wrote:
 "iridium"  wrote in message 
 news:ltcxhbcqltnltbiddqyy forum.dlang.org...

 Yes. optabtgen now runs correctly. Now another error. I 
 understand the error during assembly: 
 http://itmages.ru/image/view/1652519/5fa513e0

Linker error actually. The first one is saying it can't find Obj::init which is in backend/cgobj.c inside a #if OMFOBJ and backend/elfobj.c inside #if ELFOBJ. I'd guess you need to fix the conditioin in cdef.h to include TARGET_HAIKU -#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS) +#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU) And the rest are probably similar things.

I was able to build a compiler. Follow the link to see the result: http://itmages.ru/image/view/1654442/ecbf7af1 Now the problem with the assembly of the druntime... http://itmages.ru/image/view/1654445/31a30d8d
May 07 2014
prev sibling next sibling parent "Joakim" <dlang joakim.airpost.net> writes:
On Wednesday, 7 May 2014 at 11:40:59 UTC, iridium wrote:
 On Wednesday, 7 May 2014 at 06:21:48 UTC, Daniel Murphy wrote:
 "iridium"  wrote in message 
 news:ltcxhbcqltnltbiddqyy forum.dlang.org...

 Yes. optabtgen now runs correctly. Now another error. I 
 understand the error during assembly: 
 http://itmages.ru/image/view/1652519/5fa513e0

Linker error actually. The first one is saying it can't find Obj::init which is in backend/cgobj.c inside a #if OMFOBJ and backend/elfobj.c inside #if ELFOBJ. I'd guess you need to fix the conditioin in cdef.h to include TARGET_HAIKU -#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS) +#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU) And the rest are probably similar things.

I was able to build a compiler. Follow the link to see the result: http://itmages.ru/image/view/1654442/ecbf7af1 Now the problem with the assembly of the druntime... http://itmages.ru/image/view/1654445/31a30d8d

Take a look at my recent patches to add Android/x86 support to druntime: https://github.com/D-Programming-Language/druntime/pull/681 https://github.com/D-Programming-Language/druntime/pull/734 https://github.com/D-Programming-Language/druntime/pull/738 You will need at least the first two to get druntime working with a trimmed down mak/SRCS, then a version of the last pull to get all of druntime to compile.
May 07 2014
prev sibling next sibling parent "iridium" <asargis live.com> writes:
On Wednesday, 7 May 2014 at 15:26:23 UTC, Joakim wrote:
 On Wednesday, 7 May 2014 at 11:40:59 UTC, iridium wrote:
 On Wednesday, 7 May 2014 at 06:21:48 UTC, Daniel Murphy wrote:
 "iridium"  wrote in message 
 news:ltcxhbcqltnltbiddqyy forum.dlang.org...

 Yes. optabtgen now runs correctly. Now another error. I 
 understand the error during assembly: 
 http://itmages.ru/image/view/1652519/5fa513e0

Linker error actually. The first one is saying it can't find Obj::init which is in backend/cgobj.c inside a #if OMFOBJ and backend/elfobj.c inside #if ELFOBJ. I'd guess you need to fix the conditioin in cdef.h to include TARGET_HAIKU -#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS) +#define ELFOBJ (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_SOLARIS || TARGET_HAIKU) And the rest are probably similar things.

I was able to build a compiler. Follow the link to see the result: http://itmages.ru/image/view/1654442/ecbf7af1 Now the problem with the assembly of the druntime... http://itmages.ru/image/view/1654445/31a30d8d

Take a look at my recent patches to add Android/x86 support to druntime: https://github.com/D-Programming-Language/druntime/pull/681 https://github.com/D-Programming-Language/druntime/pull/734 https://github.com/D-Programming-Language/druntime/pull/738 You will need at least the first two to get druntime working with a trimmed down mak/SRCS, then a version of the last pull to get all of druntime to compile.

following: http://itmages.ru/image/view/1655530/a5ca9557
May 07 2014
prev sibling next sibling parent "iridium" <asargis live.com> writes:
On Thursday, 8 May 2014 at 06:07:23 UTC, Jacob Carlborg wrote:
 On 08/05/14 05:54, iridium wrote:

 Which as I collected a druntime. But in the link step, the 
 following:
 http://itmages.ru/image/view/1655530/a5ca9557

You need to link with the C library as well. When compiling with DMD, it uses GCC to link.

That's what happens when linking: http://itmages.ru/image/view/1655772/669acb30
May 07 2014
prev sibling next sibling parent "iridium" <asargis live.com> writes:
On Thursday, 8 May 2014 at 07:55:04 UTC, Jacob Carlborg wrote:
 On 08/05/14 08:53, iridium wrote:

 That's what happens when linking:
 http://itmages.ru/image/view/1655772/669acb30

You need to link with both Phobos and the C standard library. Run "dmd -v main.d" and look at the linking step at the end.

dmd -v test.d result: http://itmages.ru/image/view/1655879/d0bb1c62 gcc -o main test.o ../../phobos/generated/haiku/release/32/libphobos2.a -lstdc++ -lroot result: http://itmages.ru/image/view/1655886/0be9d48f
May 08 2014
prev sibling next sibling parent "Joakim" <dlang joakim.airpost.net> writes:
On Thursday, 8 May 2014 at 08:18:16 UTC, iridium wrote:
 On Thursday, 8 May 2014 at 07:55:04 UTC, Jacob Carlborg wrote:
 On 08/05/14 08:53, iridium wrote:

 That's what happens when linking:
 http://itmages.ru/image/view/1655772/669acb30

You need to link with both Phobos and the C standard library. Run "dmd -v main.d" and look at the linking step at the end.

dmd -v test.d result: http://itmages.ru/image/view/1655879/d0bb1c62 gcc -o main test.o ../../phobos/generated/haiku/release/32/libphobos2.a -lstdc++ -lroot result: http://itmages.ru/image/view/1655886/0be9d48f

Try linking to druntime alone first, before you start messing with phobos. You'll notice that the makefile for druntime builds a libdruntime-haiku32.a library, if you modify the makefile for Haiku. Try building some simple executables with that first before moving on to phobos. You need to go through all the TARGET_FREEBSD blocks in the dmd source and all the version(FreeBSD) blocks in druntime and add TARGET_HAIKU, version(Haiku), and the appropriate source for Haiku inside those blocks. We can't sit here and help you do that, unless it's something truly unusual that you're unable to figure out. Most of these errors seem to be the result of missing some blocks here and there. Admittedly, porting to a new OS is not a small job, and you seem to be going pretty fast. Keep plugging away at it and I'm sure you'll be able to figure it out.
May 08 2014
prev sibling next sibling parent "iridium" <asargis live.com> writes:
On Thursday, 8 May 2014 at 10:02:53 UTC, Joakim wrote:
 On Thursday, 8 May 2014 at 08:18:16 UTC, iridium wrote:
 On Thursday, 8 May 2014 at 07:55:04 UTC, Jacob Carlborg wrote:
 On 08/05/14 08:53, iridium wrote:

 That's what happens when linking:
 http://itmages.ru/image/view/1655772/669acb30

You need to link with both Phobos and the C standard library. Run "dmd -v main.d" and look at the linking step at the end.

dmd -v test.d result: http://itmages.ru/image/view/1655879/d0bb1c62 gcc -o main test.o ../../phobos/generated/haiku/release/32/libphobos2.a -lstdc++ -lroot result: http://itmages.ru/image/view/1655886/0be9d48f

Try linking to druntime alone first, before you start messing with phobos. You'll notice that the makefile for druntime builds a libdruntime-haiku32.a library, if you modify the makefile for Haiku. Try building some simple executables with that first before moving on to phobos. You need to go through all the TARGET_FREEBSD blocks in the dmd source and all the version(FreeBSD) blocks in druntime and add TARGET_HAIKU, version(Haiku), and the appropriate source for Haiku inside those blocks. We can't sit here and help you do that, unless it's something truly unusual that you're unable to figure out. Most of these errors seem to be the result of missing some blocks here and there. Admittedly, porting to a new OS is not a small job, and you seem to be going pretty fast. Keep plugging away at it and I'm sure you'll be able to figure it out.

that. I try to building some simple executables and get this and that: http://itmages.ru/image/view/1657447/92442093 dmd -c -v main.d: http://itmages.ru/image/view/1657453/3f46cbd9 main.d contains: module main; void main() { }
May 09 2014
prev sibling parent "Joakim" <dlang joakim.airpost.net> writes:
On Friday, 9 May 2014 at 07:21:36 UTC, iridium wrote:
 I'm not asking to solve the problem for me. Just tell me what 
 is that. I try to building some simple executables and get this 
 and that: http://itmages.ru/image/view/1657447/92442093

__stdoutp and __stderrp. My guess is that you simply cut and pasted the stdc.stdio block from FreeBSD, but Haiku likely doesn't define the same symbols. You need to look at stdio.h and other header files in Haiku and fill those druntime blocks in with the declarations appropriate to Haiku. It also looks like you messed something up with setting up rt.sections_haiku. Finally, as Jacob mentioned, you should look at the flags that dmd normally uses when it links, as you're missing some of those.
May 09 2014