Skip to content

Commit

Permalink
Preserve system library ordering even under EMCC_FORCE_STDLIBS=1
Browse files Browse the repository at this point in the history
In particular `EMCC_FORCE_STDLIBS=1` would previously place libc before
libbulkmemory which don't work.  libbulkmemory always needs to come
first on the link line.

Fixes: emscripten-core#22161
  • Loading branch information
sbc100 committed Jul 1, 2024
1 parent 35be995 commit 3f25bcf
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2292,12 +2292,14 @@ def add_library(libname):
if settings.SIDE_MODULE:
return libs_to_link

for forced in force_include:
if forced not in system_libs_map:
shared.exit_with_error('invalid forced library: %s', forced)
add_library(forced)
def add_forced_libs():
for forced in force_include:
if forced not in system_libs_map:
shared.exit_with_error('invalid forced library: %s', forced)
add_library(forced)

if '-nodefaultlibs' in args:
add_forced_libs()
return libs_to_link

sanitize = settings.USE_LSAN or settings.USE_ASAN or settings.UBSAN_RUNTIME
Expand All @@ -2323,6 +2325,7 @@ def add_sanitizer_libs():
add_library('libsanitizer_common_rt')

if only_forced:
add_forced_libs()
add_library('libcompiler_rt')
add_sanitizer_libs()
return libs_to_link
Expand Down Expand Up @@ -2390,6 +2393,10 @@ def add_sanitizer_libs():
add_library('libwasmfs')

add_sanitizer_libs()

# Add forced stdlibs at the end so that the order of system libraries is
# still preserved above, even when EMCC_FORCE_STDLIBS=1 is used.
add_forced_libs()
return libs_to_link


Expand Down

0 comments on commit 3f25bcf

Please sign in to comment.