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

Python 3.11.4: Running "make test" fails under gcc 4.8.5 because both -std=gnu11 and -std=c++11 are specified when compiling _testcpp11ext #105776

Closed
gtzampanakis opened this issue Jun 14, 2023 · 4 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@gtzampanakis
Copy link

gtzampanakis commented Jun 14, 2023

In Python 3.11.4, running "make test" fails under gcc 4.8.5 because both -std=gnu11 and -std=c++11 are specified when compiling _testcpp11ext.

Run the following:

./configure
make
make test EXTRATESTOPTS=test_cppext

Output:

0:00:12 load avg: 0.92 [1/1/1] test_cppext failed (2 failures)
test test_cppext failed -- multiple errors occurred; run in verbose mode for details
running build_ext
building '_testcpp03ext' extension
creating build
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/home
creating build/temp.linux-x86_64-cpython-311/home/httpd
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test
gcc -std=gnu11 -pthread -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/home/httpd/wgvd-net/delme/Python-3.11.4/build/test_python_130531æ/test_python_worker_130534æ/tempcwd/env/include -I/home/httpd/wgvd-net/delme/Python-3.11.4/Include -I/home/httpd/wgvd-net/delme/Python-3.11.4 -c /home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/_testcppext.cpp -o build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/_testcppext.o -Werror -std=c++03
cc1plus: error: command line option ‘-std=gnu11’ is valid for C/ObjC but not for C++ [-Werror]
cc1plus: all warnings being treated as errors
error: command '/usr/bin/gcc' failed with exit code 1
running build_ext
building '_testcpp11ext' extension
creating build
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/home
creating build/temp.linux-x86_64-cpython-311/home/httpd
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test
gcc -std=gnu11 -pthread -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/home/httpd/wgvd-net/delme/Python-3.11.4/build/test_python_130531æ/test_python_worker_130534æ/tempcwd/env/include -I/home/httpd/wgvd-net/delme/Python-3.11.4/Include -I/home/httpd/wgvd-net/delme/Python-3.11.4 -c /home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/_testcppext.cpp -o build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/_testcppext.o -Werror -std=c++11
cc1plus: error: command line option ‘-std=gnu11’ is valid for C/ObjC but not for C++ [-Werror]
cc1plus: all warnings being treated as errors
error: command '/usr/bin/gcc' failed with exit code 1

== Tests result: FAILURE ==

1 test failed:
    test_cppext
0:00:12 load avg: 0.92
0:00:12 load avg: 0.92 Re-running failed tests in verbose mode
0:00:12 load avg: 0.92 Re-running test_cppext in verbose mode (matching: test_build_cpp03, test_build_cpp11)
test_build_cpp03 (test.test_cppext.TestCPPExt.test_build_cpp03) ...
Run: /home/httpd/wgvd-net/delme/Python-3.11.4/python -X dev -m venv env
Run: env/bin/python -X dev /home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/setup_testcppext.py build_ext --verbose -std=c++03
running build_ext
building '_testcpp03ext' extension
creating build
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/home
creating build/temp.linux-x86_64-cpython-311/home/httpd
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test
gcc -std=gnu11 -pthread -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/home/httpd/wgvd-net/delme/Python-3.11.4/build/test_python_130531æ/tempcwd/env/include -I/home/httpd/wgvd-net/delme/Python-3.11.4/Include -I/home/httpd/wgvd-net/delme/Python-3.11.4 -c /home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/_testcppext.cpp -o build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/_testcppext.o -Werror -std=c++03
cc1plus: error: command line option ‘-std=gnu11’ is valid for C/ObjC but not for C++ [-Werror]
cc1plus: all warnings being treated as errors
error: command '/usr/bin/gcc' failed with exit code 1
ERROR
test_build_cpp11 (test.test_cppext.TestCPPExt.test_build_cpp11) ...
Run: /home/httpd/wgvd-net/delme/Python-3.11.4/python -X dev -m venv env
Run: env/bin/python -X dev /home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/setup_testcppext.py build_ext --verbose
running build_ext
building '_testcpp11ext' extension
creating build
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/home
creating build/temp.linux-x86_64-cpython-311/home/httpd
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib
creating build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test
gcc -std=gnu11 -pthread -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/home/httpd/wgvd-net/delme/Python-3.11.4/build/test_python_130531æ/tempcwd/env/include -I/home/httpd/wgvd-net/delme/Python-3.11.4/Include -I/home/httpd/wgvd-net/delme/Python-3.11.4 -c /home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/_testcppext.cpp -o build/temp.linux-x86_64-cpython-311/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/_testcppext.o -Werror -std=c++11
cc1plus: error: command line option ‘-std=gnu11’ is valid for C/ObjC but not for C++ [-Werror]
cc1plus: all warnings being treated as errors
error: command '/usr/bin/gcc' failed with exit code 1
ERROR

======================================================================
ERROR: test_build_cpp03 (test.test_cppext.TestCPPExt.test_build_cpp03)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/test_cppext.py", line 24, in test_build_cpp03
    self.check_build(True, '_testcpp03ext')
  File "/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/test_cppext.py", line 39, in check_build
    self._check_build(std_cpp03, extension_name)
  File "/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/test_cppext.py", line 80, in _check_build
    run_cmd('Build', cmd)
  File "/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/test_cppext.py", line 64, in run_cmd
    subprocess.run(cmd, check=True)
  File "/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['env/bin/python', '-X', 'dev', '/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/setup_testcppext.py', 'build_ext', '--verbose', '-std=c++03']' returned non-zero exit status 1.

======================================================================
ERROR: test_build_cpp11 (test.test_cppext.TestCPPExt.test_build_cpp11)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/test_cppext.py", line 21, in test_build_cpp11
    self.check_build(False, '_testcpp11ext')
  File "/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/test_cppext.py", line 39, in check_build
    self._check_build(std_cpp03, extension_name)
  File "/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/test_cppext.py", line 80, in _check_build
    run_cmd('Build', cmd)
  File "/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/test_cppext.py", line 64, in run_cmd
    subprocess.run(cmd, check=True)
  File "/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['env/bin/python', '-X', 'dev', '/home/httpd/wgvd-net/delme/Python-3.11.4/Lib/test/setup_testcppext.py', 'build_ext', '--verbose']' returned non-zero exit status 1.

----------------------------------------------------------------------

Your environment

Python 3.11.4
CentOS Linux release 7.9.2009 (Core)
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)

Linked PRs

@vstinner
Copy link
Member

I closed issue #107084 as a duplicate of this one.

@vstinner
Copy link
Member

vstinner commented Aug 23, 2023

s390x RHEL7 buildbots are affected by the same issue. Example on the main branch when running test_cppext: https://buildbot.python.org/all/#/builders/179/builds/5253

cc1plus: error: command line option ‘-std=gnu11’ is valid for C/ObjC but not for C++ [-Werror]

AMD64 RHEL7 3.x and PPC64LE RHEL7 3.x buildbots are not affected.

AMD64 RHEL7 3.x (ok): test.pythoninfo

CC.version: gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)

sysconfig[CCSHARED]: -fPIC
sysconfig[CC]: gcc -pthread
sysconfig[CFLAGS]: -fno-strict-overflow -Wsign-compare -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -Og -Wall
sysconfig[CONFIG_ARGS]: '--prefix' '/home/buildbot/buildarea/3.x.cstratak-RHEL7-x86_64/build/build_oot/target' '--with-pydebug' '--with-platlibdir=lib64' '--enable-ipv6' '--enable-shared' '--with-computed-gotos=yes' '--with-dbmliborder=gdbm:ndbm:bdb' '--enable-loadable-sqlite-extensions' '--with-ssl-default-suites=openssl' '--without-static-libpython'

sysconfig[OPT]: -g -Og -Wall

sysconfig[PY_CFLAGS]: -fno-strict-overflow -Wsign-compare -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -Og -Wall
sysconfig[PY_CFLAGS_NODIST]: -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I../Include/internal
sysconfig[PY_STDMODULE_CFLAGS]: -fno-strict-overflow -Wsign-compare -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -Og -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I../Include/internal -IObjects -IInclude -IPython -I. -I../Include -fPIC

PPC64LE RHEL7: test.pythoninfo

CC.version: gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)

sysconfig[CC]: gcc -pthread
sysconfig[CFLAGSFORSHARED]: -fPIC
sysconfig[CFLAGS]: -fno-strict-overflow -Wsign-compare -g -Og -Wall
sysconfig[CONFIG_ARGS]: '--prefix' '/home/buildbot/buildarea/3.x.cstratak-RHEL7-ppc64le/build/build_oot/target' '--with-pydebug' '--with-platlibdir=lib64' '--enable-ipv6' '--enable-shared' '--with-computed-gotos=yes' '--with-dbmliborder=gdbm:ndbm:bdb' '--enable-loadable-sqlite-extensions' '--with-ssl-default-suites=openssl' '--without-static-libpython'

sysconfig[OPT]: -g -Og -Wall

sysconfig[PY_CFLAGS]: -fno-strict-overflow -Wsign-compare -g -Og -Wall
sysconfig[PY_CFLAGS_NODIST]: -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I../Include/internal
sysconfig[PY_STDMODULE_CFLAGS]: -fno-strict-overflow -Wsign-compare -g -Og -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I../Include/internal -IObjects -IInclude -IPython -I. -I../Include -fPIC

s390x: test.pythoninfo

CC.version: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)

sysconfig[CCSHARED]: -fPIC
sysconfig[CC]: gcc -std=gnu11 -pthread
sysconfig[CFLAGS]: -fno-strict-overflow -Wsign-compare -g -Og -Wall
sysconfig[CONFIG_ARGS]: '--prefix' '/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/target' '--with-pydebug'

sysconfig[OPT]: -g -Og -Wall

sysconfig[PY_CFLAGS]: -fno-strict-overflow -Wsign-compare -g -Og -Wall
sysconfig[PY_CFLAGS_NODIST]: -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal
sysconfig[PY_STDMODULE_CFLAGS]: -fno-strict-overflow -Wsign-compare -g -Og -Wall -std=c11 -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hidden -I./Include/internal -I. -I./Include

Oh, AMD64 and PPC64LE use 8.3.1, whereas s390x use GCC 4.8.5.

The -std=c11 option is present in PY_CFLAGS_NODIST, but not in PY_CFLAGS.

@vstinner
Copy link
Member

Ok, the problem is not really the GCC version (4.8.5), but how GCC is called:

sysconfig[CC]: gcc -std=gnu11 -pthread

Python uses gcc -std=gnu11 -pthread. test_cppext uses it as the C++ compiler and uses -Werror to treat compiler warnings as errors. But passing -std=c11 option when building C++ code fails with an error:

$ cat x.cpp 
int main() {}

$ gcc -std=c11 x.cpp -o x -Werror
cc1plus: error: command-line option '-std=c11' is valid for C/ObjC but not for C++ [-Werror]
cc1plus: all warnings being treated as errors

vstinner added a commit to vstinner/cpython that referenced this issue Aug 23, 2023
vstinner added a commit to vstinner/cpython that referenced this issue Aug 23, 2023
vstinner added a commit to vstinner/cpython that referenced this issue Aug 23, 2023
Fix test_cppext when the C compiler command "-std=c11" option: remove
"-std=" options from the compiler command.
vstinner added a commit that referenced this issue Aug 23, 2023
Fix test_cppext when the C compiler command has the "-std=c11" option.
Remove "-std=" options from the compiler command.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Aug 23, 2023
…thonGH-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 9173b2b)

Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit to vstinner/cpython that referenced this issue Aug 23, 2023
…thon#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 9173b2b)
vstinner added a commit that referenced this issue Aug 23, 2023
…108343) (#108347)

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 9173b2b)
Yhg1s pushed a commit that referenced this issue Aug 23, 2023
…H-108343) (#108345)

gh-105776: Fix test_cppext when CC contains -std=c11 option (GH-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 9173b2b)

Co-authored-by: Victor Stinner <vstinner@python.org>
@hugovk
Copy link
Member

hugovk commented Nov 10, 2023

Looks like everything is done here? Thanks @gtzampanakis and @vstinner for the issue and PRs!

@hugovk hugovk closed this as completed Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants