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,10 +21,13 @@ } static bool allowUndefined(const Symbol* sym) { - // Undefined functions with explicit import name are allowed to be undefined - // at link time. - if (auto *F = dyn_cast(sym)) - if (F->importName) + // 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);