Skip to contentSkip to conversation

python-grpcio: Use gettid API from glibc 2.30+

PATCH New Khem Raj 1 participant 3 messages Aug 7, 2019

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/3 python-grpcio: Use gettid API from glibc 2.30+

---
 .../recipes-devtools/python/python-grpcio.inc |  1 +
 .../python/python-grpcio/gettid.patch         | 26 +++++++++++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python-grpcio/gettid.patch
meta-python/recipes-devtools/python/python-grpcio.inc +1 -0
index fd341f5de7..7d3675c455 100644
@@ -9,6 +9,7 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/python-grpcio:"
 SRC_URI_append_class-target = " file://0001-setup.py-Do-not-mix-C-and-C-compiler-options.patch \
                                 file://ppc-boringssl-support.patch \
                                 file://riscv64_support.patch \
+                                file://gettid.patch \
 "
 
 RDEPENDS_${PN} = "${PYTHON_PN}-protobuf \
meta-python/recipes-devtools/python/python-grpcio/gettid.patch new file +26 -0
new file mode 100644
index 0000000000..fb15cf7f96
@@ -0,0 +1,26 @@
+use glibc provided gettid API for glibc 2.30+
+
+glibc 2.30 introduced this function see [1]
+so it's best to detect it
+and provide fallback only if it's not present
+
+[1] https://sourceware.org/bugzilla/show_bug.cgi?id=6399
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+--- a/src/core/lib/gpr/log_linux.cc
++++ b/src/core/lib/gpr/log_linux.cc
+@@ -40,7 +40,13 @@
+ #include <time.h>
+ #include <unistd.h>
+ 
++#if  defined(__GLIBC__)
++#if !__GLIBC_PREREQ(2,29)
+ static long gettid(void) { return syscall(__NR_gettid); }
++#endif
++#else
++static long gettid(void) { return syscall(__NR_gettid); }
++#endif
+ 
+ void gpr_log(const char* file, int line, gpr_log_severity severity,
+              const char* format, ...) {
Signature · 1 line
2.22.0
author
#1 lore raw

PATCH 2/3 grpc: Update to 1.22.0

Fix build with glibc 2.30
Forward port patches
Add versioiniing to grpcpp_channelz plugin

---
 ...ix-grpc_cpp_plugin-path-during-cross.patch | 32 ++---------
 ...Fix-libraries-installation-for-Linux.patch | 44 ++++++++-------
 ...01-Define-gettid-only-for-glibc-2.30.patch | 53 +++++++++++++++++++
 .../grpc/{grpc_1.14.1.bb => grpc_1.22.0.bb}   |  8 +--
 4 files changed, 86 insertions(+), 51 deletions(-)
 create mode 100644 meta-networking/recipes-devtools/grpc/grpc/0001-Define-gettid-only-for-glibc-2.30.patch
 rename meta-networking/recipes-devtools/grpc/{grpc_1.14.1.bb => grpc_1.22.0.bb} (86%)
meta-networking/recipes-devtools/grpc/grpc/0001-CMakeLists.txt-Fix-grpc_cpp_plugin-path-during-cross.patch +3 -29
index 54e0b99a46..6cad533964 100644
@@ -1,8 +1,7 @@
 From 6d606f1101c1a172fb6d738d6f1865aa61849e68 Mon Sep 17 00:00:00 2001
 From: Alexey Firago <[email protected]>
 Date: Fri, 20 Oct 2017 00:04:19 +0300
-Subject: [PATCH] CMakeLists.txt: Fix grpc_cpp_plugin path during
- cross-compiling or native build
+Subject: [PATCH] CMakeLists.txt: Fix grpc_cpp_plugin path during cross-compiling or native build
 
 Signed-off-by: Alexey Firago <[email protected]>
 Signed-off-by: Hiram Lew <[email protected]>
@@ -12,11 +11,9 @@ Signed-off-by: Jan Kaisrlik <[email protected]>
  templates/CMakeLists.txt.template | 9 ++++++++-
  2 files changed, 16 insertions(+), 2 deletions(-)
 
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index a59fd81..cd90424 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
-@@ -160,6 +160,13 @@ function(protobuf_generate_grpc_cpp)
+@@ -193,6 +193,13 @@ function(protobuf_generate_grpc_cpp)
      return()
    endif()
  
@@ -30,20 +27,9 @@ index a59fd81..cd90424 100644
    set(_protobuf_include_path -I . -I ${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR})
    foreach(FIL ${ARGN})
      get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
-@@ -177,7 +184,7 @@ function(protobuf_generate_grpc_cpp)
-       COMMAND ${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}
-       ARGS --grpc_out=generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}
-            --cpp_out=${_gRPC_PROTO_GENS_DIR}
--           --plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin>
-+           --plugin=protoc-gen-grpc=${gRPC_CPP_PLUGIN}
-            ${_protobuf_include_path}
-            ${REL_FIL}
-       DEPENDS ${ABS_FIL} ${_gRPC_PROTOBUF_PROTOC} grpc_cpp_plugin
-diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
-index de13d02..b22bd5c 100644
 --- a/templates/CMakeLists.txt.template
 +++ b/templates/CMakeLists.txt.template
-@@ -209,6 +209,13 @@
+@@ -233,6 +233,13 @@
        return()
      endif()
  
@@ -57,15 +43,3 @@ index de13d02..b22bd5c 100644
      set(_protobuf_include_path -I . -I <%text>${_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR}</%text>)
      foreach(FIL <%text>${ARGN}</%text>)
        get_filename_component(ABS_FIL <%text>${FIL}</%text> ABSOLUTE)
-@@ -226,7 +233,7 @@
-         COMMAND <%text>${_gRPC_PROTOBUF_PROTOC_EXECUTABLE}</%text>
-         ARGS --grpc_out=<%text>generate_mock_code=true:${_gRPC_PROTO_GENS_DIR}</%text>
-              --cpp_out=<%text>${_gRPC_PROTO_GENS_DIR}</%text>
--             --plugin=protoc-gen-grpc=$<TARGET_FILE:grpc_cpp_plugin>
-+             --plugin=protoc-gen-grpc=${gRPC_CPP_PLUGIN}
-              <%text>${_protobuf_include_path}</%text>
-              <%text>${REL_FIL}</%text>
-         DEPENDS <%text>${ABS_FIL}</%text> <%text>${_gRPC_PROTOBUF_PROTOC}</%text> grpc_cpp_plugin
--- 
-2.7.4
-
meta-networking/recipes-devtools/grpc/grpc/0001-CMakeLists.txt-Fix-libraries-installation-for-Linux.patch +25 -19

131 lines not on this page · raw message

meta-networking/recipes-devtools/grpc/grpc/0001-Define-gettid-only-for-glibc-2.30.patch new file +53 -0

53 lines not on this page · raw message

meta-networking/recipes-devtools/grpc/grpc_1.22.0.bb renamed from meta-networking/recipes-devtools/grpc/grpc_1.14.1.bb +5 -3
similarity index 86%
rename from meta-networking/recipes-devtools/grpc/grpc_1.14.1.bb
rename to meta-networking/recipes-devtools/grpc/grpc_1.22.0.bb
index 0550866e5b..a80c574cc9 100644
@@ -11,12 +11,14 @@ DEPENDS_append_class-target = " googletest grpc-native "
 DEPENDS_append_class-nativesdk = " grpc-native "
 
 S = "${WORKDIR}/git"
-SRCREV = "d8020cb6daa87f1a3bb3b0c299bc081c4a3de1e8"
-BRANCH = "v1.14.x"
+SRCREV = "08fd59f039c7cf62614ab7741b3f34527af103c7"
+BRANCH = "v1.22.x"
 SRC_URI = "git://github.com/grpc/grpc.git;protocol=https;branch=${BRANCH} \
            file://0001-CMakeLists.txt-Fix-libraries-installation-for-Linux.patch \
            "
-SRC_URI_append_class-target = " file://0001-CMakeLists.txt-Fix-grpc_cpp_plugin-path-during-cross.patch"
+SRC_URI_append_class-target = " file://0001-CMakeLists.txt-Fix-grpc_cpp_plugin-path-during-cross.patch \
+                                file://0001-Define-gettid-only-for-glibc-2.30.patch \
+                               "
 SRC_URI_append_class-nativesdk = " file://0001-CMakeLists.txt-Fix-grpc_cpp_plugin-path-during-cross.patch"
 
 # Fixes build with older compilers 4.8 especially on ubuntu 14.04
Signature · 1 line
2.22.0
author
#2 lore raw

PATCH 3/3 android-tools: Fix build with glibc 2.30

In reply to Khem Raj
---
 ...t-define-gettid-if-glibc-2.30-is-use.patch | 52 +++++++++++++++++++
 .../android-tools/android-tools_5.1.1.r37.bb  |  1 +
 2 files changed, 53 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch
meta-oe/recipes-devtools/android-tools/android-tools/libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch new file +52 -0
new file mode 100644
index 0000000000..8524517cb6
@@ -0,0 +1,52 @@
+From f4f9d24860e1b5cd4f6a014f3fda7cd33ebe5be7 Mon Sep 17 00:00:00 2001
+From: Petr Lautrbach <[email protected]>
+Date: Sat, 27 Jul 2019 08:20:20 -0700
+Subject: [PATCH] libselinux: Do not define gettid() if glibc >= 2.30 is used
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Since version 2.30 glibc implements gettid() system call wrapper, see
+https://sourceware.org/bugzilla/show_bug.cgi?id=6399
+
+Fixes:
+cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -I../include -D_GNU_SOURCE  -DNO_ANDROID_BACKEND   -c -o procattr.o procattr.c
+procattr.c:28:14: error: static declaration of ‘gettid’ follows non-static declaration
+   28 | static pid_t gettid(void)
+      |              ^~~~~~
+In file included from /usr/include/unistd.h:1170,
+                 from procattr.c:2:
+/usr/include/bits/unistd_ext.h:34:16: note: previous declaration of ‘gettid’ was here
+   34 | extern __pid_t gettid (void) __THROW;
+      |                ^~~~~~
+
+Signed-off-by: Petr Lautrbach <[email protected]>
+Acked-by: Stephen Smalley <[email protected]>
+Signed-off-by: Khem Raj <[email protected]>
+---
+ src/procattr.c | 14 +++++++++++++-
+ 1 file changed, 13 insertions(+), 1 deletion(-)
+
+--- a/src/procattr.c
++++ b/src/procattr.c
+@@ -8,7 +8,19 @@
+ #include "selinux_internal.h"
+ #include "policy.h"
+ 
+-#ifndef __BIONIC__
++/* Bionic and glibc >= 2.30 declare gettid() system call wrapper in unistd.h and
++ * has a definition for it */
++#ifdef __BIONIC__
++  #define OVERRIDE_GETTID 0
++#elif !defined(__GLIBC_PREREQ)
++  #define OVERRIDE_GETTID 1
++#elif !__GLIBC_PREREQ(2,29)
++  #define OVERRIDE_GETTID 1
++#else
++  #define OVERRIDE_GETTID 0
++#endif
++
++#if OVERRIDE_GETTID
+ static pid_t gettid(void)
+ {
+ 	return syscall(__NR_gettid);
meta-oe/recipes-devtools/android-tools/android-tools_5.1.1.r37.bb +1 -0
index e09cd829d7..d84fcaecc9 100644
@@ -41,6 +41,7 @@ SRC_URI = " \
     file://extras/0001-ext4_utils-remove-selinux-extensions.patch;patchdir=system/extras \
     file://extras/0002-ext4_utils-add-o-argument-to-preserve-ownership.patch;patchdir=system/extras \
     file://libselinux/0001-Remove-bionic-specific-calls.patch;patchdir=external/libselinux \
+    file://libselinux/0001-libselinux-Do-not-define-gettid-if-glibc-2.30-is-use.patch;patchdir=external/libselinux \
     file://android-tools-adbd.service \
     file://gitignore \
     file://adb.mk;subdir=${BPN} \
Signature · 1 line
2.22.0