diff options
author | 2023-11-01 07:21:45 +0100 | |
---|---|---|
committer | 2023-10-31 23:21:45 -0700 | |
commit | 3912f4d06418e1a8d430638fa7107ded3b601201 (patch) | |
tree | 2530c31ecd6bdc0044da1f8a38e8b0118b50a23e | |
parent | 53d1acb0a5655deb69f54bd6f8222a6f4dd27633 (diff) | |
download | bun-3912f4d06418e1a8d430638fa7107ded3b601201.tar.gz bun-3912f4d06418e1a8d430638fa7107ded3b601201.tar.zst bun-3912f4d06418e1a8d430638fa7107ded3b601201.zip |
fix(build): add option and auto detect for arch linux (#6835)
* fix(build): add option and auto detect for arch linux
This adds a option and a automatic routine for decting arch linux,
where the path for libatomic is a bit special.
* fix: don't statically link if not needed
-rw-r--r-- | CMakeLists.txt | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f03b9a218..3281ad6bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,6 +186,13 @@ endif() set(DEFAULT_ON_UNLESS_APPLE ON) +set(DEFAULT_USE_STATIC_LIBATOMIC ON) +if(UNIX AND NOT APPLE) + execute_process(COMMAND cat /etc/os-release COMMAND head -n1 OUTPUT_VARIABLE LINUX_DISTRO) + if(${LINUX_DISTRO} STREQUAL "NAME=\"Arch Linux\"\n") + set(DEFAULT_USE_STATIC_LIBATOMIC OFF) + endif() +endif() if(APPLE) set(DEFAULT_ON_UNLESS_APPLE OFF) endif() @@ -214,7 +221,7 @@ option(USE_DEBUG_JSC "Enable assertions and use a debug build of JavaScriptCore" option(USE_UNIFIED_SOURCES "Use unified sources to speed up the build" OFF) option(CANARY "Make `bun --revision` report a canary release" OFF) - +option(USE_STATIC_LIBATOMIC "statically link libatomic, requires the presence of libatomic.a" ${DEFAULT_USE_STATIC_LIBATOMIC}) set(ERROR_LIMIT 100 CACHE STRING "Maximum number of errors to show when compiling C++ code") set(ARCH x86_64) @@ -936,7 +943,11 @@ if(UNIX AND NOT APPLE) target_link_libraries(${bun} PRIVATE "pthread") target_link_libraries(${bun} PRIVATE "dl") - target_link_libraries(${bun} PRIVATE "libatomic.a") + if(NOT USE_STATIC_LIBATOMIC) + target_link_libraries(${bun} PUBLIC "libatomic.so") + else() + target_link_libraries(${bun} PRIVATE "libatomic.a") + endif() target_link_libraries(${bun} PRIVATE "${WEBKIT_LIB_DIR}/libicudata.a") target_link_libraries(${bun} PRIVATE "${WEBKIT_LIB_DIR}/libicui18n.a") |