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 @@ -3441,15 +3441,23 @@ namespace Cpp {
3441
3441
static inline std::string DemangleNameForDlsym (const std::string& name) {
3442
3442
std::string nameForDlsym = name;
3443
3443
3444
- #if defined(R__MACOSX) || defined(R__WIN32)
3444
+ static bool is_demangle_active = false ;
3445
+ static bool demangle = false ;
3446
+ if (!is_demangle_active) {
3447
+ auto & I = getInterp ();
3448
+ llvm::orc::LLJIT& EE = *compat::getExecutionEngine (I);
3449
+ auto t = EE.getTargetMachine ().getTargetTriple ();
3450
+ demangle = t.isOSDarwin () || t.isWindows ();
3451
+ is_demangle_active = true ;
3452
+ }
3453
+
3445
3454
// The JIT gives us a mangled name which has an additional leading underscore
3446
3455
// on macOS and Windows, for instance __ZN8TRandom34RndmEv. However, dlsym
3447
3456
// requires us to remove it.
3448
3457
// FIXME: get this information from the DataLayout via getGlobalPrefix()!
3449
- if (nameForDlsym[0 ] == ' _' )
3458
+ if (demangle && nameForDlsym[0 ] == ' _' )
3450
3459
nameForDlsym.erase (0 , 1 );
3451
- #endif // R__MACOSX
3452
-
3460
+ }
3453
3461
return nameForDlsym;
3454
3462
}
3455
3463
You can’t perform that action at this time.
0 commit comments