grpcio_tools: setup.py: update libatomic check from top-level setup.py

pull/24274/head
Ben Wolsieffer 4 years ago
parent ad36ff39d3
commit 1024ebeb31
  1. 16
      tools/distrib/python/grpcio_tools/setup.py

@ -70,12 +70,22 @@ def check_linker_need_libatomic():
"""Test if linker on system needs libatomic.""" """Test if linker on system needs libatomic."""
code_test = (b'#include <atomic>\n' + code_test = (b'#include <atomic>\n' +
b'int main() { return std::atomic<int64_t>{}; }') b'int main() { return std::atomic<int64_t>{}; }')
cc_test = subprocess.Popen(['cc', '-x', 'c++', '-std=c++11', '-'], cpp_test = subprocess.Popen(['c++', '-x', 'c++', '-std=c++11', '-'],
stdin=PIPE, stdin=PIPE,
stdout=PIPE, stdout=PIPE,
stderr=PIPE) stderr=PIPE)
cc_test.communicate(input=code_test) cpp_test.communicate(input=code_test)
return cc_test.returncode != 0 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
cpp_test = subprocess.Popen(
['c++', '-x', 'c++', '-std=c++11', '-latomic', '-'],
stdin=PIPE,
stdout=PIPE,
stderr=PIPE)
cpp_test.communicate(input=code_test)
return cpp_test.returncode == 0
# There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are # There are some situations (like on Windows) where CC, CFLAGS, and LDFLAGS are

Loading…
Cancel
Save