On Mon, 14 Feb 2011 13:24:26 -0500, Walter Bright <newshou...@digitalmars.com> wrote:

Steven Schveighoffer wrote:
On Sun, 13 Feb 2011 14:12:02 -0500, Walter Bright <newshou...@digitalmars.com> wrote:

Vladimir Panteleev wrote:
On Sun, 13 Feb 2011 20:26:50 +0200, Walter Bright <newshou...@digitalmars.com> wrote:

golgeliyele wrote:
I don't think C++ and gcc set a good bar here.

Short of writing our own linker, we're a bit stuck with what ld does.
That's not true. The compiler has knowledge of what symbols will be passed to the linker, and can display its own, much nicer error messages. I've mentioned this in our previous discussion on this topic.

Not without reading the .o files passed to the linker, and the libraries, and figuring out what would be pulled in from those libraries. In essence, the compiler would have to become a linker.

It's not impossible, but is a tremendous amount of work in order to improve one error message, and one error message that generations of C and C++ programmers are comfortable dealing with.
I'm not saying that this should be done and is worth the tremendous effort.
 However, when linking a c++ app without a main, here is what I get:
/usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
 When linking a d app without a main, we get:
/home/steves/dmd-2.051/linux/bin/../lib/libphobos2.a(dmain2_517_1a5.o): In function `_D2rt6dmain24mainUiPPaZi7runMainMFZv': src/rt/dmain2.d:(.text._D2rt6dmain24mainUiPPaZi7runMainMFZv+0x16): undefined reference to `_Dmain' /home/steves/dmd-2.051/linux/bin/../lib/libphobos2.a(deh2_4e7_525.o): In function `_D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable': src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0x4): undefined reference to `_deh_beg' src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0xc): undefined reference to `_deh_beg' src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0x13): undefined reference to `_deh_end' src/rt/deh2.d:(.text._D2rt4deh213__eh_finddataFPvZPS2rt4deh213DHandlerTable+0x37): undefined reference to `_deh_end' /home/steves/dmd-2.051/linux/bin/../lib/libphobos2.a(thread_eb_258.o): In function `_D4core6thread6Thread6__ctorMFZC4core6thread6Thread': src/core/thread.d:(.text._D4core6thread6Thread6__ctorMFZC4core6thread6Thread+0x1d): undefined reference to `_tlsend' src/core/thread.d:(.text._D4core6thread6Thread6__ctorMFZC4core6thread6Thread+0x24): undefined reference to `_tlsstart' /home/steves/dmd-2.051/linux/bin/../lib/libphobos2.a(thread_ee_6e4.o): In function `thread_attachThis': src/core/thread.d:(.text.thread_attachThis+0x53): undefined reference to `_tlsstart' src/core/thread.d:(.text.thread_attachThis+0x5c): undefined reference to `_tlsend' /home/steves/dmd-2.051/linux/bin/../lib/libphobos2.a(thread_e8_713.o): In function `thread_entryPoint': src/core/thread.d:(.text.thread_entryPoint+0x29): undefined reference to `_tlsend' src/core/thread.d:(.text.thread_entryPoint+0x2f): undefined reference to `_tlsstart'
collect2: ld returned 1 exit status
--- errorlevel 1
Let's not pretend that generations of c/C++ coders are going to attribute this slew of errors to a missing main function.

I understand what you're saying, but experienced C/C++ programmers are used to paying attention only to the first error message :-)

Really? I find that in a mess of linker errors, the error isn't always the first line. It doesn't help that the name of the function "missing" is not called main (as it is called in the d source file).

But Like I said, it's not critical -- the error is listed, it's just not as user-friendly as the C++ error.


I personally think we need to get the linker to demangle symbols better. That would go a long way...

Not for the above messages.

I meant to demangle things like _D2rt6dmain24mainUiPPaZi7runMainMFZv Note how the _Dmain is buried between some of these large symbols. Those seemingly random nonsense symbols make the whole error listing seem unreadable.

-Steve

Reply via email to