On Thu, 11 Nov 2010 08:20:46 -0500, Denis Koroskin <2kor...@gmail.com> wrote:

On Thu, 11 Nov 2010 15:54:50 +0300, Steven Schveighoffer <schvei...@yahoo.com> wrote:

Just saw another linker error in d.learn, and it got me thinking

dmd just calls the linker, and the linker spits out link errors. But what if we had a 'linker wrapper' program which translated mangled names into demangled names? It would at least help people understand the problem better. How many times does a newbie come back and say "I have this problem, and dmd spits out some weird message I don't understand" and it takes a person who half-speaks mangled d names to understand what the name is.

Given that D already includes a demangler, wouldn't it be rather trivial to write this program in D?

I know it would make my life a bit better.

Thoughts?  Takers?

-Steve

I suggested that previously [1], and I think that need to be a part of DMD for a simple reason: some of the names can't be demangled because their are somewhat "hashed" to avoid limitations such as long literal name. E.g. "_D4math6Mбrix9х44F32__T3addTCЂ–ЎZЂ„ќFЂ—ќЂ˜ґЂ—˜".

Not sure we can do anything about that, if we're only giving dmd object files to work with.

I think we need to implement something different in terms of 'hashing'. It's another idea I've had, but not sure if I've expressed it. Typically, you have things like this in a module:

struct Y(T) {}

struct X(T)
{
   void foo(Y!T y) {...}
}

where this is in std.amodule. The seemingly small foo symbol gets exploded to the equivalent of:

std.amodule.X!int.foo(std.amodule.Y!int)

I see a lot of repetition in there. I think we can do some kind of lossless compression with name mangling so you represent repetetive symbols such as module names and type parameters as back references.

These would also be demangleable.


Given that dmd calls a linker internally, it could also retrieve linker errors (if any present), translate and then show them, with a list of suggestions to fix the problem if possible. Here are an example:

module test1;
void foo() {}

module test2;
import test1;
void main() { foo(); }

#dmd test2.d

Desired output: Error: No implementation found for method void foo() defined in module test1. Try linking with test1.d
Actual output: Error 42: Symbol Undefined _D5test13fooFZv

This would be cool too. BTW, does anyone know if the linkers used by DMD allow options to output easily-parsable errors?

-Steve

Reply via email to