From 7dcba1a700a2af129716783393af55d69a7b3f3e Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Fri, 21 Aug 2020 09:54:07 -0700 Subject: [PATCH 1/2] Make check_linker_need_libatomic more robust --- setup.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 20a6d76dbe0..88a7ef47956 100644 --- a/setup.py +++ b/setup.py @@ -171,7 +171,17 @@ def check_linker_need_libatomic(): stdout=PIPE, stderr=PIPE) cc_test.communicate(input=code_test) - return cc_test.returncode != 0 + if cc_test.returncode == 0: + return False + # Double-check to see if -latomic actually can solve the problem. + # https://github.com/grpc/grpc/issues/22491 + cc_test = subprocess.Popen( + ['cc', '-x', 'c++', '-std=c++11', '-latomic', '-'], + stdin=PIPE, + stdout=PIPE, + stderr=PIPE) + cc_test.communicate(input=code_test) + return cc_test.returncode == 0 # There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are From 3b8044ae4ec5d9791881e59b0ea84ac71f897921 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Thu, 27 Aug 2020 19:57:02 -0700 Subject: [PATCH 2/2] Use c++ instead of cc --- setup.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 88a7ef47956..18be2e17817 100644 --- a/setup.py +++ b/setup.py @@ -166,22 +166,22 @@ def check_linker_need_libatomic(): """Test if linker on system needs libatomic.""" code_test = (b'#include \n' + b'int main() { return std::atomic{}; }') - cc_test = subprocess.Popen(['cc', '-x', 'c++', '-std=c++11', '-'], - stdin=PIPE, - stdout=PIPE, - stderr=PIPE) - cc_test.communicate(input=code_test) - if cc_test.returncode == 0: + cpp_test = subprocess.Popen(['c++', '-x', 'c++', '-std=c++11', '-'], + stdin=PIPE, + stdout=PIPE, + stderr=PIPE) + cpp_test.communicate(input=code_test) + if cpp_test.returncode == 0: return False # Double-check to see if -latomic actually can solve the problem. # https://github.com/grpc/grpc/issues/22491 - cc_test = subprocess.Popen( - ['cc', '-x', 'c++', '-std=c++11', '-latomic', '-'], + cpp_test = subprocess.Popen( + ['c++', '-x', 'c++', '-std=c++11', '-latomic', '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE) - cc_test.communicate(input=code_test) - return cc_test.returncode == 0 + cpp_test.communicate(input=code_test) + return cpp_test.returncode == 0 # There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are