This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Demangle itanium symbols in mingw mode
ClosedPublic

Authored by mstorsjo on Sep 1 2019, 2:26 PM.

Details

Summary

Maybe the msvc demangling should be within if (!mingw)? Performance wise it's probably irrelevant, but the itanium demangling, in combination with dllimport and i386 leading underscores, ended up as a few more lines, so an if (mingw) around it makes it a bit clearer.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Sep 1 2019, 2:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 1 2019, 2:27 PM
ruiu added a comment.Sep 1 2019, 9:54 PM

I'm not very familiar with MinGW, but is Itanium name mangling in use on MinGW? MinGW is intended to be a native development environment for Windows, so I thought that they naturally use the platform way of mangling symbols.

I'm not very familiar with MinGW, but is Itanium name mangling in use on MinGW? MinGW is intended to be a native development environment for Windows, so I thought that they naturally use the platform way of mangling symbols.

Yes, MinGW uses Itanium name mangling only.

Yes, MinGW is intended to be a native development environment, but despite this (for historical reasons) it has done a lot of things very differently, due to being based on the GNU tools originally, and generally doing unixy things in COFF files. GCC doesn't support the MSVC C++ ABI at all, and the name mangling is only a very small part of the whole C++ ABI.

Generally the level of compatibility is that you can call between DLLs built by different tools, as long as it only has a pure C API, but you shouldn't expect to mix object files (or static libraries) between MSVC/link.exe and GCC/ld.bfd.

ruiu accepted this revision.Sep 1 2019, 10:49 PM

LGTM

Thank you for the explanation!

This revision is now accepted and ready to land.Sep 1 2019, 10:49 PM
This revision was automatically updated to reflect the committed changes.
rnk added inline comments.Sep 3 2019, 11:35 AM
lld/trunk/COFF/Symbols.cpp
31

It is trivial to disambiguate Itanium and MSVC symbols just by looking at the prefix. For both mangling types, we should ignore __imp_ prefixes in the same way. Then, Itanium names match _+Z, and Microsoft names start with ?.

I think we should get rid of the two lld::demangleItanium/MSVC variants, add a check for ? in llvm::demangle, and standardize on that. The COFF demangle helper can do the __imp_ handling. Make sense?

mstorsjo marked an inline comment as done.Sep 3 2019, 12:24 PM
mstorsjo added inline comments.
lld/trunk/COFF/Symbols.cpp
31

Sounds sensible, I'll put it on my backlog and give it a shot.