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 @@ -3367,15 +3367,23 @@ namespace Cpp {
33673367 static inline std::string DemangleNameForDlsym (const std::string& name) {
33683368 std::string nameForDlsym = name;
33693369
3370- #if defined(R__MACOSX) || defined(R__WIN32)
3370+ static bool is_demangle_active = false ;
3371+ static bool demangle = false ;
3372+ if (!is_demangle_active) {
3373+ auto & I = getInterp ();
3374+ llvm::orc::LLJIT& EE = *compat::getExecutionEngine (I);
3375+ auto t = EE.getTargetMachine ().getTargetTriple ();
3376+ demangle = t.isOSDarwin () || t.isWindows ();
3377+ is_demangle_active = true ;
3378+ }
3379+
33713380 // The JIT gives us a mangled name which has an additional leading underscore
33723381 // on macOS and Windows, for instance __ZN8TRandom34RndmEv. However, dlsym
33733382 // requires us to remove it.
33743383 // FIXME: get this information from the DataLayout via getGlobalPrefix()!
3375- if (nameForDlsym[0 ] == ' _' )
3384+ if (demangle && nameForDlsym[0 ] == ' _' )
33763385 nameForDlsym.erase (0 , 1 );
3377- #endif // R__MACOSX
3378-
3386+ }
33793387 return nameForDlsym;
33803388 }
33813389
You can’t perform that action at this time.
0 commit comments