Skip to content

Commit 741cf4f

Browse files
authored
Remove --no-gc-sections from -sLINKABLE builds. (#17056)
Any symbols that have default visibility should be kept around because we already pass `--export-dynamic`. Passing `--no-gc-sections` causes a lot more stuff that we don't even export to be kept around at link time. This change also makes `__set_stack_limits` options in shared libraries which it technically always has been. Binaryen doesn't generate this function at all if it can't find a stack pointer at all in the side module. See: #16926
1 parent 05e60a1 commit 741cf4f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/library_dylink.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,9 @@ var LibraryDylink = {
587587
reportUndefinedSymbols();
588588
}
589589
#if STACK_OVERFLOW_CHECK >= 2
590-
moduleExports['__set_stack_limits'](_emscripten_stack_get_base(), _emscripten_stack_get_end())
590+
if (moduleExports['__set_stack_limits']) {
591+
moduleExports['__set_stack_limits'](_emscripten_stack_get_base(), _emscripten_stack_get_end())
592+
}
591593
#endif
592594

593595
// initialize the module
@@ -651,7 +653,9 @@ var LibraryDylink = {
651653
err('setDylinkStackLimits[' + name + ']');
652654
#endif
653655
var lib = LDSO.loadedLibsByName[name];
654-
lib.module['__set_stack_limits'](stackTop, stackMax);
656+
if (lib.module['__set_stack_limits']) {
657+
lib.module['__set_stack_limits'](stackTop, stackMax);
658+
}
655659
}
656660
},
657661
#endif

tools/building.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ def lld_flags_for_executable(external_symbols):
292292

293293
if settings.LINKABLE:
294294
cmd.append('--export-dynamic')
295-
cmd.append('--no-gc-sections')
296295

297296
c_exports = [e for e in settings.EXPORTED_FUNCTIONS if is_c_symbol(e)]
298297
# Strip the leading underscores

0 commit comments

Comments
 (0)