Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-105776: Fix test_cppext when CC contains -std=c11 option #108343

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Lib/test/test_cppext/setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# 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.
import os
import shlex
import sys
import sysconfig

from setuptools import setup, Extension

Expand Down Expand Up @@ -30,6 +32,17 @@ def main():

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(
name,
sources=[SOURCE],
Expand Down
Original file line number Diff line number Diff line change
@@ -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