mirror of
https://github.com/oven-sh/bun
synced 2026-02-26 11:37:26 +01:00
fix(build): statically link musl builds for portability
The musl builds were dynamically linked against musl libc, requiring /lib/ld-musl-x86_64.so.1 at runtime. This made them only usable on systems with musl installed (e.g. Alpine Linux), defeating the purpose of providing musl builds for maximum portability. Change musl builds to use -static so the binary is fully self-contained and works on any Linux system. Also use -static-libstdc++ and -static-libgcc for musl builds (same as glibc builds) instead of dynamically linking them. Closes #27375 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1150,16 +1150,16 @@ if(LINUX)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT ABI STREQUAL "musl")
|
||||
target_link_options(${bun} PUBLIC
|
||||
-static-libstdc++
|
||||
-static-libgcc
|
||||
)
|
||||
else()
|
||||
target_link_options(${bun} PUBLIC
|
||||
-lstdc++
|
||||
-lgcc
|
||||
)
|
||||
target_link_options(${bun} PUBLIC
|
||||
-static-libstdc++
|
||||
-static-libgcc
|
||||
)
|
||||
|
||||
if(ABI STREQUAL "musl")
|
||||
# Statically link the musl C library so the binary doesn't require
|
||||
# /lib/ld-musl-*.so.1 at runtime. This makes musl builds portable
|
||||
# to any Linux system, not just ones with musl installed.
|
||||
target_link_options(${bun} PUBLIC -static)
|
||||
endif()
|
||||
|
||||
if (ENABLE_LTO)
|
||||
|
||||
Reference in New Issue
Block a user