Skip to content

Fix C coverage #20222

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

Merged
merged 1 commit into from
May 14, 2021
Merged

Fix C coverage #20222

merged 1 commit into from
May 14, 2021

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented May 14, 2021

PR Summary

This was noticed while attempting Ubuntu 20.04 builds, but actually affects any system with new gcc. I was able to reproduce on Fedora by setting CPPFLAGS=--coverage.

The problem is that gcc will save the object file name and the time it was created, and warn about producing coverage if those differ. This is the case for our extensions, because we share some source files between them, and setuptools builds object files in the same directory.

The fix is simply to override the temporary directory while building a single extension to some path that is unique. Additionally, when generating coverage, we need to tell gcc to save absolute paths (for CI.)

You can test this by compiling with CPPFLAGS=--coverage in the environment, and then running anything. It will produce warnings from libgcov. This occurs in tests, but only test_sphinxext fails, because it captures stderr from a subprocess and treats it as an error.

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • [n/a] New features are documented, with examples if plot related.
  • [n/a] Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • [n/a] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [n/a] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

When C coverage is enabled, the path to the object file is saved. Since
we re-use source files in multiple extensions, libgcov will complain at
runtime that it is trying to save coverage for the same object file at
different timestamps (since each source is compiled again for each
extension). Thus, we need to use unique temporary build directories to
store object files for each extension.
@QuLogic QuLogic added the Build label May 14, 2021
@QuLogic QuLogic added this to the v3.5.0 milestone May 14, 2021
@QuLogic
Copy link
Member Author

QuLogic commented May 14, 2021

Hmm, I guess -fprofile-abs-path is not available in Ubuntu 18. Since that is only going to have an effect on Ubuntu 20 anyway, I'll drop that commit from here and put it in the ci one.

@jklymak jklymak merged commit 11e880d into matplotlib:master May 14, 2021
@QuLogic QuLogic deleted the fix-c-coverage branch May 14, 2021 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants