Index: test/wasm/stack-pointer.ll =================================================================== --- test/wasm/stack-pointer.ll +++ test/wasm/stack-pointer.ll @@ -58,6 +58,9 @@ ; CHECK-NEXT: - Name: __wasm_call_ctors ; CHECK-NEXT: Kind: FUNCTION ; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Name: __stack_pointer +; CHECK-NEXT: Kind: GLOBAL +; CHECK-NEXT: Index: 0 ; CHECK-NEXT: - Name: __heap_base ; CHECK-NEXT: Kind: GLOBAL ; CHECK-NEXT: Index: 1 Index: wasm/Writer.cpp =================================================================== --- wasm/Writer.cpp +++ wasm/Writer.cpp @@ -658,8 +658,10 @@ for (const Symbol *Sym : DefinedGlobals) { // Can't export the SP right now because it's mutable and mutable globals - // cannot be exported. - if (Sym == Config->StackPointerSymbol) + // cannot be exported. However, for output that's intended for processing + // by downstream tools, we can rely on the "mutable global" proposal + // being present. + if (Sym == Config->StackPointerSymbol && !Config->EmitRelocs) continue; ExportedSymbols.emplace_back(WasmExportEntry{Sym, BudgeName(Sym)}); }