Skip to content

Commit f348b6a

Browse files
authored
Merge pull request #350 from GeoscienceAustralia/dr-349
Fix locale issues
2 parents cef6587 + 4129428 commit f348b6a

6 files changed

Lines changed: 35 additions & 11 deletions

File tree

.github/workflows/build_and_test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,8 +1145,9 @@ jobs:
11451145
# Source Intel OneAPI environment
11461146
source /opt/intel/oneapi/setvars.sh
11471147
1148-
# Modify PATH to use our binaries
1148+
# Modify PATH and LD_LIBRARY_PATH to use our binaries
11491149
export PATH="../bin:$PATH"
1150+
export LD_LIBRARY_PATH="../bin:${LD_LIBRARY_PATH:-}"
11501151
11511152
# Run the test script and capture output
11521153
set +e # Don't exit on error
@@ -1169,8 +1170,9 @@ jobs:
11691170
# Source Intel OneAPI environment
11701171
source /opt/intel/oneapi/setvars.sh
11711172
1172-
# Modify PATH to use our binaries
1173+
# Modify PATH and LD_LIBRARY_PATH to use our binaries
11731174
export PATH="../bin:$PATH"
1175+
export LD_LIBRARY_PATH="../bin:${LD_LIBRARY_PATH:-}"
11741176
11751177
# Run the test script and capture output
11761178
set +e # Don't exit on error

dynadjust/CMakeLists.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,16 @@ if(BUILD_TESTING)
5959
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6060
endif()
6161

62-
# Set output directories for all platforms to use ../bin/
63-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../bin)
64-
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../bin)
65-
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../bin)
62+
# Set output directories for all platforms to use ../bin/ (unless overridden)
63+
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
64+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../bin)
65+
endif()
66+
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
67+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../bin)
68+
endif()
69+
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
70+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/../bin)
71+
endif()
6672

6773
# For multi-config generators (Visual Studio, Xcode)
6874
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
@@ -300,10 +306,13 @@ message(STATUS "Found Boost version: ${Boost_VERSION}")
300306
# Set up libraries
301307
# ----------------------------------------------------------------------------
302308

309+
find_package(Threads REQUIRED)
310+
303311
set(DNA_LIBRARIES
304312
${Boost_LIBRARIES}
305313
${XercesC_LIBRARIES}
306314
${XERCES_ICU_LIBRARIES}
315+
Threads::Threads
307316
)
308317

309318
# ----------------------------------------------------------------------------

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__

dynadjust/include/functions/dnaiostreamfuncs.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void print_file_header(
132132
stream << std::setw(PRINT_VAR_PAD) << std::left << "File created:";
133133
std::ostringstream datetime_ss;
134134
boost::posix_time::time_facet* p_time_output = new boost::posix_time::time_facet;
135-
std::locale special_locale (std::locale(""), p_time_output);
135+
std::locale special_locale (std::locale::classic(), p_time_output);
136136
// special_locale takes ownership of the p_time_output facet
137137
datetime_ss.imbue (special_locale);
138138
(*p_time_output).format("%A, %d %B %Y, %X");

dynadjust/include/functions/dnatemplatedatetimefuncs.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ T formattedDateTimeString()
548548
{
549549
std::stringstream datetime_ss, stream;
550550
boost::posix_time::time_facet* p_time_output = new boost::posix_time::time_facet;
551-
std::locale special_locale (std::locale(""), p_time_output);
551+
std::locale special_locale (std::locale::classic(), p_time_output);
552552

553553
// special_locale takes ownership of the p_time_output facet
554554
datetime_ss.imbue (special_locale);

0 commit comments

Comments
 (0)