Skip to content

Commit 3a0b32b

Browse files
committed
jit-rt: do not lookup cached symbols on macOS
1 parent 688e42a commit 3a0b32b

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

runtime/jit-rt/cpp-so/compile.cpp

+14-11
Original file line numberDiff line numberDiff line change
@@ -444,17 +444,20 @@ void rtCompileProcessImplSoInternal(const RtCompileModuleList *modlist_head,
444444
JitFinaliser jitFinalizer(myJit);
445445
/*if (myJit.isMainContext())*/ {
446446
interruptPoint(context, "Resolve functions");
447-
std::vector<std::string> names{};
448-
for (auto &elem : moduleInfo.functions()) {
449-
names.emplace_back(elem.name);
450-
}
451-
for (auto &elem : moduleInfo.getBindHandles()) {
452-
names.emplace_back(elem.name);
453-
}
454-
auto results = cantFail(myJit.lookupMany(names));
455-
for (auto &symbol : results) {
456-
myJit.addSymbol((*symbol.first).str(),
457-
symbol.second.getAddress().toPtr<void *>());
447+
// macOS may require pointer signing, so caching symbols might not work.
448+
if (!myJit.getTargetMachine()->getTargetTriple().isOSDarwin()) {
449+
std::vector<std::string> names{};
450+
for (auto &elem : moduleInfo.functions()) {
451+
names.emplace_back(elem.name);
452+
}
453+
for (auto &elem : moduleInfo.getBindHandles()) {
454+
names.emplace_back(elem.name);
455+
}
456+
auto results = cantFail(myJit.lookupMany(names));
457+
for (auto &symbol : results) {
458+
myJit.addSymbol((*symbol.first).str(),
459+
symbol.second.getAddress().toPtr<void *>());
460+
}
458461
}
459462
for (auto &&fun : moduleInfo.functions()) {
460463
if (fun.thunkVar == nullptr) {

runtime/jit-rt/cpp-so/jit_context.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,11 @@ DynamicCompilerContext::findSymbol(const std::string &name) {
186186
llvm::Expected<llvm::orc::ExecutorSymbolDef>
187187
DynamicCompilerContext::lookup(const std::string &name) {
188188
auto mangled = mangler(name);
189-
auto symbol = findSymbol((*mangled).str());
190-
if (symbol) {
191-
return *symbol;
189+
if (!targetmachine->getTargetTriple().isOSDarwin()) {
190+
auto symbol = findSymbol((*mangled).str());
191+
if (symbol) {
192+
return *symbol;
193+
}
192194
}
193195
return execSession->lookup({&moduleHandle}, mangled);
194196
}

0 commit comments

Comments
 (0)