Respect CC environment variable. https://github.com/grpc/grpc/pull/26480 Use C++17 instead of C++14. https://github.com/grpc/grpc/issues/34256 https://github.com/grpc/grpc/commit/93b29607ccaa2545e2b3a5a8016f765333f1b38f --- src/python/grpcio/commands.py +++ src/python/grpcio/commands.py @@ -228,7 +228,8 @@ def compiler_ok_with_extra_std(): """ try: # TODO(lidiz) Remove the generated a.out for success tests. - cc_test = subprocess.Popen(['cc', '-x', 'c', '-std=c++14', '-'], + cc = os.environ.get('CC', 'cc') + cc_test = subprocess.Popen([cc, '-x', 'c', '-std=c++17', '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) --- tools/distrib/gen_compilation_database.py.orig 2024-12-29 20:39:24.000000000 -0600 +++ tools/distrib/gen_compilation_database.py 2024-12-29 21:30:07.000000000 -0600 @@ -88,7 +88,7 @@ # Workaround for bazel added C++14 options, those doesn't affect build itself but # clang-tidy will misinterpret them. options = options.replace("-std=c++0x ", "") - options = options.replace("-std=c++14 ", "") + options = options.replace("-std=c++17 ", "") # Add -DNDEBUG so that editors show the correct size information for structs. options += " -DNDEBUG" @@ -107,7 +107,7 @@ options += " -Wno-unused-function" if not target["file"].startswith("external/"): # *.h file is treated as C header by default while our headers files are all C++14. - options = "-x c++ -std=c++14 -fexceptions " + options + options = "-x c++ -std=c++17 -fexceptions " + options target["command"] = " ".join([cc, options]) return target --- tools/distrib/python/grpcio_tools/setup.py.orig 2024-12-29 20:39:24.000000000 -0600 +++ tools/distrib/python/grpcio_tools/setup.py 2024-12-29 21:30:07.000000000 -0600 @@ -88,7 +88,7 @@ code_test = (b'#include \n' + b'int main() { return std::atomic{}; }') cxx = os.environ.get('CXX', 'c++') - cpp_test = subprocess.Popen([cxx, '-x', 'c++', '-std=c++14', '-'], + cpp_test = subprocess.Popen([cxx, '-x', 'c++', '-std=c++17', '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE) @@ -98,7 +98,7 @@ # Double-check to see if -latomic actually can solve the problem. # https://github.com/grpc/grpc/issues/22491 cpp_test = subprocess.Popen( - [cxx, '-x', 'c++', '-std=c++14', '-', '-latomic'], + [cxx, '-x', 'c++', '-std=c++17', '-', '-latomic'], stdin=PIPE, stdout=PIPE, stderr=PIPE) @@ -134,7 +134,7 @@ EXTRA_ENV_COMPILE_ARGS = os.environ.get('GRPC_PYTHON_CFLAGS', None) EXTRA_ENV_LINK_ARGS = os.environ.get('GRPC_PYTHON_LDFLAGS', None) if EXTRA_ENV_COMPILE_ARGS is None: - EXTRA_ENV_COMPILE_ARGS = '-std=c++14' + EXTRA_ENV_COMPILE_ARGS = '-std=c++17' if 'win32' in sys.platform: if sys.version_info < (3, 5): # We use define flags here and don't directly add to DEFINE_MACROS below to --- tools/run_tests/artifacts/artifact_targets.py.orig 2024-12-29 20:39:24.000000000 -0600 +++ tools/run_tests/artifacts/artifact_targets.py 2024-12-29 21:30:07.000000000 -0600 @@ -384,7 +384,7 @@ environ=environ) else: environ[ - 'CXXFLAGS'] += ' -std=c++14 -stdlib=libc++ %s' % _MACOS_COMPAT_FLAG + 'CXXFLAGS'] += ' -std=c++17 -stdlib=libc++ %s' % _MACOS_COMPAT_FLAG return create_jobspec( self.name, ['tools/run_tests/artifacts/build_artifact_protoc.sh'], --- setup.py.orig 2024-12-29 20:39:21.000000000 -0600 +++ setup.py 2024-12-29 21:30:08.000000000 -0600 @@ -207,7 +207,7 @@ code_test = (b'#include \n' + b'int main() { return std::atomic{}; }') cxx = shlex.split(os.environ.get('CXX', 'c++')) - cpp_test = subprocess.Popen(cxx + ['-x', 'c++', '-std=c++14', '-'], + cpp_test = subprocess.Popen(cxx + ['-x', 'c++', '-std=c++17', '-'], stdin=PIPE, stdout=PIPE, stderr=PIPE) @@ -217,7 +217,7 @@ # Double-check to see if -latomic actually can solve the problem. # https://github.com/grpc/grpc/issues/22491 cpp_test = subprocess.Popen( - [cxx, '-x', 'c++', '-std=c++14', '-', '-latomic'], + [cxx, '-x', 'c++', '-std=c++17', '-', '-latomic'], stdin=PIPE, stdout=PIPE, stderr=PIPE) @@ -235,7 +235,7 @@ EXTRA_ENV_COMPILE_ARGS = os.environ.get('GRPC_PYTHON_CFLAGS', None) EXTRA_ENV_LINK_ARGS = os.environ.get('GRPC_PYTHON_LDFLAGS', None) if EXTRA_ENV_COMPILE_ARGS is None: - EXTRA_ENV_COMPILE_ARGS = ' -std=c++14' + EXTRA_ENV_COMPILE_ARGS = ' -std=c++17' if 'win32' in sys.platform: if sys.version_info < (3, 5): EXTRA_ENV_COMPILE_ARGS += ' -D_hypot=hypot'