Skip to content

Commit d16c374

Browse files
committed
Static build fixes for locale and threading
1 parent eb53c63 commit d16c374

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

dynadjust/cmake/StaticBuildOptimizations.cmake

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,26 @@ function(optimize_static_target TARGET_NAME)
66
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
77
set_property(TARGET ${TARGET_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
88
endif()
9-
9+
1010
# Platform-specific optimizations
1111
if(UNIX AND NOT APPLE)
1212
# Linux-specific optimizations
1313
target_link_options(${TARGET_NAME} PRIVATE
1414
-static
15-
-Wl,--gc-sections # Remove unused sections
15+
-pthread
16+
# Clang + static glibc: libstdc++'s gthr-posix.h uses __weakref__ aliases
17+
# for pthread functions. GCC resolves these at link time, but Clang leaves
18+
# them as null, causing segfaults when std::thread calls through them.
19+
# Force the linker to pull in the real symbols from libc.a.
20+
-Wl,-u,pthread_create
21+
-Wl,-u,pthread_join
22+
-Wl,-u,pthread_cancel
23+
-Wl,-u,pthread_detach
24+
-Wl,-u,pthread_mutex_lock
25+
-Wl,-u,pthread_mutex_unlock
26+
-Wl,-u,pthread_once
27+
-Wl,-u,pthread_key_create
28+
-Wl,--gc-sections # Remove unused sections
1629
-Wl,--as-needed # Only link libraries that are actually used
1730
-Wl,-O2 # Optimize at link time
1831
-Wl,--strip-all # Strip all symbols

dynadjust/include/config/dnaversion.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ const char* const __plot_dll_name__ = "libdnaplot.so";
310310

311311
#if defined(__clang__) // Clang compiler
312312
#define __COMPILER__ "Clang"
313-
#define __COMPILER_VERSION__ __VERSION__
313+
#define __COMPILER_VERSION__ __clang_version__
314314
#elif defined(__GNUC__) || defined(__GNUG__) // GNU GCC
315315
#define __COMPILER__ "GNU GCC"
316316
#define __COMPILER_VERSION__ __VERSION__

0 commit comments

Comments
 (0)