| From dd2d42a7f877d292f86e421dd9651f4b7c2abf18 Mon Sep 17 00:00:00 2001 |
| From: Khem Raj <raj.khem@gmail.com> |
| Date: Tue, 19 Apr 2022 14:57:58 -0700 |
| Subject: [PATCH] cmake: Link with libatomic on rv32/rv64 |
| |
| Use of <atomic> needs to link in libatomic on riscv |
| Fixes |
| |
| undefined reference to `__atomic_exchange_1' |
| |
| Upstream-Status: Pending |
| Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| --- |
| src/lib/CMakeLists.txt | 8 +++++++- |
| 1 file changed, 7 insertions(+), 1 deletion(-) |
| |
| diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt |
| index 3293376..65018be 100644 |
| --- a/src/lib/CMakeLists.txt |
| +++ b/src/lib/CMakeLists.txt |
| @@ -37,6 +37,12 @@ else() |
| set(SOCKET_LIBRARY socket) |
| endif() |
| |
| +if(CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv32") |
| + set(ATOMIC_LIBRARY atomic) |
| +else() |
| + set(ATOMIC_LIBRARY "") |
| +endif() |
| + |
| if(HAVE_FUNC_PTHREAD_SETNAME_NP) |
| add_definitions(-DDLT_USE_PTHREAD_SETNAME_NP) |
| message(STATUS "Using pthread_setname_np API to set thread name") |
| @@ -44,7 +50,7 @@ else() |
| message(STATUS "pthread_setname_np API not available on this platform") |
| endif() |
| |
| -target_link_libraries(dlt ${RT_LIBRARY} ${SOCKET_LIBRARY} Threads::Threads) |
| +target_link_libraries(dlt ${RT_LIBRARY} ${SOCKET_LIBRARY} ${ATOMIC_LIBRARY} Threads::Threads) |
| |
| target_include_directories(dlt |
| PUBLIC |
| -- |
| 2.36.0 |
| |