mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
gh-105776: Fix test_cppext when CC contains -std=c11 option (#108343)
Fix test_cppext when the C compiler command has the "-std=c11" option.
Remove "-std=" options from the compiler command.
(cherry picked from commit 9173b2bbe1
)
This commit is contained in:
parent
a15396146f
commit
1aff195903
2 changed files with 15 additions and 0 deletions
|
@ -1,7 +1,9 @@
|
||||||
# gh-91321: Build a basic C++ test extension to check that the Python C API is
|
# gh-91321: Build a basic C++ test extension to check that the Python C API is
|
||||||
# compatible with C++ and does not emit C++ compiler warnings.
|
# compatible with C++ and does not emit C++ compiler warnings.
|
||||||
import os.path
|
import os.path
|
||||||
|
import shlex
|
||||||
import sys
|
import sys
|
||||||
|
import sysconfig
|
||||||
|
|
||||||
from setuptools import setup, Extension
|
from setuptools import setup, Extension
|
||||||
|
|
||||||
|
@ -36,6 +38,17 @@ def main():
|
||||||
|
|
||||||
cppflags = [*CPPFLAGS, f'-std={std}']
|
cppflags = [*CPPFLAGS, f'-std={std}']
|
||||||
|
|
||||||
|
# gh-105776: When "gcc -std=11" is used as the C++ compiler, -std=c11
|
||||||
|
# option emits a C++ compiler warning. Remove "-std11" option from the
|
||||||
|
# CC command.
|
||||||
|
cmd = (sysconfig.get_config_var('CC') or '')
|
||||||
|
if cmd is not None:
|
||||||
|
cmd = shlex.split(cmd)
|
||||||
|
cmd = [arg for arg in cmd if not arg.startswith('-std=')]
|
||||||
|
cmd = shlex.join(cmd)
|
||||||
|
# CC env var overrides sysconfig CC variable in setuptools
|
||||||
|
os.environ['CC'] = cmd
|
||||||
|
|
||||||
cpp_ext = Extension(
|
cpp_ext = Extension(
|
||||||
name,
|
name,
|
||||||
sources=[SOURCE],
|
sources=[SOURCE],
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix test_cppext when the C compiler command ``-std=c11`` option: remove
|
||||||
|
``-std=`` options from the compiler command. Patch by Victor Stinner.
|
Loading…
Add table
Add a link
Reference in a new issue