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 {
3367
3367
static inline std::string DemangleNameForDlsym (const std::string& name) {
3368
3368
std::string nameForDlsym = name;
3369
3369
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
+
3371
3380
// The JIT gives us a mangled name which has an additional leading underscore
3372
3381
// on macOS and Windows, for instance __ZN8TRandom34RndmEv. However, dlsym
3373
3382
// requires us to remove it.
3374
3383
// FIXME: get this information from the DataLayout via getGlobalPrefix()!
3375
- if (nameForDlsym[0 ] == ' _' )
3384
+ if (demangle && nameForDlsym[0 ] == ' _' )
3376
3385
nameForDlsym.erase (0 , 1 );
3377
- #endif // R__MACOSX
3378
-
3386
+ }
3379
3387
return nameForDlsym;
3380
3388
}
3381
3389
You can’t perform that action at this time.
0 commit comments