blob: 1f465dbb6e8e20f50616083c39dc92b4b2dc95b9 [file] [log] [blame]
Andrew Geissler97771a32021-03-05 15:23:11 -06001From de10fbc2386dcac3ab810c49b6977b2ee01bf426 Mon Sep 17 00:00:00 2001
Andrew Geissler82c905d2020-04-13 13:39:40 -05002From: Khem Raj <raj.khem@gmail.com>
Andrew Geissler97771a32021-03-05 15:23:11 -06003Date: Wed, 17 Feb 2021 13:30:23 -0800
Andrew Geissler82c905d2020-04-13 13:39:40 -05004Subject: [PATCH] setup.py: Do not mix C and C++ compiler options
5
6EXTRA_ENV_COMPILE_ARGS is used both with CC and CXX
7so using -std=c++11 or -std=gnu99 together will cause
8build time errors espcially with clang
9
Andrew Geissler97771a32021-03-05 15:23:11 -060010Keep '-std=c++11' to fix native build error
Andrew Geissler82c905d2020-04-13 13:39:40 -050011with old gcc (such as gcc 5.4.0 on ubuntu 16.04), for clang
12we will remove them through GRPC_PYTHON_CFLAGS at do_compile
13in bb recipe.
14
Andrew Geissler97771a32021-03-05 15:23:11 -060015While export CC="gcc ", cc_args is None, it will
Andrew Geissler82c905d2020-04-13 13:39:40 -050016cause subprocess.Popen always return 1. On centos 8, if you don't
17install package libatomic, there will be a native build error
18`cannot find /usr/lib64/libatomic.so.1.2.0'.
19
20Add no harm '-g' to cc_args if cc_args is empty.
21
22Upstream-Status: Inappropriate [oe specific]
Andrew Geissler97771a32021-03-05 15:23:11 -060023
24Signed-off-by: Khem Raj <raj.khem@gmail.com>
Andrew Geissler82c905d2020-04-13 13:39:40 -050025Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Andrew Geissler87f5cff2022-09-30 13:13:31 -050026Signed-off-by: Wang Mingyu <wangmy@fujitsu.com>
Andrew Geissler82c905d2020-04-13 13:39:40 -050027---
Andrew Geissler87f5cff2022-09-30 13:13:31 -050028 setup.py | 11 +++++++----
29 src/python/grpcio/commands.py | 5 ++++-
30 2 files changed, 11 insertions(+), 5 deletions(-)
Andrew Geissler82c905d2020-04-13 13:39:40 -050031
Andrew Geissler615f2f12022-07-15 14:00:58 -050032diff --git a/setup.py b/setup.py
Andrew Geissler87f5cff2022-09-30 13:13:31 -050033index 3a50c97..bb2386d 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050034--- a/setup.py
35+++ b/setup.py
Andrew Geissler87f5cff2022-09-30 13:13:31 -050036@@ -205,8 +205,11 @@ def check_linker_need_libatomic():
Andrew Geissler97771a32021-03-05 15:23:11 -060037 """Test if linker on system needs libatomic."""
38 code_test = (b'#include <atomic>\n' +
39 b'int main() { return std::atomic<int64_t>{}; }')
Andrew Geissler615f2f12022-07-15 14:00:58 -050040- cxx = shlex.split(os.environ.get('CXX', 'c++'))
41- cpp_test = subprocess.Popen(cxx + ['-x', 'c++', '-std=c++14', '-'],
Andrew Geissler97771a32021-03-05 15:23:11 -060042+ cxx, cxx_args = os.environ.get('CXX').split(' ', 1) or 'c++'
43+ if not cxx_args:
44+ cxx_args = "-g"
Andrew Geissler82c905d2020-04-13 13:39:40 -050045+
Andrew Geissler615f2f12022-07-15 14:00:58 -050046+ cpp_test = subprocess.Popen([cxx, cxx_args, '-x', 'c++', '-std=c++14', '-'],
Andrew Geissler97771a32021-03-05 15:23:11 -060047 stdin=PIPE,
48 stdout=PIPE,
49 stderr=PIPE)
Andrew Geissler87f5cff2022-09-30 13:13:31 -050050@@ -215,8 +218,8 @@ def check_linker_need_libatomic():
51 return False
Andrew Geissler97771a32021-03-05 15:23:11 -060052 # Double-check to see if -latomic actually can solve the problem.
53 # https://github.com/grpc/grpc/issues/22491
Andrew Geissler87f5cff2022-09-30 13:13:31 -050054- cpp_test = subprocess.Popen(cxx +
55- ['-x', 'c++', '-std=c++14', '-', '-latomic'],
56+ cpp_test = subprocess.Popen(
57+ [cxx, cxx_args, '-x', 'c++', '-std=c++14', '-', '-latomic'],
58 stdin=PIPE,
59 stdout=PIPE,
60 stderr=PIPE)
Andrew Geissler615f2f12022-07-15 14:00:58 -050061diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py
62index d93b6c7..a8c4a51 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050063--- a/src/python/grpcio/commands.py
64+++ b/src/python/grpcio/commands.py
Andrew Geissler9aee5002022-03-30 16:27:02 +000065@@ -228,7 +228,10 @@ class BuildExt(build_ext.build_ext):
Andrew Geissler82c905d2020-04-13 13:39:40 -050066 """
Andrew Geissler97771a32021-03-05 15:23:11 -060067 try:
68 # TODO(lidiz) Remove the generated a.out for success tests.
Andrew Geissler615f2f12022-07-15 14:00:58 -050069- cc_test = subprocess.Popen(['cc', '-x', 'c', '-std=c++14', '-'],
Andrew Geissler97771a32021-03-05 15:23:11 -060070+ cc_test, cc_args = os.environ.get('CC').split(' ', 1) or 'gcc'
71+ if not cc_args:
72+ cc_args = "-g"
Andrew Geissler615f2f12022-07-15 14:00:58 -050073+ cc_test = subprocess.Popen([cc_test, cc_args, '-x', 'c', '-std=c++14', '-'],
Andrew Geissler97771a32021-03-05 15:23:11 -060074 stdin=subprocess.PIPE,
75 stdout=subprocess.PIPE,
76 stderr=subprocess.PIPE)
Andrew Geissler615f2f12022-07-15 14:00:58 -050077--
782.25.1
79