buildroot/package/grpc/0002-Properly-detect-the-availability-of-pthread_setname_.patch
Adam Duskett e0e54afd0c package/grpc: bump to version 1.25.0
Other changes:

 - Remove upstream patch 0004-Fix-gettid-naming-conflict.patch
 - Remove upstream patch 0005-Rename-gettid-functions.patch
 - Add a check for BR2_TOOLCHAIN_GCC_AT_LEAST_5 in grpc.mk. If the
   selected toolchain is not at least version 5 or higher and the
   optimization level is -Os, set the GRPC_CFLAGS and GRPC_CXXFLAGS
   optimizations to -O2. This check prevents the following error:

   error: failure memory model cannot be stronger than success memory model for '__atomic_compare_exchange'

Tested with test-pkg, all tests passed:
            br-arm-full [1/6]: OK
 br-arm-cortex-a9-glibc [2/6]: OK
  br-arm-cortex-m4-full [3/6]: SKIPPED
         br-x86-64-musl [4/6]: OK
     br-arm-full-static [5/6]: SKIPPED

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2019-12-08 15:39:57 +01:00

53 lines
1.8 KiB
Diff

From 0dfb289a3b362b082ac3608d887e42f09dadc0d2 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Date: Mon, 31 Dec 2018 16:22:07 +0100
Subject: [PATCH] Properly detect the availability of pthread_setname_np()
This commit adds a CMake check for the availability of
pthread_setname_np(), and only uses it on Linux when available.
Indeed, some C libraries, such as uClibc, do not provide this
non-POSIX function in all cases.
Upstream: https://github.com/grpc/grpc/pull/17610
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
CMakeLists.txt | 6 ++++++
include/grpc/impl/codegen/port_platform.h | 2 ++
2 files changed, 8 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 89e834b..c7bd2ad 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -97,6 +97,12 @@ endif()
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
+include(CheckSymbolExists)
+check_symbol_exists(pthread_setname_np pthread.h HAVE_PTHREAD_SETNAME_NP)
+if (HAVE_PTHREAD_SETNAME_NP)
+ add_definitions(-DHAVE_PTHREAD_SETNAME_NP)
+endif ()
+
if (MSVC)
include(cmake/msvc_static_runtime.cmake)
add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h
index 031c0c3..a29a9dc 100644
--- a/include/grpc/impl/codegen/port_platform.h
+++ b/include/grpc/impl/codegen/port_platform.h
@@ -181,7 +181,9 @@
#endif /* _LP64 */
#ifdef __GLIBC__
#define GPR_POSIX_CRASH_HANDLER 1
+#if defined(HAVE_PTHREAD_SETNAME_NP)
#define GPR_LINUX_PTHREAD_NAME 1
+#endif /* HAVE_PTHREAD_SETNAME_NP */
#include <linux/version.h>
#else /* musl libc */
#define GPR_MUSL_LIBC_COMPAT 1
--
2.14.4