diff options
| author | Sam Clegg <sbc@chromium.org> | 2018-06-07 01:27:07 +0000 |
|---|---|---|
| committer | Sam Clegg <sbc@chromium.org> | 2018-06-07 01:27:07 +0000 |
| commit | 177b458c8a42e5edac291ab39e90012b3df63090 (patch) | |
| tree | d15caa580ebd3e61434995dfbcc50ff2067ef94d /lld/wasm/Writer.cpp | |
| parent | 7a88f19099a9da3fbc655389cf2d6fc72af41595 (diff) | |
| download | bcm5719-llvm-177b458c8a42e5edac291ab39e90012b3df63090.tar.gz bcm5719-llvm-177b458c8a42e5edac291ab39e90012b3df63090.zip | |
[WebAssembly] Add --export-all flag
This causes all symbols to be exported in the final wasm binary
even if they were not compiled with default visibility.
This feature is useful for the emscripten toolchain that has a
corresponding EXPORT_ALL feature which allows the JS code to
interact with all C function.
Differential Revision: https://reviews.llvm.org/D47806
llvm-svn: 334157
Diffstat (limited to 'lld/wasm/Writer.cpp')
| -rw-r--r-- | lld/wasm/Writer.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp index ee6056ab76d..70d52bdb72d 100644 --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -742,7 +742,9 @@ void Writer::calculateExports() { for (Symbol *Sym : Symtab->getSymbols()) { if (!Sym->isDefined()) continue; - if (Sym->isHidden() || Sym->isLocal()) + if (Sym->isHidden() && !Config->ExportAll) + continue; + if (Sym->isLocal()) continue; if (!Sym->isLive()) continue; @@ -752,6 +754,14 @@ void Writer::calculateExports() { if (auto *F = dyn_cast<DefinedFunction>(Sym)) { Export = {Name, WASM_EXTERNAL_FUNCTION, F->getFunctionIndex()}; } else if (auto *G = dyn_cast<DefinedGlobal>(Sym)) { + // TODO(sbc): Remove this check once to mutable global proposal is + // implement in all major browsers. + // See: https://github.com/WebAssembly/mutable-global + if (G->getGlobalType()->Mutable) { + // Only the __stack_pointer should ever be create as mutable. + assert(G == WasmSym::StackPointer); + continue; + } Export = {Name, WASM_EXTERNAL_GLOBAL, G->getGlobalIndex()}; } else { auto *D = cast<DefinedData>(Sym); |

