From 2babf8f6bfd50b30e19e7fe19e2ea8aa1d81761d Mon Sep 17 00:00:00 2001 From: Liviu Ionescu Date: Wed, 11 Oct 2023 23:22:23 +0300 Subject: [PATCH] rework -rpath list --- tests/platform-native/CMakeLists.txt | 20 +++++++++++++------ tests/platform-native/platform/CMakeLists.txt | 10 ++++++---- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/tests/platform-native/CMakeLists.txt b/tests/platform-native/CMakeLists.txt index ff893216..eb8a538d 100644 --- a/tests/platform-native/CMakeLists.txt +++ b/tests/platform-native/CMakeLists.txt @@ -27,11 +27,19 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") # On non-Windows, get the actual libraries paths by asking the compiler. execute_process( COMMAND "${CMAKE_SOURCE_DIR}/xpacks/@micro-os-plus/build-helper/dev-scripts/get-libraries-paths.sh" ${CMAKE_CXX_COMPILER} - OUTPUT_VARIABLE CXX_LIBRARY_PATH + OUTPUT_VARIABLE cxx_library_path OUTPUT_STRIP_TRAILING_WHITESPACE ) - cmake_path(GET CMAKE_CXX_COMPILER FILENAME CXX_FILENAME) - message(VERBOSE "${CXX_FILENAME} RPATH: ${CXX_LIBRARY_PATH}") + string(REPLACE ":" ";" cxx_library_path_list ${cxx_library_path}) + + set(rpath_options_list) + foreach(RPATH IN LISTS cxx_library_path_list) + cmake_path(SET normalized_path NORMALIZE ${RPATH}) + list(APPEND rpath_options_list "-Wl,-rpath,${normalized_path}") + endforeach() + + cmake_path(GET CMAKE_CXX_COMPILER FILENAME cxx_filename) + message(STATUS "${cxx_filename} RPATH_LIST: ${rpath_options_list}") endif() @@ -56,7 +64,7 @@ if (ENABLE_RTOS_APIS_TEST) # https://cmake.org/cmake/help/v3.20/manual/cmake-generator-expressions.7.html target_link_options(rtos-apis-test PRIVATE $<$:-Wl,-Map,platform-bin/rtos-apis-test-map.txt> - $<$:-Wl,-rpath,${CXX_LIBRARY_PATH}> + $<$:${rpath_options_list}> ) target_link_libraries(rtos-apis-test PRIVATE @@ -103,7 +111,7 @@ if (ENABLE_MUTEX_STRESS_TEST) # https://cmake.org/cmake/help/v3.20/manual/cmake-generator-expressions.7.html target_link_options(mutex-stress-test PRIVATE $<$:-Wl,-Map,platform-bin/mutex-stress-test-map.txt> - $<$:-Wl,-rpath,${CXX_LIBRARY_PATH}> + $<$:${rpath_options_list}> ) target_link_libraries(mutex-stress-test PRIVATE @@ -147,7 +155,7 @@ if (ENABLE_CMSIS_OS_VALIDATOR_TEST) # https://cmake.org/cmake/help/v3.20/manual/cmake-generator-expressions.7.html target_link_options(cmsis-os-validator-test PRIVATE $<$:-Wl,-Map,platform-bin/cmsis-os-validator-test-map.txt> - $<$:-Wl,-rpath,${CXX_LIBRARY_PATH}> + $<$:${rpath_options_list}> ) target_link_libraries(cmsis-os-validator-test PRIVATE diff --git a/tests/platform-native/platform/CMakeLists.txt b/tests/platform-native/platform/CMakeLists.txt index 117ef8e5..ee67a82f 100644 --- a/tests/platform-native/platform/CMakeLists.txt +++ b/tests/platform-native/platform/CMakeLists.txt @@ -54,7 +54,7 @@ set(xpack_platform_common_args if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") list(APPEND xpack_platform_common_args - # $<$:-Wno-used-but-marked-unused> + $<$:-Wno-used-but-marked-unused> ) endif() @@ -85,9 +85,11 @@ target_link_options(platform-native-interface INTERFACE $<$:-static> - # No need for them, -rpath is used. - # $<$,$>:-static-libgcc> - # $<$,$>:-static-libstdc++> + # On Linux no need for statics, -rpath is fine. + # On macOS, GCC 11 gets confused + # dyld[72401]: Symbol not found: (__ZNKSt3_V214error_category10_M_messageB5cxx11Ei) + $<$,$>:-static-libgcc> + $<$,$>:-static-libstdc++> $<$:-Wl,-dead_strip> $<$:-Wl,--gc-sections>