Repository navigation
finalize: strip segments that contain only EM_ASM/EM_JS data - #3557
Conversation
5afa64c to
52441fb
Compare
|
Hmm.. how come the UI is saying I can merge this without a review? Does binaryen not require an lgtm? |
52441fb to
01b115a
Compare
|
That's weird, it should require an LGTM |
|
Ah.. its because I wasn't targeting main. Fixed. |
01b115a to
64b8741
Compare
ec8fddd to
91f5cb5
Compare
|
This change now handle EM_ASM strings too. |
91f5cb5 to
5e78ba6
Compare
| // Older versions of emscripten don't export these symbols. Instead | ||
| // we run AsmConstWalker in an attempt to derive the string addresses | ||
| // from the code. | ||
| if (!start || !end) { | ||
| AsmConstWalker walker(wasm, minimizeWasmChanges); | ||
| walker.process(); | ||
| return walker.asmConsts; | ||
| } |
There was a problem hiding this comment.
Are planning to remove this fallback code in the future? What is stopping us from removing it now?
There was a problem hiding this comment.
Yes. Mostly its a transition thing. I can't land the emscripten-side change first because it actually changes the way that arg0 gets passed the em_asm functions. llvm ends up storing that address of the string in memory and then loading it back (at least in -O0) which is not currently supported by the AsmConstWalker. So if I land the emscripten side first it would break this pass.
| ;; CHECK: (data (i32.const 1024) "some JS string data\00xxx") | ||
| ;; CHECK: (data (i32.const 2048) "more JS string data\00yyy") |
There was a problem hiding this comment.
Why aren't the JS strings zeroed out?
There was a problem hiding this comment.
I've only done the zeroing out thing for the em_asm path so far. The reason is that I don't currently use the start/end symbols for the em_js path at all. I think we can do that a followup perhaps, and maybe even completely remove the current 1-export-per-em-js thing.
There was a problem hiding this comment.
Gotcha. The difference between EM_JS and EM_ASM still confuses me, but that's ok.
If we find a data segment whose entire contents is EM_JS or EM_ASM strings then strip it from the binary. See: emscripten-core/emscripten#13443
3da8d22 to
00ecb51
Compare
If we find a data segment whose entire contents is EM_JS or EM_ASM
strings then strip it from the binary.
This change also introduces a new way to exact EM_ASM strings based
on the _start and stop sections symbols. This code will no be active
until the emscripten-side change lands.
See: emscripten-core/emscripten#13443