[PATCH] D147548: [lld][WebAssembly] Fix stub library parsing with windows line endings
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 4 10:33:10 PDT 2023
sbc100 updated this revision to Diff 510854.
sbc100 added a comment.
- revert
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147548/new/
https://reviews.llvm.org/D147548
Files:
lld/test/wasm/Inputs/.gitattributes
lld/wasm/Driver.cpp
lld/wasm/InputFiles.cpp
Index: lld/wasm/InputFiles.cpp
===================================================================
--- lld/wasm/InputFiles.cpp
+++ lld/wasm/InputFiles.cpp
@@ -691,12 +691,16 @@
}
void StubFile::parse() {
- bool first = false;
+ bool first = true;
+
+ SmallVector<StringRef, 0> lines;
+ mb.getBuffer().split(lines, '\n');
+ for (StringRef line : lines) {
+ line = line.trim();
- for (StringRef line : args::getLines(mb)) {
// File must begin with #STUB
if (first) {
- assert(line == "#STUB\n");
+ assert(line == "#STUB");
first = false;
}
@@ -713,10 +717,10 @@
symbolDependencies[sym] = {};
while (rest.size()) {
- StringRef first;
- std::tie(first, rest) = rest.split(',');
- first = strip(first);
- symbolDependencies[sym].push_back(first);
+ StringRef dep;
+ std::tie(dep, rest) = rest.split(',');
+ dep = strip(dep);
+ symbolDependencies[sym].push_back(dep);
}
}
}
Index: lld/wasm/Driver.cpp
===================================================================
--- lld/wasm/Driver.cpp
+++ lld/wasm/Driver.cpp
@@ -280,7 +280,7 @@
files.push_back(createObjectFile(mbref));
break;
case file_magic::unknown:
- if (mbref.getBuffer().starts_with("#STUB\n")) {
+ if (mbref.getBuffer().starts_with("#STUB")) {
files.push_back(make<StubFile>(mbref));
break;
}
Index: lld/test/wasm/Inputs/.gitattributes
===================================================================
--- /dev/null
+++ lld/test/wasm/Inputs/.gitattributes
@@ -0,0 +1,3 @@
+# ensures that we test parsing of stub libraries that contain
+# windows line endings
+libstub.so text eol=crlf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147548.510854.patch
Type: text/x-patch
Size: 1695 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230404/0e71e5e5/attachment.bin>
More information about the llvm-commits
mailing list