[lld] r326976 - [WebAssembly] Honor --allow-undefined even for explicit exports
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 7 17:16:05 PST 2018
Author: sbc
Date: Wed Mar 7 17:16:05 2018
New Revision: 326976
URL: http://llvm.org/viewvc/llvm-project?rev=326976&view=rev
Log:
[WebAssembly] Honor --allow-undefined even for explicit exports
When a symbol is exported via --export=foo but --allow-undefined
is also specified, the symbol is now allowed to be undefined.
Previously we were special casing such symbols.
This combinations of behavior is exactly what emescripten
requires. Although we are trying hard not to allow emscripten
specific features in lld, this one makes sense.
Enforce this behavior by added this case to test/wasm/undefined.ll.
Differential Revision: https://reviews.llvm.org/D44237
Modified:
lld/trunk/test/wasm/undefined.ll
lld/trunk/wasm/Driver.cpp
Modified: lld/trunk/test/wasm/undefined.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/wasm/undefined.ll?rev=326976&r1=326975&r2=326976&view=diff
==============================================================================
--- lld/trunk/test/wasm/undefined.ll (original)
+++ lld/trunk/test/wasm/undefined.ll Wed Mar 7 17:16:05 2018
@@ -6,10 +6,13 @@
; CHECK: error: {{.*}}.o: undefined symbol: foo
; CHECK: error: undefined symbol: baz
-; But succeeds if we pass a file containing 'foo' as --allow-undefined-file.
+; Succeeds if we pass a file containing 'foo' as --allow-undefined-file.
; RUN: echo 'foo' > %t.txt
; RUN: wasm-ld --check-signatures --allow-undefined-file=%t.txt -o %t.wasm %t.o
+; Succeeds even if a missing symbol is added via --export
+; RUN: wasm-ld --check-signatures --allow-undefined --export=xxx -o %t.wasm %t.o
+
target triple = "wasm32-unknown-unknown-wasm"
; Takes the address of the external foo() resulting in undefined external
Modified: lld/trunk/wasm/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Driver.cpp?rev=326976&r1=326975&r2=326976&view=diff
==============================================================================
--- lld/trunk/wasm/Driver.cpp (original)
+++ lld/trunk/wasm/Driver.cpp Wed Mar 7 17:16:05 2018
@@ -346,7 +346,7 @@ void LinkerDriver::link(ArrayRef<const c
Symbol *Sym = Symtab->find(Name);
if (Sym && Sym->isDefined())
Sym->setHidden(false);
- else
+ else if (!Config->AllowUndefined)
error("symbol exported via --export not found: " + Name);
}
More information about the llvm-commits
mailing list