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