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 {
3388
3388
static inline std::string DemangleNameForDlsym (const std::string& name) {
3389
3389
std::string nameForDlsym = name;
3390
3390
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
+
3392
3401
// The JIT gives us a mangled name which has an additional leading underscore
3393
3402
// on macOS and Windows, for instance __ZN8TRandom34RndmEv. However, dlsym
3394
3403
// requires us to remove it.
3395
3404
// FIXME: get this information from the DataLayout via getGlobalPrefix()!
3396
- if (nameForDlsym[0 ] == ' _' )
3405
+ if (demangle && nameForDlsym[0 ] == ' _' )
3397
3406
nameForDlsym.erase (0 , 1 );
3398
- #endif // R__MACOSX
3399
-
3407
+ }
3400
3408
return nameForDlsym;
3401
3409
}
3402
3410
You can’t perform that action at this time.
0 commit comments