Skip to content

Commit 056b605

Browse files
committed
gh-116869: Fix test_cext on RHEL7
Remove -std option from CC command line.
1 parent f55e188 commit 056b605

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

Lib/test/test_cext/setup.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,22 @@ def main():
3939
if std:
4040
if support.MS_WINDOWS:
4141
cflags.append(f'/std:{std}')
42-
std_prefix = '/std'
4342
else:
4443
cflags.append(f'-std={std}')
45-
std_prefix = '-std'
4644

47-
# Remove existing -std options to only test ours
48-
cmd = (sysconfig.get_config_var('CC') or '')
49-
if cmd is not None:
50-
cmd = shlex.split(cmd)
51-
cmd = [arg for arg in cmd if not arg.startswith(std_prefix)]
52-
cmd = shlex.join(cmd)
53-
# CC env var overrides sysconfig CC variable in setuptools
54-
os.environ['CC'] = cmd
45+
# Remove existing -std or /std options from CC command line.
46+
# Python adds -std=c11 option.
47+
cmd = (sysconfig.get_config_var('CC') or '')
48+
if cmd is not None:
49+
if support.MS_WINDOWS:
50+
std_prefix = '/std'
51+
else:
52+
std_prefix = '-std'
53+
cmd = shlex.split(cmd)
54+
cmd = [arg for arg in cmd if not arg.startswith(std_prefix)]
55+
cmd = shlex.join(cmd)
56+
# CC env var overrides sysconfig CC variable in setuptools
57+
os.environ['CC'] = cmd
5558

5659
# Define Py_LIMITED_API macro
5760
if limited:

Lib/test/test_cppext/setup.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,23 @@ def main():
3535
if std:
3636
if support.MS_WINDOWS:
3737
cppflags.append(f'/std:{std}')
38-
std_prefix = '/std'
3938
else:
4039
cppflags.append(f'-std={std}')
41-
std_prefix = '-std'
4240

43-
# Remove existing -std options to only test ours
44-
cmd = (sysconfig.get_config_var('CC') or '')
45-
if cmd is not None:
46-
cmd = shlex.split(cmd)
47-
cmd = [arg for arg in cmd if not arg.startswith(std_prefix)]
48-
cmd = shlex.join(cmd)
49-
# CC env var overrides sysconfig CC variable in setuptools
50-
os.environ['CC'] = cmd
41+
# gh-105776: When "gcc -std=11" is used as the C++ compiler, -std=c11
42+
# option emits a C++ compiler warning. Remove "-std11" option from the
43+
# CC command.
44+
cmd = (sysconfig.get_config_var('CC') or '')
45+
if cmd is not None:
46+
if support.MS_WINDOWS:
47+
std_prefix = '/std'
48+
else:
49+
std_prefix = '-std'
50+
cmd = shlex.split(cmd)
51+
cmd = [arg for arg in cmd if not arg.startswith(std_prefix)]
52+
cmd = shlex.join(cmd)
53+
# CC env var overrides sysconfig CC variable in setuptools
54+
os.environ['CC'] = cmd
5155

5256
# On Windows, add PCbuild\amd64\ to include and library directories
5357
include_dirs = []

0 commit comments

Comments
 (0)