From 6be805cfdfd7fc5354ffff4eeb64dd6016c1e4f8 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Mon, 23 Feb 2026 15:23:36 +0000 Subject: [PATCH] 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 --- cmake/targets/BuildBun.cmake | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cmake/targets/BuildBun.cmake b/cmake/targets/BuildBun.cmake index 54bbfb596d..28110ff47f 100644 --- a/cmake/targets/BuildBun.cmake +++ b/cmake/targets/BuildBun.cmake @@ -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)