www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - dmd -D == ouch!!

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

While trying out David Simcha's std.rational (see: 
http://forum.dlang.org/post/mailman.1774.1380289646.1719.digital
ars-d puremagic.com 
and please offer feedback if this is of interest to you...), I tried building 
the docs and ran into the following amusing error message:

$ dmd -D rational.d

/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
--- errorlevel 1

Ouch, I think you'll agree!

Of course, it only took a second's thought to realize that I should have used

     dmd -o- -D rational.d

... but the error message is pretty opaque.  How feasible would it be to handle 
the case where the -D flag is passed with a nicer error message limiting itself
to:

     (.text+0x20): undefined reference to `main'
     collect2: error: ld returned 1 exit status
     To build only documentation, use dmd -o- -D

(I'd ask for it to just build the docs without erroring, but that would surely 
make for overlooked errors in some cases where you _should_ find main.)

Thanks & best wishes,

     -- Joe
Sep 27 2013
parent reply "Damien" <damien.levac gmail.com> writes:
Hi,

 From "The D Programming Language" by Andrei Alexandrescu: "If you 
forget about --main, don't worry; the linker will fluently and 
baroquely remind you of that in its native language, encrypted 
Klingon."

So I think that your issue is well known and not a development 
priority at the moment... :P

Cheers,
Damien


 ... but the error message is pretty opaque.  How feasible would 
 it be to handle the case where the -D flag is passed with a 
 nicer error message limiting itself to:

     (.text+0x20): undefined reference to `main'
     collect2: error: ld returned 1 exit status
     To build only documentation, use dmd -o- -D
Sep 28 2013
parent Joseph Rushton Wakeling <joseph.wakeling webdrake.net> writes:
On 28/09/13 15:38, Damien wrote:
  From "The D Programming Language" by Andrei Alexandrescu: "If you forget about
 --main, don't worry; the linker will fluently and baroquely remind you of that
 in its native language, encrypted Klingon."
If you ever forget why we all love Andrei, a quick read of his books quickly reminds you ... :-)
 So I think that your issue is well known and not a development priority at the
 moment... :P
My request is subtly different from a plea for a better error message when the user misses off -main ;-) If the user calls dmd -D on a file where "main" is not defined, the likely intention is that they want to build the docs and only the docs, and the Klingon is therefore slightly more disconcerting than usual. So, slightly more need for a "nice" error message. It was obvious to me because I'm used to D -- for a novice it could be nasty.
Sep 29 2013