Skip to content

Commit ef78bdc

Browse files
committed
Filter out -flto from sysconfig's CFLAGS
An rpm build was failing during %test with Python 3.7, built with LTO, due to "-flto" coming in from sysconfig's CFLAGS in testcpybuilder.BuiltModule.compile_src, and thus the plugin unexpectedly running from within lto1 (and failing). Filter out any "-flto" in testcpybuilder.BuiltModule + python3 testcpychecker.py -v ====================================================================== ERROR: test_correct_usage (__main__.PyArg_ParseTupleAndKeywordsTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "testcpychecker.py", line 223, in test_correct_usage self.assertNoErrors(src) File "testcpychecker.py", line 88, in assertNoErrors self.build_module(bm) File "testcpychecker.py", line 79, in build_module self.compile_src(bm) File "testcpychecker.py", line 75, in compile_src bm.compile_src(extra_cflags) File "/builddir/build/BUILD/gcc-python-plugin-0.16/building-for-python3/testcpybuilder.py", line 98, in compile_src raise CompilationError(self) testcpybuilder.CompilationError: returncode: 1 compiling: gcc -o /tmp/tmpo4qiynz3/example.cpython-37m-x86_64-linux-gnu.so -I/usr/include/python3.7m -I/usr/include/python3.7m -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -flto -fuse-linker-plugin -ffat-lto-objects -flto-partition=none -Wall -Werror -fPIC -shared -fplugin=/builddir/build/BUILD/gcc-python-plugin-0.16/building-for-python3/python3.so -fplugin-arg-python3-script=cpychecker.py -fno-diagnostics-show-caret /tmp/tmpo4qiynz3/example.c Stdout: Stderr: <built-in>: error: Unhandled Python exception raised within callback Traceback (most recent call last): File "/builddir/build/BUILD/gcc-python-plugin-0.16/building-for-python3/libcpychecker/attributes.py", line 54, in register_our_attributes gcc.define_macro('WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE') ValueError: gcc.define_macro("WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE") called without a compilation unit lto1: fatal error: errors during merging of translation units compilation terminated. lto-wrapper: fatal error: gcc returned 1 exit status compilation terminated. /usr/bin/ld: error: lto-wrapper failed collect2: error: ld returned 1 exit status
1 parent c22d408 commit ef78bdc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

testcpybuilder.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,13 @@ def compile_src(self, extra_cflags = None):
7373
self.args += ['-o', self.modfile]
7474
self.args += ['-I' + sc.get_python_inc(),
7575
'-I' + sc.get_python_inc(plat_specific=True)]
76-
self.args += sc.get_config_var('CFLAGS').split()
76+
77+
# Get CFLAGS from sysconfig
78+
cflags = sc.get_config_var('CFLAGS').split()
79+
# Filter out LTO
80+
cflags = filter(lambda flag: flag != '-flto', cflags)
81+
self.args += cflags
82+
7783
self.args += ['-Wall', '-Werror'] # during testing
7884
# on some builds of Python, CFLAGS does not contain -fPIC, but it
7985
# appears to still be necessary:

0 commit comments

Comments
 (0)