blob: 13911ddcf34d2edaf75780f361963bebff24f041 [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 Geissler82c905d2020-04-13 13:39:40 -050032--- a/setup.py
33+++ b/setup.py
Andrew Geissler8f840682023-07-21 09:09:43 -050034@@ -206,8 +206,11 @@ def check_linker_need_libatomic():
Andrew Geissler97771a32021-03-05 15:23:11 -060035 """Test if linker on system needs libatomic."""
36 code_test = (b'#include <atomic>\n' +
37 b'int main() { return std::atomic<int64_t>{}; }')
Andrew Geissler615f2f12022-07-15 14:00:58 -050038- cxx = shlex.split(os.environ.get('CXX', 'c++'))
39- cpp_test = subprocess.Popen(cxx + ['-x', 'c++', '-std=c++14', '-'],
Andrew Geissler97771a32021-03-05 15:23:11 -060040+ cxx, cxx_args = os.environ.get('CXX').split(' ', 1) or 'c++'
41+ if not cxx_args:
42+ cxx_args = "-g"
Andrew Geissler82c905d2020-04-13 13:39:40 -050043+
Andrew Geissler615f2f12022-07-15 14:00:58 -050044+ cpp_test = subprocess.Popen([cxx, cxx_args, '-x', 'c++', '-std=c++14', '-'],
Andrew Geissler97771a32021-03-05 15:23:11 -060045 stdin=PIPE,
46 stdout=PIPE,
47 stderr=PIPE)
Andrew Geissler8f840682023-07-21 09:09:43 -050048@@ -216,8 +219,8 @@ def check_linker_need_libatomic():
Andrew Geissler87f5cff2022-09-30 13:13:31 -050049 return False
Andrew Geissler97771a32021-03-05 15:23:11 -060050 # Double-check to see if -latomic actually can solve the problem.
51 # https://github.com/grpc/grpc/issues/22491
Andrew Geissler87f5cff2022-09-30 13:13:31 -050052- cpp_test = subprocess.Popen(cxx +
53- ['-x', 'c++', '-std=c++14', '-', '-latomic'],
54+ cpp_test = subprocess.Popen(
55+ [cxx, cxx_args, '-x', 'c++', '-std=c++14', '-', '-latomic'],
56 stdin=PIPE,
57 stdout=PIPE,
58 stderr=PIPE)
Andrew Geissler82c905d2020-04-13 13:39:40 -050059--- a/src/python/grpcio/commands.py
60+++ b/src/python/grpcio/commands.py
Andrew Geissler8f840682023-07-21 09:09:43 -050061@@ -228,8 +228,10 @@ class BuildExt(build_ext.build_ext):
Andrew Geissler82c905d2020-04-13 13:39:40 -050062 """
Andrew Geissler97771a32021-03-05 15:23:11 -060063 try:
64 # TODO(lidiz) Remove the generated a.out for success tests.
Andrew Geissler8f840682023-07-21 09:09:43 -050065- cc = os.environ.get('CC', 'cc')
66- cc_test = subprocess.Popen([cc, '-x', 'c', '-std=c++14', '-'],
Andrew Geissler97771a32021-03-05 15:23:11 -060067+ cc_test, cc_args = os.environ.get('CC').split(' ', 1) or 'gcc'
68+ if not cc_args:
69+ cc_args = "-g"
Andrew Geissler615f2f12022-07-15 14:00:58 -050070+ cc_test = subprocess.Popen([cc_test, cc_args, '-x', 'c', '-std=c++14', '-'],
Andrew Geissler97771a32021-03-05 15:23:11 -060071 stdin=subprocess.PIPE,
72 stdout=subprocess.PIPE,
73 stderr=subprocess.PIPE)