[cfe-dev] Get mangled names C++

Paul Davey plmdvy at gmail.com
Fri Jul 16 05:17:36 PDT 2010


On Fri, Jul 16, 2010 at 7:35 PM, John McCall <rjmccall at apple.com> wrote:
> On Jul 15, 2010, at 11:55 PM, Frank Fuchs wrote:
>> Ok I need and want native performance - it's a scientific application and although very complex things will be referred to the core methods I cannot stop users from writing large loops and complain about the performance. In the worst case they crash the whole thing ... but I'm willing to take that risk :D.
>
> Well, your call.
>
>> Now concerning your answer I do not see how it might help me. If I understand it correctly you have implemented a way to get information about the Decl of jitted methods. Now how does that help me, because I still think I need to declare the mangled names to the JIT, and for this purpose I need to now them at compile time of the host application.
>
> Oh, are you just asking for a way to figure out a mangling statically?  I'm sorry, I really thought you were trying to do this dynamically.  I'm afraid there really isn't a convenient way of getting a mangling for a declaration string from the command line.  It'd be a fun little hack, but nobody's done it yet.
>
> Honestly, I'd suggest just looking in your executable:  if you know what .o file contains that symbol, just nm that file and grep for the name, which is always a substring of the mangling.
>
> For example, there's a method on Sema called GetTypeForDeclarator that's implemented in SemaType.cpp.
>
> % nm lib/Sema/Debug+Asserts/SemaType.o | grep GetTypeForDeclarator
> 00000000001ebd90 s L___func__._ZN5clang4Sema20GetTypeForDeclaratorERNS_10DeclaratorEPNS_5ScopeEPPNS_7TagDeclE
> 0000000000002670 T __ZN5clang4Sema20GetTypeForDeclaratorERNS_10DeclaratorEPNS_5ScopeEPPNS_7TagDeclE
> 00000000001eea38 S __ZN5clang4Sema20GetTypeForDeclaratorERNS_10DeclaratorEPNS_5ScopeEPPNS_7TagDeclE.eh
>
> The function is the one in the middle;  the mangled name is that, minus the first leading underscore.
>
> John.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>

There are several problems with what you are trying to do,

Firstly it will only work with gcc or something that uses exactly the
same ABI as clang so for now no MSVC
secondly the JIT is supposed to be able to use dlsym to resolve
functions at runtime but this only works on non windows,
Putting manglings into your code manually is horrible and will only
break stuff down the road.




More information about the cfe-dev mailing list