-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[object][WebAssembly] Add support for RUNTIME_PATH to yaml2obj and obj2yaml #126080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-llvm-binary-utilities @llvm/pr-subscribers-backend-webassembly Author: Hood Chatham (hoodmane) ChangesThis is the first step of adding RPATH support for wasm. See corresponding update to the WebAssembly/tool-conventions repo on dynamic linking: cc @sbc100 @ryanking13 Full diff: https://github.com/llvm/llvm-project/pull/126080.diff 7 Files Affected:
diff --git a/llvm/include/llvm/BinaryFormat/Wasm.h b/llvm/include/llvm/BinaryFormat/Wasm.h
index ede2d692a594916..00782f53a8e13d3 100644
--- a/llvm/include/llvm/BinaryFormat/Wasm.h
+++ b/llvm/include/llvm/BinaryFormat/Wasm.h
@@ -201,6 +201,7 @@ enum : unsigned {
WASM_DYLINK_NEEDED = 0x2,
WASM_DYLINK_EXPORT_INFO = 0x3,
WASM_DYLINK_IMPORT_INFO = 0x4,
+ WASM_DYLINK_RUNTIME_PATH = 0x5,
};
// Kind codes used in the custom "linking" section in the WASM_COMDAT_INFO
@@ -294,6 +295,7 @@ struct WasmDylinkInfo {
std::vector<StringRef> Needed; // Shared library dependencies
std::vector<WasmDylinkImportInfo> ImportInfo;
std::vector<WasmDylinkExportInfo> ExportInfo;
+ StringRef RuntimePath;
};
struct WasmProducerInfo {
diff --git a/llvm/include/llvm/ObjectYAML/WasmYAML.h b/llvm/include/llvm/ObjectYAML/WasmYAML.h
index 94ecc2fcfdb536b..2285dd65647689f 100644
--- a/llvm/include/llvm/ObjectYAML/WasmYAML.h
+++ b/llvm/include/llvm/ObjectYAML/WasmYAML.h
@@ -230,6 +230,7 @@ struct DylinkSection : CustomSection {
std::vector<StringRef> Needed;
std::vector<DylinkImportInfo> ImportInfo;
std::vector<DylinkExportInfo> ExportInfo;
+ StringRef RuntimePath;
};
struct NameSection : CustomSection {
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index 0f6fd5612f9d82a..5c6b97e0acc8cd8 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -484,6 +484,10 @@ Error WasmObjectFile::parseDylink0Section(ReadContext &Ctx) {
}
break;
}
+ case wasm::WASM_DYLINK_RUNTIME_PATH: {
+ DylinkInfo.RuntimePath = readString(Ctx);
+ break;
+ }
default:
LLVM_DEBUG(dbgs() << "unknown dylink.0 sub-section: " << Type << "\n");
Ctx.Ptr += Size;
diff --git a/llvm/lib/ObjectYAML/WasmEmitter.cpp b/llvm/lib/ObjectYAML/WasmEmitter.cpp
index bd016764f586267..877ece5224959a8 100644
--- a/llvm/lib/ObjectYAML/WasmEmitter.cpp
+++ b/llvm/lib/ObjectYAML/WasmEmitter.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
//
+#include "llvm/BinaryFormat/Wasm.h"
#include "llvm/Object/Wasm.h"
#include "llvm/ObjectYAML/ObjectYAML.h"
#include "llvm/ObjectYAML/yaml2obj.h"
@@ -180,6 +181,12 @@ void WasmWriter::writeSectionContent(raw_ostream &OS,
writeStringRef(Needed, SubOS);
SubSection.done();
}
+ if (Section.RuntimePath.size()) {
+ writeUint8(OS, wasm::WASM_DYLINK_RUNTIME_PATH);
+ raw_ostream &SubOS = SubSection.getStream();
+ writeStringRef(Section.RuntimePath, SubOS);
+ SubSection.done();
+ }
}
void WasmWriter::writeSectionContent(raw_ostream &OS,
diff --git a/llvm/lib/ObjectYAML/WasmYAML.cpp b/llvm/lib/ObjectYAML/WasmYAML.cpp
index 6af66ba62be1889..d9e93d06dcf273f 100644
--- a/llvm/lib/ObjectYAML/WasmYAML.cpp
+++ b/llvm/lib/ObjectYAML/WasmYAML.cpp
@@ -59,6 +59,7 @@ static void sectionMapping(IO &IO, WasmYAML::DylinkSection &Section) {
IO.mapRequired("Needed", Section.Needed);
IO.mapOptional("ImportInfo", Section.ImportInfo);
IO.mapOptional("ExportInfo", Section.ExportInfo);
+ IO.mapOptional("RuntimePath", Section.RuntimePath);
}
static void sectionMapping(IO &IO, WasmYAML::NameSection &Section) {
diff --git a/llvm/test/ObjectYAML/wasm/dylink_section.yaml b/llvm/test/ObjectYAML/wasm/dylink_section.yaml
index a43f678c45194b3..cdc094efc345613 100644
--- a/llvm/test/ObjectYAML/wasm/dylink_section.yaml
+++ b/llvm/test/ObjectYAML/wasm/dylink_section.yaml
@@ -11,6 +11,7 @@ Sections:
TableSize: 1
TableAlignment: 0
Needed: [ libfoo.so, libbar.so ]
+ RuntimePath: $ORIGIN/../lib:$ORIGIN/../../.libs
...
# CHECK: --- !WASM
# CHECK: FileHeader:
@@ -25,4 +26,5 @@ Sections:
# CHECK: Needed:
# CHECK: - libfoo.so
# CHECK: - libbar.so
+# CHECK: RuntimePath: '$ORIGIN/../lib:$ORIGIN/../../.libs'
# CHECK: ...
diff --git a/llvm/tools/obj2yaml/wasm2yaml.cpp b/llvm/tools/obj2yaml/wasm2yaml.cpp
index 9aa7f5abe8dd436..5a9d9a88da2271f 100644
--- a/llvm/tools/obj2yaml/wasm2yaml.cpp
+++ b/llvm/tools/obj2yaml/wasm2yaml.cpp
@@ -61,6 +61,7 @@ WasmDumper::dumpCustomSection(const WasmSection &WasmSec) {
DylinkSec->TableSize = Info.TableSize;
DylinkSec->TableAlignment = Info.TableAlignment;
DylinkSec->Needed = Info.Needed;
+ DylinkSec->RuntimePath = Info.RuntimePath;
for (const auto &Imp : Info.ImportInfo)
DylinkSec->ImportInfo.push_back({Imp.Module, Imp.Field, Imp.Flags});
for (const auto &Exp : Info.ExportInfo)
|
@sbc100 can you approve the workflow? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but lets wait for the tool-conventions change to land first.
@sbc100 since we merged the tool-conventions PR can we merge this now? |
@hoodmane Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/19304 Here is the relevant piece of the build log for the reference
|
This finishes adding RPATH support for WebAssembly. See my previous PR which added RPATH support to yaml2obj and obj2yaml: llvm#126080 See corresponding update to the WebAssembly/tool-conventions repo on dynamic linking: WebAssembly/tool-conventions#246
This finishes adding RPATH support for WebAssembly. See my previous PR which added RPATH support to yaml2obj and obj2yaml: #126080 See corresponding update to the WebAssembly/tool-conventions repo on dynamic linking: WebAssembly/tool-conventions#246
…29050) This finishes adding RPATH support for WebAssembly. See my previous PR which added RPATH support to yaml2obj and obj2yaml: llvm/llvm-project#126080 See corresponding update to the WebAssembly/tool-conventions repo on dynamic linking: WebAssembly/tool-conventions#246
This is the first step of adding RPATH support for wasm. See corresponding update to the WebAssembly/tool-conventions repo on dynamic linking:
WebAssembly/tool-conventions#246
cc @sbc100 @ryanking13