diff --git a/lld/test/wasm/import-name.ll b/lld/test/wasm/import-name.ll --- a/lld/test/wasm/import-name.ll +++ b/lld/test/wasm/import-name.ll @@ -1,5 +1,5 @@ ; RUN: llc -filetype=obj %s -o %t.o -; RUN: wasm-ld --allow-undefined -o %t.wasm %t.o +; RUN: wasm-ld -o %t.wasm %t.o ; RUN: obj2yaml %t.wasm | FileCheck %s target triple = "wasm32-unknown-unknown" diff --git a/lld/wasm/Relocations.cpp b/lld/wasm/Relocations.cpp --- a/lld/wasm/Relocations.cpp +++ b/lld/wasm/Relocations.cpp @@ -28,6 +28,12 @@ // compiling with -fPIC) if (isa(sym)) return false; + // Undefined functions with explicit import name are allowed to be undefined + // at link time. + if (auto* F = dyn_cast(sym)) { + if (F->importName || F->importModule) + return true; + } return (config->allowUndefined || config->allowUndefinedSymbols.count(sym->getName()) != 0); }