This is an archive of the discontinued LLVM Phabricator instance.

[lld][WebAssembly] Allow exporting of mutable globals
ClosedPublic

Authored by sbc100 on Sep 29 2020, 11:11 AM.

Details

Summary

In particular allow explict exporting of __stack_pointer but
exclude this from --export-all to avoid requiring the mutable
globals feature whenenve --export-all is used.

This uncovered a bug in populateTargetFeatures regarding checking
if the mutable-globals feature is allowed.

See: https://github.com/WebAssembly/binaryen/issues/2934

Diff Detail

Event Timeline

sbc100 created this revision.Sep 29 2020, 11:11 AM
sbc100 requested review of this revision.Sep 29 2020, 11:11 AM
sbc100 edited the summary of this revision. (Show Details)Sep 29 2020, 11:14 AM

I think it's kind of confusing that export-all doesn't actually export all the symbols. What if we instead made export-all exactly equivalent to individually exporting all the symbols so that it errors out if mutable-globals is not enabled and any of the symbols is a mutable global? Then we could add a --no-export=<symbol> flag that users or drivers could use to filter out the mutable global symbols if they can't enable mutable-globals and need to avoid the error.

lld/wasm/Writer.cpp
456

Oops! Nice catch.

579

I think it's kind of confusing that export-all doesn't actually export all the symbols. What if we instead made export-all exactly equivalent to individually exporting all the symbols so that it errors out if mutable-globals is not enabled and any of the symbols is a mutable global? Then we could add a --no-export=<symbol> flag that users or drivers could use to filter out the mutable global symbols if they can't enable mutable-globals and need to avoid the error.

The problem with that is that it would be breaking change for pretty much all current users of --export-all. This is not ideal... but I think its reasonable compromise between internal consistency and backward compatibility.

Also its not clear that any users of --export-all really want these internal symbols to be exported. Indeed they have made do up until now without them.

tlively accepted this revision.Sep 29 2020, 2:52 PM

Ah, I didn't realize export-all already didn't export these symbols, but that makes sense. Can we make sure the help documentation mentions that export-all does not include synthetic symbols?

This revision is now accepted and ready to land.Sep 29 2020, 2:52 PM
sbc100 marked an inline comment as done.Sep 30 2020, 5:53 PM
This revision was landed with ongoing or failed builds.Sep 30 2020, 5:54 PM
This revision was automatically updated to reflect the committed changes.