[lld] 3c28a6d - [lld][WebAssembly] Add support for LLD_REPRODUCE
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 3 17:00:15 PDT 2022
Author: Sam Clegg
Date: 2022-11-03T16:55:37-07:00
New Revision: 3c28a6d2cbf7faeecde6aee33dfc6b05ccfeb7a4
URL: https://github.com/llvm/llvm-project/commit/3c28a6d2cbf7faeecde6aee33dfc6b05ccfeb7a4
DIFF: https://github.com/llvm/llvm-project/commit/3c28a6d2cbf7faeecde6aee33dfc6b05ccfeb7a4.diff
LOG: [lld][WebAssembly] Add support for LLD_REPRODUCE
This is feature of the ELF and COFF linker that we were missing until
now.
Differential Revision: https://reviews.llvm.org/D137377
Added:
lld/test/wasm/reproduce.s
Modified:
lld/wasm/Driver.cpp
Removed:
lld/test/wasm/reproduce.ll
################################################################################
diff --git a/lld/test/wasm/reproduce.ll b/lld/test/wasm/reproduce.ll
deleted file mode 100644
index b00727e3b3e26..0000000000000
--- a/lld/test/wasm/reproduce.ll
+++ /dev/null
@@ -1,27 +0,0 @@
-; REQUIRES: shell
-; RUN: rm -rf %t.dir
-; RUN: mkdir -p %t.dir
-; RUN: llc -filetype=obj %s -o %t.dir/foo.o
-; RUN: wasm-ld --reproduce=%t.dir/repro.tar -o %t.dir/out.wasm %t.dir/foo.o
-
-; RUN: cd %t.dir
-; RUN: tar tf repro.tar | FileCheck --check-prefix=TAR %s
-
-; TAR: repro/response.txt
-; TAR: repro/version.txt
-; TAR: repro/{{.*}}/foo.o
-
-; RUN: tar xf repro.tar
-; RUN: FileCheck --check-prefix=RSP %s < repro/response.txt
-
-; RSP: -o {{.*}}out.wasm
-; RSP: {{.*}}/foo.o
-
-; RUN: FileCheck %s --check-prefix=VERSION < repro/version.txt
-; VERSION: LLD
-
-target triple = "wasm32-unknown-unknown"
-
-define void @_start() {
- ret void
-}
diff --git a/lld/test/wasm/reproduce.s b/lld/test/wasm/reproduce.s
new file mode 100644
index 0000000000000..a89843fe219e3
--- /dev/null
+++ b/lld/test/wasm/reproduce.s
@@ -0,0 +1,32 @@
+# REQUIRES: shell
+# RUN: rm -rf %t.dir
+# RUN: mkdir -p %t.dir
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.dir/foo.o %s
+# RUN: wasm-ld --reproduce=%t.dir/repro.tar -o %t.dir/out.wasm %t.dir/foo.o
+# RUN: env LLD_REPRODUCE=%t.dir/repro2.tar wasm-ld -o %t.dir/out.wasm %t.dir/foo.o
+
+# RUN: cd %t.dir
+# RUN: tar tf repro.tar | FileCheck --check-prefix=TAR %s
+# RUN: tar tf repro2.tar | FileCheck --check-prefix=TAR2 %s
+
+# TAR: repro/response.txt
+# TAR: repro/version.txt
+# TAR: repro/{{.*}}/foo.o
+
+# TAR2: repro2/response.txt
+# TAR2: repro2/version.txt
+# TAR2: repro2/{{.*}}/foo.o
+
+# RUN: tar xf repro.tar
+# RUN: FileCheck --check-prefix=RSP %s < repro/response.txt
+
+# RSP: -o {{.*}}out.wasm
+# RSP: {{.*}}/foo.o
+
+# RUN: FileCheck %s --check-prefix=VERSION < repro/version.txt
+# VERSION: LLD
+
+.globl _start
+_start:
+ .functype _start () -> ()
+ end_function
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index db1ef5ffff778..62cd6192b01d8 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -618,6 +618,12 @@ static void checkOptions(opt::InputArgList &args) {
}
}
+static const char *getReproduceOption(opt::InputArgList &args) {
+ if (auto *arg = args.getLastArg(OPT_reproduce))
+ return arg->getValue();
+ return getenv("LLD_REPRODUCE");
+}
+
// Force Sym to be entered in the output. Used for -u or equivalent.
static Symbol *handleUndefined(StringRef name) {
Symbol *sym = symtab->find(name);
@@ -955,8 +961,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
}
// Handle --reproduce
- if (auto *arg = args.getLastArg(OPT_reproduce)) {
- StringRef path = arg->getValue();
+ if (const char *path = getReproduceOption(args)) {
Expected<std::unique_ptr<TarWriter>> errOrWriter =
TarWriter::create(path, path::stem(path));
if (errOrWriter) {
More information about the llvm-commits
mailing list