www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D tools build problem

reply Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
Hello all,

I've started encountering a problem recently when building the D tools (i.e. 
rdmd et al.).

$ make -f posix.mak
../dmd/src/dmd -m64  -ofgenerated/linux/64/rdmd rdmd.d
Error: cannot find source code for runtime library file 'object.d'
        dmd might not be correctly installed. Run 'dmd -man' for installation 
instructions.
Specify path to file 'object.d' with -I switch
make: *** [generated/linux/64/rdmd] Error 1

I take it the error is because the makefile tries to build using ../dmd/src/dmd 
(which exists, I've built it) but can't find the corresponding runtime files.

There's an easy workaround -- use

     make -f posix.mak DMD=/opt/bin/dmd

(i.e. using the just-installed-2-minutes-before dmd), but it's annoying.  Is 
this a known issue?  Is there something I need to change about my build setup 
that I've missed?

Thanks & best wishes,

     -- Joe
Feb 11 2014
parent reply "Dicebot" <public dicebot.lv> writes:
On Tuesday, 11 February 2014 at 21:16:34 UTC, Joseph Rushton 
Wakeling wrote:
 I take it the error is because the makefile tries to build 
 using ../dmd/src/dmd (which exists, I've built it) but can't 
 find the corresponding runtime files.
It looks for ../druntime - this is where object.di is located, not in compiler repo. You need all of those - dmd, druntime and phobos build before tools.
Feb 11 2014
next sibling parent "Dicebot" <public dicebot.lv> writes:
P.S. Though I don't know if makefile is up to date for tools repo
- I have always build needed tools by manually supplying import
paths and invoking dmd directly.
Feb 11 2014
prev sibling next sibling parent reply Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 11/02/14 22:22, Dicebot wrote:
 It looks for ../druntime - this is where object.di is located, not in compiler
 repo. You need all of those - dmd, druntime and phobos build before tools.
Exactly what I thought, but they _have_ been built and they are located in the right places. That's why I was baffled by the error message.
Feb 11 2014
parent reply "Dicebot" <public dicebot.lv> writes:
On Tuesday, 11 February 2014 at 22:10:21 UTC, Joseph Rushton 
Wakeling wrote:
 Exactly what I thought, but they _have_ been built and they are 
 located in the right places.  That's why I was baffled by the 
 error message.
../dmd/src/dmd -I../druntime/src -I../phobos rdmd.d ;)
Feb 11 2014
next sibling parent Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 11/02/14 23:18, Dicebot wrote:
 On Tuesday, 11 February 2014 at 22:10:21 UTC, Joseph Rushton Wakeling wrote:
 Exactly what I thought, but they _have_ been built and they are located in the
 right places.  That's why I was baffled by the error message.
../dmd/src/dmd -I../druntime/src -I../phobos rdmd.d
Yeah, yeah. :-P I mean I was baffled that the error was occurring and at first glance assumed it must be something weirder. Didn't anybody test this? I'll see if I can knock up a patch ... :-)
Feb 11 2014
prev sibling next sibling parent reply Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 11/02/14 23:33, Joseph Rushton Wakeling wrote:
 On 11/02/14 23:18, Dicebot wrote:
 On Tuesday, 11 February 2014 at 22:10:21 UTC, Joseph Rushton Wakeling wrote:
 Exactly what I thought, but they _have_ been built and they are located in the
 right places.  That's why I was baffled by the error message.
../dmd/src/dmd -I../druntime/src -I../phobos rdmd.d
Yeah, yeah. :-P I mean I was baffled that the error was occurring and at first glance assumed it must be something weirder. Didn't anybody test this? I'll see if I can knock up a patch ... :-)
I've attached my current patch. It should be possible to apply this to master, if anyone wants to test it. It works for everything except the CURL_TOOLS which invariably fail to link with the error described at the bottom of this email. It looks like a main() function is absent where one is expected, but my make-fu is not good enough to understand what's wrong with the relevant lines in the makefile: #dreadful custom step because of libcurl dmd linking problem (Bugzilla 7044) $(CURL_TOOLS): $(ROOT)/%: %.d $(DMD) $(MODEL_FLAG) $(DFLAGS) -c -of$( ).o $(<) ($(DMD) $(MODEL_FLAG) $(DFLAGS) -v -of$( ) $( ).o 2>/dev/null | grep '\-Xlinker' | cut -f2- -d' ' ; echo -lcurl ) | xargs $(CC) Note that the $(MODEL_FLAG) $(DFLAGS) entries here are my addition. Absent the $(DFLAGS) entry the build will fail with the same issue of being unable to find object.d. With these flags in place, the following error message is produced: (../dmd/src/dmd -m64 -I../druntime/import -I../phobos -L-L../phobos/generated/linux/release/64 -w -v -ofgenerated/linux/64/dget generated/linux/64/dget.o 2>/dev/null | grep '\-Xlinker' | cut -f2- -d' ' ; echo -lcurl ) | xargs gcc /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 1 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 2 has invalid symbol index 2 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 3 has invalid symbol index 2 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 4 has invalid symbol index 11 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 5 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 6 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 7 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 8 has invalid symbol index 12 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 9 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 10 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 11 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 12 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 13 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 14 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 15 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 16 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 17 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 18 has invalid symbol index 13 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 19 has invalid symbol index 21 /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): relocation 0 has invalid symbol index 2 /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status make: *** [generated/linux/64/dget] Error 123
Feb 11 2014
parent reply "Martin Nowak" <code dawg.eu> writes:
On Tuesday, 11 February 2014 at 23:06:27 UTC, Joseph Rushton 
Wakeling wrote:
 With these flags in place, the following error message is 
 produced:

 (../dmd/src/dmd -m64 -I../druntime/import -I../phobos
 -L-L../phobos/generated/linux/release/64  -w -v 
 -ofgenerated/linux/64/dget
 generated/linux/64/dget.o 2>/dev/null | grep '\-Xlinker' | cut 
 -f2- -d' ' ; echo
 -lcurl  ) | xargs gcc
What are the actual gcc arguments? For me running ../dmd/src/dmd -m64 -I../druntime/import -I../phobos -L-L../phobos/generated/linux/release/64 -w -v -ofgenerated/linux/64/dget generated/linux/64/dget.o 2>/dev/null | grep '\-Xlinker' prints gcc generated/linux/64/dget.o -o generated/linux/64/dget -m64 -L../phobos/generated/linux/release/64 -L/usr/lib64 -Xlinker --export-dynamic -l:libphobos2.a -lpthread -lm -lrt. Also check wheter the dget.o object has a D main. nm generated/linux/64/changed.o | grep _Dmain 0000000000000000 T _Dmain
Mar 01 2014
next sibling parent Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 01/03/14 23:35, Martin Nowak wrote:
 What are the actual gcc arguments?
Thanks for the advice here -- I appreciate it :-)
 For me running

 ../dmd/src/dmd -m64 -I../druntime/import -I../phobos
 -L-L../phobos/generated/linux/release/64  -w -v -ofgenerated/linux/64/dget
 generated/linux/64/dget.o 2>/dev/null | grep '\-Xlinker'

 prints

 gcc generated/linux/64/dget.o -o generated/linux/64/dget -m64
 -L../phobos/generated/linux/release/64 -L/usr/lib64 -Xlinker --export-dynamic
 -l:libphobos2.a -lpthread -lm -lrt.
For me: $ ../dmd/src/dmd -m64 -I../druntime/import -I../phobos -L-L../phobos/generated/linux/release/64 -w -v -ofgenerated/linux/64/dget generated/linux/64/dget.o binary ../dmd/src/dmd version v2.065-devel-0d01545 config /etc/dmd.conf gcc generated/linux/64/dget.o -o generated/linux/64/dget -m64 -L../phobos/generated/linux/release/64 -l:libphobos2.a -lpthread -lm -lrt If I try literally using the statement you posted, I get no output at all.
 Also check wheter the dget.o object has a D main.

 nm generated/linux/64/changed.o | grep _Dmain

 0000000000000000 T _Dmain
$ nm generated/linux/64/dget.o | grep _Dmain 0000000000000000 T _Dmain U _Dmain
Mar 01 2014
prev sibling parent Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 02/03/14 00:07, Joseph Rushton Wakeling wrote:
 config    /etc/dmd.conf
This is interesting. My system doesn't have an /etc/dmd.conf file: I always place dmd.conf in the same directory as the dmd binary. Could it be that people not seeing my linker errors are doing so because the tools build is picking up on flags in an /etc/dmd.conf introduced with an earlier install?
Mar 01 2014
prev sibling parent Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 12/02/14 00:06, Joseph Rushton Wakeling wrote:
 I've attached my current patch.  It should be possible to apply this to master,
 if anyone wants to test it.
I fixed my patch :-) https://github.com/D-Programming-Language/tools/pull/117
Feb 20 2014
prev sibling parent Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 11/02/14 23:10, Joseph Rushton Wakeling wrote:
 On 11/02/14 22:22, Dicebot wrote:
 It looks for ../druntime - this is where object.di is located, not in compiler
 repo. You need all of those - dmd, druntime and phobos build before tools.
Exactly what I thought, but they _have_ been built and they are located in the right places. That's why I was baffled by the error message.
Actually, on looking inside the tools makefile, it's not looking for ../druntime at all. The D compiler has been hardcoded to ../dmd/src/dmd but there is no DRUNTIME_PATH defined as there is in e.g. the phobos posix.mak.
Feb 11 2014