[PATCH] D129175: [ORC] Fix weak hidden symbols failure on PPC with runtimedyld
Sunho Kim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 19 08:05:51 PDT 2022
sunho updated this revision to Diff 445827.
sunho added a comment.
Address comments.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129175/new/
https://reviews.llvm.org/D129175
Files:
clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
Index: llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
+++ llvm/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
@@ -108,6 +108,7 @@
// filter these later.
auto InternalSymbols = std::make_shared<std::set<StringRef>>();
{
+ SymbolFlagsMap ExtraSymbolsToClaim;
for (auto &Sym : (*Obj)->symbols()) {
// Skip file symbols.
@@ -128,6 +129,33 @@
return;
}
+ // Try to claim responsibility of weak symbols
+ // if AutoClaimObjectSymbols flag is set.
+ if (AutoClaimObjectSymbols &&
+ (*SymFlagsOrErr & object::BasicSymbolRef::SF_Weak)) {
+ auto SymName = Sym.getName();
+ if (!SymName) {
+ ES.reportError(SymName.takeError());
+ R->failMaterialization();
+ return;
+ }
+
+ // Already included in responsibility set, skip it
+ SymbolStringPtr SymbolName = ES.intern(*SymName);
+ if (R->getSymbols().count(SymbolName))
+ continue;
+
+ auto SymFlags = JITSymbolFlags::fromObjectSymbol(Sym);
+ if (!SymFlags) {
+ ES.reportError(SymFlags.takeError());
+ R->failMaterialization();
+ return;
+ }
+
+ ExtraSymbolsToClaim[SymbolName] = *SymFlags;
+ continue;
+ }
+
// Don't include symbols that aren't global.
if (!(*SymFlagsOrErr & object::BasicSymbolRef::SF_Global)) {
if (auto SymName = Sym.getName())
@@ -139,6 +167,13 @@
}
}
}
+
+ if (!ExtraSymbolsToClaim.empty()) {
+ if (auto Err = R->defineMaterializing(ExtraSymbolsToClaim)) {
+ ES.reportError(std::move(Err));
+ R->failMaterialization();
+ }
+ }
}
auto MemMgr = GetMemoryManager();
Index: llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
===================================================================
--- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -746,6 +746,11 @@
Layer->setAutoClaimResponsibilityForObjectSymbols(true);
}
+ if (S.JTMB->getTargetTriple().isOSBinFormatELF() &&
+ (S.JTMB->getTargetTriple().getArch() == Triple::ArchType::ppc64 ||
+ S.JTMB->getTargetTriple().getArch() == Triple::ArchType::ppc64le))
+ Layer->setAutoClaimResponsibilityForObjectSymbols(true);
+
// FIXME: Explicit conversion to std::unique_ptr<ObjectLayer> added to silence
// errors from some GCC / libstdc++ bots. Remove this conversion (i.e.
// just return ObjLinkingLayer) once those bots are upgraded.
Index: clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
===================================================================
--- clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
+++ clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp
@@ -98,11 +98,6 @@
// FIXME: Re-enable the excluded target triples.
const clang::CompilerInstance *CI = Interp->getCompilerInstance();
const llvm::Triple &Triple = CI->getASTContext().getTargetInfo().getTriple();
- // FIXME: PPC fails due to `Symbols not found: [DW.ref.__gxx_personality_v0]`
- // The current understanding is that the JIT should emit this symbol if it was
- // not (eg. the way passing clang -fPIC does it).
- if (Triple.isPPC())
- return;
// FIXME: ARM fails due to `Not implemented relocation type!`
if (Triple.isARM())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129175.445827.patch
Type: text/x-patch
Size: 3522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220719/8afd7817/attachment.bin>
More information about the llvm-commits
mailing list