dlt-daemon: Fix build on rv32/rv64

This is seen with gcc particularly

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj
2022-04-19 15:00:32 -07:00
parent 47d2307ae7
commit 62a60f91aa
2 changed files with 48 additions and 0 deletions
@@ -0,0 +1,45 @@
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
@@ -17,6 +17,7 @@ DEPENDS = "zlib gzip-native json-c"
SRC_URI = "git://github.com/GENIVI/${BPN}.git;protocol=https;branch=master \
file://0002-Don-t-execute-processes-as-a-specific-user.patch \
file://0004-Modify-systemd-config-directory.patch \
file://0001-cmake-Link-with-libatomic-on-rv32-rv64.patch \
"
SRCREV = "0138c00811c86eab4ff6bff3c6528163885ade19"
@@ -24,6 +25,8 @@ PV .= "+2.18.9git${SRCPV}"
S = "${WORKDIR}/git"
LDFLAGS:append:riscv64 = " -latomic"
PACKAGECONFIG ?= "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', ' systemd systemd-watchdog systemd-journal dlt-examples dlt-adaptor dlt-console ', '', d)} \
udp-connection dlt-system dlt-filetransfer "
# dlt-dbus