TestExternal.test_c_unit_test fails on FreeBSD
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
On FreeBSD where clang is the default compiler, one test from mypy testsuite fails: TestExternal.test_c_unit_test, because -std=c++11 flag is set for both C and CXX compilers, but it only applies to C++, and clang refuses to compile C code with it.
=================================== FAILURES ===================================
________________________ TestExternal.test_c_unit_test _________________________
self = <mypyc.test.test_external.TestExternal testMethod=test_c_unit_test>
@unittest.skipIf(sys.platform.startswith("win"), "rt tests don't work on windows")
def test_c_unit_test(self) -> None:
"""Run C unit tests in a subprocess."""
# Build Google Test, the C++ framework we use for testing C code.
# The source code for Google Test is copied to this repository.
cppflags: List[str] = []
env = os.environ.copy()
if sys.platform == 'darwin':
cppflags += ['-mmacosx-version-min=10.10', '-stdlib=libc++']
env['CPPFLAGS'] = ' '.join(cppflags)
subprocess.check_call(
['make', 'libgtest.a'],
env=env,
cwd=os.path.join(base_dir, 'mypyc', 'external', 'googletest', 'make'))
# Build Python wrapper for C unit tests.
env = os.environ.copy()
env['CPPFLAGS'] = ' '.join(cppflags)
> status = subprocess.check_call(
[sys.executable, 'setup.py', 'build_ext', '--inplace'],
env=env,
cwd=os.path.join(base_dir, 'mypyc', 'lib-rt'))
mypyc/test/test_external.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
popenargs = (['/usr/local/bin/python3.8', 'setup.py', 'build_ext', '--inplace'],)
kwargs = {'cwd': '/work/usr/ports/devel/py-mypy/work-py38/mypy-0.940/mypyc/test/../../mypyc/lib-rt', 'env': {'ARCH': 'amd64', 'BATCH': '1', 'BLOCKSIZE': 'K', 'BSD_INSTALL_DATA': 'install -m 0644', ...}}
retcode = 1
cmd = ['/usr/local/bin/python3.8', 'setup.py', 'build_ext', '--inplace']
def check_call(*popenargs, **kwargs):
"""Run command with arguments. Wait for command to complete. If
the exit code was zero then return, otherwise raise
CalledProcessError. The CalledProcessError object will have the
return code in the returncode attribute.
The arguments are the same as for the call function. Example:
check_call(["ls", "-l"])
"""
retcode = call(*popenargs, **kwargs)
if retcode:
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs[0]
> raise CalledProcessError(retcode, cmd)
E subprocess.CalledProcessError: Command '['/usr/local/bin/python3.8', 'setup.py', 'build_ext', '--inplace']' returned non-zero exit status 1.
/usr/local/lib/python3.8/subprocess.py:364: CalledProcessError
----------------------------- Captured stdout call -----------------------------
c++ -isystem ../include -I.. -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -g -Wall -Wextra -pthread -fPIC -c ../src/gtest-all.cc
ar -crsD libgtest.a
running build_ext
building 'test_capi' extension
creating build
creating build/temp.freebsd-13.0-RELEASE-amd64-3.8
cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -I../external/googletest -I../external/googletest/include -I/usr/local/include/python3.8 -c test_capi.cc -o build/temp.freebsd-13.0-RELEASE-amd64-3.8/test_capi.o -Wno-unused-function -Wno-sign-compare --std=c++11
cc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -I../external/googletest -I../external/googletest/include -I/usr/local/include/python3.8 -c init.c -o build/temp.freebsd-13.0-RELEASE-amd64-3.8/init.o -Wno-unused-function -Wno-sign-compare --std=c++11
----------------------------- Captured stderr call -----------------------------
error: invalid argument '--std=c++11' not allowed with 'C'
error: command 'cc' failed with exit status 1
Full log: https://gist.github.com/7b5fb7d6e43d83e9ccdacf34cddc2dec
To Reproduce
Run tests when clang compiler.
Expected Behavior
Tests pass
Actual Behavior
Tests fail
Your Environment
- Mypy version used: 0.940
- Python version used: 3.8
- Operating system and version: FreeBSD 13.0 amd64, clang 11.0.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with mypyc/test/test_external.py and the setup.py build_ext invocation in mypyc/lib-rt; reproduce TestExternal.test_c_unit_test on FreeBSD and inspect the compiler arguments shown in the failure. Done means the test suite builds the C and C++ sources successfully with clang and TestExternal.test_c_unit_test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, python
- Domain
- build-system, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 66/100