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.
Uh oh!
There was an error while loading. Please reload this page.
-
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
embindsymbols 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-lddoes not have visibility or control over JS library symbol stripping, so using-Wl,-u,unused_symbol_namedoes not work.wasm-ldcannot preserveexternsymbols (i.e. symbols defined in JS), so using-Wl,--export=unused_symbol_namealso 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_FUNCTIONSwhich doesn't work because this controls making C symbols visible in JavaScript, not the other way around. Similarly,-sEXPORTED_RUNTIME_METHODSdoesn'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