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 @@ -3278,15 +3278,23 @@ namespace Cpp {
3278
3278
static inline std::string DemangleNameForDlsym (const std::string& name) {
3279
3279
std::string nameForDlsym = name;
3280
3280
3281
- #if defined(R__MACOSX) || defined(R__WIN32)
3281
+ static bool is_demangle_active = false ;
3282
+ static bool demangle = false ;
3283
+ if (!is_demangle_active) {
3284
+ auto & I = getInterp ();
3285
+ llvm::orc::LLJIT& EE = *compat::getExecutionEngine (I);
3286
+ auto t = EE.getTargetMachine ().getTargetTriple ();
3287
+ demangle = t.isOSDarwin () || t.isWindows ();
3288
+ is_demangle_active = true ;
3289
+ }
3290
+
3282
3291
// The JIT gives us a mangled name which has an additional leading underscore
3283
3292
// on macOS and Windows, for instance __ZN8TRandom34RndmEv. However, dlsym
3284
3293
// requires us to remove it.
3285
3294
// FIXME: get this information from the DataLayout via getGlobalPrefix()!
3286
- if (nameForDlsym[0 ] == ' _' )
3295
+ if (demangle && nameForDlsym[0 ] == ' _' )
3287
3296
nameForDlsym.erase (0 , 1 );
3288
- #endif // R__MACOSX
3289
-
3297
+ }
3290
3298
return nameForDlsym;
3291
3299
}
3292
3300
You can’t perform that action at this time.
0 commit comments