[meta-oe,2/2] grpc: Fix build with rv32/rv64

Message ID 20220419231024.283373-2-raj.khem@gmail.com
State New
Headers show
Series [meta-oe,1/2] dlt-daemon: Fix build on rv32/rv64 | expand

Commit Message

Khem Raj April 19, 2022, 11:10 p.m. UTC
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...ake-Link-with-libatomic-on-rv32-rv64.patch | 32 +++++++++++++++++++
 meta-oe/recipes-devtools/grpc/grpc_1.45.2.bb  |  1 +
 2 files changed, 33 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/grpc/grpc/0001-cmake-Link-with-libatomic-on-rv32-rv64.patch

Patch

diff --git a/meta-oe/recipes-devtools/grpc/grpc/0001-cmake-Link-with-libatomic-on-rv32-rv64.patch b/meta-oe/recipes-devtools/grpc/grpc/0001-cmake-Link-with-libatomic-on-rv32-rv64.patch
new file mode 100644
index 0000000000..c2afd4a92e
--- /dev/null
+++ b/meta-oe/recipes-devtools/grpc/grpc/0001-cmake-Link-with-libatomic-on-rv32-rv64.patch
@@ -0,0 +1,32 @@ 
+From 592a4aaba20818bcff9a1448c34b09aff9e0d2e9 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 19 Apr 2022 16:07:19 -0700
+Subject: [PATCH] cmake: Link with libatomic on rv32/rv64
+
+Fixes
+riscv64-yoe-linux-musl/12.0.1/ld: libgrpc.so.23.0.0: undefined reference to `__atomic_exchange_1'
+| collect2: error: ld returned 1 exit status
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ CMakeLists.txt | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index a8fd3bf37b3..9f5b242683d 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -303,6 +303,9 @@ if(UNIX)
+   if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_POSIX)
+     set(_gRPC_ALLTARGETS_LIBRARIES ${_gRPC_ALLTARGETS_LIBRARIES} rt)
+   endif()
++  if(CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv32")
++    set(_gRPC_ALLTARGETS_LIBRARIES ${_gRPC_ALLTARGETS_LIBRARIES} atomic)
++  endif()
+ endif()
+ 
+ # configure ccache if requested
+-- 
+2.36.0
+
diff --git a/meta-oe/recipes-devtools/grpc/grpc_1.45.2.bb b/meta-oe/recipes-devtools/grpc/grpc_1.45.2.bb
index 48d0f58e20..c2f952fc64 100644
--- a/meta-oe/recipes-devtools/grpc/grpc_1.45.2.bb
+++ b/meta-oe/recipes-devtools/grpc/grpc_1.45.2.bb
@@ -25,6 +25,7 @@  BRANCH = "v1.45.x"
 SRC_URI = "git://github.com/grpc/grpc.git;protocol=https;name=grpc;branch=${BRANCH} \
            file://0001-Revert-Changed-GRPCPP_ABSEIL_SYNC-to-GPR_ABSEIL_SYNC.patch \
            file://0001-cmake-add-separate-export-for-plugin-targets.patch \
+           file://0001-cmake-Link-with-libatomic-on-rv32-rv64.patch \
            "
 # Fixes build with older compilers 4.8 especially on ubuntu 14.04
 CXXFLAGS:append:class-native = " -Wl,--no-as-needed"