diff --git a/lld/test/wasm/mutable-globals.s b/lld/test/wasm/mutable-globals.s --- a/lld/test/wasm/mutable-globals.s +++ b/lld/test/wasm/mutable-globals.s @@ -9,5 +9,7 @@ end_function .globaltype foo, i32 +.import_module foo, env +.import_name foo, foo # CHECK: error: mutable global imported but 'mutable-globals' feature not present in inputs: `foo`. Use --no-check-features to suppress. diff --git a/lld/wasm/Relocations.cpp b/lld/wasm/Relocations.cpp --- a/lld/wasm/Relocations.cpp +++ b/lld/wasm/Relocations.cpp @@ -21,11 +21,14 @@ } static bool allowUndefined(const Symbol* sym) { - // Undefined functions with explicit import name are allowed to be undefined - // at link time. + // Undefined functions and globals with explicit import name are allowed to be + // undefined at link time. if (auto *F = dyn_cast(sym)) if (F->importName) return true; + if (auto *G = dyn_cast(sym)) + if (G->importName) + return true; return (config->allowUndefined || config->allowUndefinedSymbols.count(sym->getName()) != 0); }