WebAssembly / WebAssembly/tool-conventions
Revisit the default of `-fvisibility=hidden`
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 372
- Forks
- 75
- PR merge metrics
- No merged PRs in 30d
Description
;TLDR; visibility is currently only used by emscripten and emscripten uses a default of -fvisibility=default.
A long while ago we choose to make -fvisibility=hidden the default for the WebAssembly backend in llvm. IIRC the rational was that we would want to avoid exporting a lot of C/C++ symbols by default.
However, the only time the wasm-ld linker actually exports things based on their visibility is when -shared is used (or in the static linking case when --export-dynamic is passed). These flags are not currently used outside of emscripten. For example, with wasi-sdk users are currently things via on of 3 different methods:
- Explicit
--exporton the command line (e.g.--export=foo) --export-allon the command line. This is even worse that exporting non-hidden symbols since it exports everything (do we even what to support this going forward?)export_nameattribute in the source code.
In emscripten, the visibility attribute is honored when -shared/-pie is used, and we recently switch from using --export-all to --export-dynamic + -fvisibility=default which results in fewer exports (for example --export-all exports all libc-internal symbols , even those marked as hidden, whereas --export-dynamic + -fvisibility=default does not). See https://github.com/emscripten-core/emscripten/pull/15413.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the wasm-ld linker behavior described here, then compare how emscripten and wasi-sdk use -fvisibility=hidden/default, -shared/-pie, --export-dynamic, --export-all, and export_name. Review the linked emscripten change for context. Done requires an agreed convention for the default and its supported export mechanisms, followed by coordinated implementation and validation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100