升级third_party/c-ares库后构建Python/Cython版gRPC失败求助
升级third_party/c-ares库后构建Python/Cython版gRPC失败求助
我最近碰到了一个头疼的问题,想请大家帮忙出出主意。情况是这样的:为了发布包含gRPC的软件,我们必须处理所有安全问题,而BDBA标记了grpc/c-ares的一堆CVE。gRPC仓库里的third_party/cares库用的是已经废弃两年多的v1.19.1版本,所以我想升级它来解决安全隐患。
我主要关注Python/Cython环境的安装,尝试手动升级c-ares子模块后构建wheel包,但过程一直失败。我在Fedora 37构建服务器上测试,同时在Ubuntu 24.04和RHEL系统上也碰到了同样的问题。另外,我试过多个gRPC版本:1.59.2、1.69.0、1.71.0,结果都一样。
下面是我的操作步骤:
git clone -b v1.69.0 https://github.com/grpc/grpc cd grpc git submodule update --init pip install -r requirements.txt cd third_party/cares/cares git fetch --tags git checkout tags/v1.34.4 cd ../../.. GRPC_PYTHON_BUILD_WITH_CYTHON=1 python setup.py bdist_wheel
构建失败的报错信息如下:
gcc -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -D_WIN32_WINNT=1536 -DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"Python\" -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"1.69.0\" -DHAVE_CONFIG_H=1 -DGRPC_ENABLE_FORK_SUPPORT=1 -DGRPC_DO_NOT_INSTANTIATE_POSIX_POLLER=1 -D__STDC_FORMAT_MACROS "-DPyMODINIT_FUNC=extern \"C\" __attribute__((visibility (\"default\"))) PyObject*" -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 -Isrc/python/grpcio -Iinclude -I. -Ithird_party/abseil-cpp -Ithird_party/address_sorting/include -Ithird_party/cares/cares/include -Ithird_party/cares -Ithird_party/cares/cares -Ithird_party/cares/config_linux -Ithird_party/re2 -Ithird_party/boringssl-with-bazel/src/include -Ithird_party/upb -Isrc/core/ext/upb-gen -Isrc/core/ext/upbdefs-gen -Ithird_party/utf8_range -Ithird_party/xxhash -Ithird_party/zlib -I/usr/include/python3.11 -c third_party/abseil-cpp/absl/base/internal/cycleclock.cc -o pyb/temp.linux-x86_64-cpython-311/third_party/abseil-cpp/absl/base/internal/cycleclock.o -std=c++14 -fvisibility=hidden -fno-wrapv -fno-exceptions -pthread gcc -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -D_WIN32_WINNT=1536 -DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"Python\" -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"1.69.0\" -DHAVE_CONFIG_H=1 -DGRPC_ENABLE_FORK_SUPPORT=1 -DGRPC_DO_NOT_INSTANTIATE_POSIX_POLLER=1 -D__STDC_FORMAT_MACROS "-DPyMODINIT_FUNC=extern \"C\" __attribute__((visibility (\"default\"))) PyObject*" -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 -Isrc/python/grpcio -Iinclude -I. -Ithird_party/abseil-cpp -Ithird_party/address_sorting/include -Ithird_party/cares/cares/include -Ithird_party/cares -Ithird_party/cares/cares -Ithird_party/cares/config_linux -Ithird_party/re2 -Ithird_party/boringssl-with-bazel/src/include -Ithird_party/upb -Isrc/core/ext/upb-gen -Isrc/core/ext/upbdefs-gen -Ithird_party/utf8_range -Ithird_party/xxhash -Ithird_party/zlib -I/usr/include/python3.11 -c third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc -o pyb/temp.linux-x86_64-cpython-311/third_party/abseil-cpp/absl/base/internal/low_level_alloc.o -std=c++14 -fvisibility=hidden -fno-wrapv -fno-exceptions -pthread gcc -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -D_WIN32_WINNT=1536 -DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"Python\" -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"1.69.0\" -DHAVE_CONFIG_H=1 -DGRPC_ENABLE_FORK_SUPPORT=1 -DGRPC_DO_NOT_INSTANTIATE_POSIX_POLLER=1 -D__STDC_FORMAT_MACROS "-DPyMODINIT_FUNC=extern \"C\" __attribute__((visibility (\"default\"))) PyObject*" -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 -Isrc/python/grpcio -Iinclude -I. -Ithird_party/abseil-cpp -Ithird_party/address_sorting/include -Ithird_party/cares/cares/include -Ithird_party/cares -Ithird_party/cares/cares -Ithird_party/cares/config_linux -Ithird_party/re2 -Ithird_party/boringssl-with-bazel/src/include -Ithird_party/upb -Isrc/core/ext/upb-gen -Isrc/core/ext/upbdefs-gen -Ithird_party/utf8_range -Ithird_party/xxhash -Ithird_party/zlib -I/usr/include/python3.11 -c third_party/abseil-cpp/absl/base/internal/raw_logging.cc -o pyb/temp.linux-x86_64-cpython-311/third_party/abseil-cpp/absl/base/internal/raw_logging.o -std=c++14 -fvisibility=hidden -fno-wrapv -fno-exceptions -pthread creating None creating None/tmp creating None/tmp/tmpenr0zk78 gcc -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python3.11 -c /tmp/tmpenr0zk78/a.c -o None/tmp/tmpenr0zk78/a.o Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/unixccompiler.py", line 186, in _compile self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs) File "/root/grpc/src/python/grpcio/_spawn_patch.py", line 58, in _commandfile_spawn _classic_spawn(self, command, **kwargs) File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/ccompiler.py", line 1007, in spawn spawn(cmd, dry_run=self.dry_run, **kwargs) File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/spawn.py", line 70, in spawn raise DistutilsExecError( distutils.errors.DistutilsExecError: command '/usr/bin/gcc' failed with exit code 1 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/root/grpc/src/python/grpcio/commands.py", line 313, in build_extensions build_ext.build_ext.build_extensions(self) File "/usr/lib64/python3.11/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions _build_ext.build_ext.build_extensions(self) File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 466, in build_extensions self._build_extensions_serial() File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 492, in _build_extensions_serial self.build_extension(ext) File "/usr/local/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 246, in build_extension _build_ext.build_extension(self, ext) File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 547, in build_extension objects = self.compiler.compile( ^^^^^^^^^^^^^^^^^^^^^^ File "/root/grpc/src/python/grpcio/_compiler_patch.py", line 52, in compile self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/unixccompiler.py", line 189, in _compile raise CompileError(msg) distutils.errors.CompileError: command '/usr/bin/gcc' failed with exit code 1
有没有朋友遇到过类似的问题?或者能给我一些排查方向吗?非常感谢!
备注:内容来源于stack exchange,提问作者5abeel
相关产品推荐
相关产品推荐

