File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -3388,15 +3388,23 @@ namespace Cpp {
33883388 static inline std::string DemangleNameForDlsym (const std::string& name) {
33893389 std::string nameForDlsym = name;
33903390
3391- #if defined(R__MACOSX) || defined(R__WIN32)
3391+ static bool is_demangle_active = false ;
3392+ static bool demangle = false ;
3393+ if (!is_demangle_active) {
3394+ auto & I = getInterp ();
3395+ llvm::orc::LLJIT& EE = *compat::getExecutionEngine (I);
3396+ auto t = EE.getTargetMachine ().getTargetTriple ();
3397+ demangle = t.isOSDarwin () || t.isWindows ();
3398+ is_demangle_active = true ;
3399+ }
3400+
33923401 // The JIT gives us a mangled name which has an additional leading underscore
33933402 // on macOS and Windows, for instance __ZN8TRandom34RndmEv. However, dlsym
33943403 // requires us to remove it.
33953404 // FIXME: get this information from the DataLayout via getGlobalPrefix()!
3396- if (nameForDlsym[0 ] == ' _' )
3405+ if (demangle && nameForDlsym[0 ] == ' _' )
33973406 nameForDlsym.erase (0 , 1 );
3398- #endif // R__MACOSX
3399-
3407+ }
34003408 return nameForDlsym;
34013409 }
34023410
You can’t perform that action at this time.
0 commit comments