Understanding Linking and Stripping #21850
Replies: 3 comments 13 replies
-
If you build with If you build with There are some docs on this here: https://emscripten.org/docs/compiling/Dynamic-Linking.html#code-size |
Beta Was this translation helpful? Give feedback.
-
Sure that sounds reasonable. |
Beta Was this translation helpful? Give feedback.
-
When I try this on the (latest emscripten version at least) it what you want:
Does this not work for you? It sounds like add
|
Beta Was this translation helpful? Give feedback.
-
Hey all, I'm trying to wrap my head around how the Emscripten toolchain handles stripping specifically around JS library symbols. My use case is simple: I'm compiling a main module that will be extended at runtime with dynamic linking (side module). The main module needs to contain
embind
symbols that the side module will try to use, but since these symbols are not used at compile-time, they will get stripped away. Here's what I've learned so far:LibraryEmVal
) will be stripped as expected.wasm-ld
does not have visibility or control over JS library symbol stripping, so using-Wl,-u,unused_symbol_name
does not work.wasm-ld
cannot preserveextern
symbols (i.e. symbols defined in JS), so using-Wl,--export=unused_symbol_name
also does not work.My question then is what part of the Emscripten toolchain handles stripping JS library functions, and what compiler flags can be used to preserve these symbols?
I've tested
-sEXPORTED_FUNCTIONS
which doesn't work because this controls making C symbols visible in JavaScript, not the other way around. Similarly,-sEXPORTED_RUNTIME_METHODS
doesn't work because it only handles making a function available in the globalModule
, and doesn't preserve any form of stripping.Beta Was this translation helpful? Give feedback.
All reactions