[WebAssemlby] MC: Don't write COMDAT symbols as global imports
This was causing undefined references at link time in lld.
Differential Revision: https://reviews.llvm.org/D41959
llvm-svn: 322309
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index e5099a8..ff00073 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -1122,7 +1122,8 @@
continue;
// If the symbol is not defined in this translation unit, import it.
- if (!WS.isDefined(/*SetUsed=*/false) || WS.isVariable()) {
+ if ((!WS.isDefined(/*SetUsed=*/false) && !WS.isComdat()) ||
+ WS.isVariable()) {
WasmImport Import;
Import.ModuleName = WS.getModuleName();
Import.FieldName = WS.getName();