Unlike the existing --export option this will not causes errors
or warnings if the specified symbol is not defined.
This is an existing flag from GNU ld and lld ELF backend.
See: https://github.com/emscripten-core/emscripten/issues/13736
Differential D101271
[lld][WebAssembly] Add support for `--export-dynamic-symbol` sbc100 on Apr 25 2021, 5:19 PM. Authored by
Details Unlike the existing --export option this will not causes errors This is an existing flag from GNU ld and lld ELF backend. See: https://github.com/emscripten-core/emscripten/issues/13736
Diff Detail
Event Timeline
Comment Actions LGTM modulo MaskRay's comment about the help text. Also I think @sunfish had a question earlier today that we didn't get to talk about.
Comment Actions I'm a little confused by the name "export-dynamic-symbol". I understand it's an ELF flag, though it seems to have a slightly different meaning here. What would you think about adding a warning when using this flag is -experimental-pic isn't passed, similar to what we do with -shared? Comment Actions This flag, although it has dynamic its is name, does not imply PIC ABI stuff or imply -shared or -pie so I don't think it makes sense to link it to -experimental-pic. In works just like the existing --export flag but allows the symbol to be undefined. I plan to use this in emscripten when we are doing static linking. Comment Actions The existing --export flag, one could argue, already promotes symbols from the static world to the dyanmic (runtime) world, its just that it also implies --require-defined=foo. In fact one could potentially argue that --export should be deprecated in favor of --require-defined= + --export-dynamic-symbol= (although I'm not doing that). My original version of this patch used the name --export-if-defined=.. if you feel strongly we could go back to that name instead, but I like sharing flags where possible rather than inventing new ones, and the meaning of this flag seems to match pretty well here. Comment Actions Looking at the ld documentation for export-dynamic-symbol:
We're applying this to statically linked executables too.
We don't have the semantics of allowing symbols to be preempted like ELF does. I'm looking ahead to wasm-ld supporting new dynamic linking ABIs, which may be significantly different from ELF. So my preference here would be, if we have functionality which exactly matches ELF, it makes sense to reuse the ELF-specific names, otherwise we should use names which make sense for wasm on their own terms. Does that make sense? Comment Actions So you think it would be preferable to go with --export-if-defined then, or something wasm specific? Comment Actions Yes, --export-if-defined would be my preference here. "export" has a clear meaning in wasm terms, and we already have --export, so the meaning of --export-if-defined is clear. |
Drop period.