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