Skip to content
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
56 changes: 55 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
contents: read
outputs:
wheels: ${{ steps.plan.outputs.wheels }}
extras: ${{ steps.plan.outputs.extras }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand Down Expand Up @@ -172,12 +173,65 @@ jobs:
msvc: ${{ matrix.msvc }}
release-files-command: ${{ matrix.release-files-command }}

# A package's [tool.wheels] extra-tests: build one version's wheel for the
# runner's platform and run the smoke test with more arguments, after a
# setup, e.g. llvm-cov with the clang of the same major version.
extra:
name: ${{ matrix.package }} / ${{ matrix.name }}
needs: plan
if: needs.plan.outputs.extras != '[]'
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(needs.plan.outputs.extras) }}
runs-on: ${{ matrix.os }}
permissions:
contents: read
defaults:
run:
shell: bash
working-directory: ${{ matrix.directory }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # hatch-prebuilt takes its version from the tags
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.x"
- name: Set up
if: matrix.setup
env:
SETUP: ${{ matrix.setup }}
run: bash -euo pipefail -c "$SETUP"
- name: Build the wheel with hatch-prebuilt from this commit
env:
VERSION: ${{ matrix.version }}
run: |
python -m pip install "$GITHUB_WORKSPACE/packages/hatch-prebuilt" build
variable=$(python -m hatch_prebuilt info | python -c "import json, sys; print(json.load(sys.stdin).get('version-variable', ''))")
if [ -n "$VERSION" ] && [ -n "$variable" ]; then
export "$variable=$VERSION"
fi
python -m build --wheel --outdir dist --no-isolation --skip-dependency-check
- name: Install it and run the smoke test
env:
VERSION: ${{ matrix.version }}
ARGS: ${{ matrix.args }}
run: |
python -m venv .venv
if [ "$RUNNER_OS" = Windows ]; then bin=.venv/Scripts; else bin=.venv/bin; fi
version=${VERSION:-$(python -m hatch_prebuilt info | python -c "import json, sys; print(open(json.load(sys.stdin)['version-file']).read().strip())")}
"$bin/python" -m pip install --no-index --find-links dist "$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['name'])")==$version"
# shellcheck disable=SC2086 # ARGS holds several arguments
PATH="$PWD/$bin:$PATH" "$bin/python" tests/smoke_test.py --version "$version" $ARGS

# One check for the branch rules to require: it fails unless every job
# above passed or had nothing to do, whatever the jobs are called.
all:
name: All wheels pass
if: always()
needs: [plan, hatch-prebuilt, scripts, new-package, wheels]
needs: [plan, hatch-prebuilt, scripts, new-package, wheels, extra]
runs-on: ubuntu-latest
permissions: {}
steps:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ clangd --version
| Package | Tools | |
| --- | --- | --- |
| [clangd-bin](packages/clangd-bin) | clangd | [![PyPI](https://img.shields.io/pypi/v/clangd-bin?label=&labelColor=454a63&color=007ec6)](https://pypi.org/project/clangd-bin/) |
| [llvm-cov](packages/llvm-cov) | llvm-cov, llvm-profdata | [![PyPI](https://img.shields.io/pypi/v/llvm-cov?label=&labelColor=454a63&color=007ec6)](https://pypi.org/project/llvm-cov/) |

**Build tooling**:

Expand All @@ -27,7 +28,6 @@ clangd --version
| [hatch-prebuilt](packages/hatch-prebuilt) | The hatchling plugin that builds every wheel here from prebuilt binaries | [![PyPI](https://img.shields.io/pypi/v/hatch-prebuilt?label=&labelColor=454a63&color=007ec6)](https://pypi.org/project/hatch-prebuilt/) |

Moving here from their own repositories:
[llvm-cov](https://github.com/cpp-linter/llvm-cov-wheel),
[clang-include-cleaner](https://github.com/cpp-linter/clang-include-cleaner-wheel),
[clang-apply-replacements](https://github.com/cpp-linter/clang-apply-replacements-wheel),
[ccache-bin](https://github.com/cpp-linter/ccache-wheel) and
Expand Down
21 changes: 21 additions & 0 deletions packages/llvm-cov/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 cpp-linter

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
96 changes: 96 additions & 0 deletions packages/llvm-cov/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# llvm-cov

[![PyPI](https://img.shields.io/pypi/v/llvm-cov?labelColor=454a63&color=007ec6)](https://pypi.org/project/llvm-cov/)
[![ci](https://img.shields.io/github/actions/workflow/status/cpp-linter/wheels/ci.yml?branch=main&label=ci&labelColor=454a63)](https://github.com/cpp-linter/wheels/actions/workflows/ci.yml)
[![part of cpp-linter](https://img.shields.io/badge/part%20of-cpp--linter-ffc20a?labelColor=454a63)](https://cpp-linter.github.io/)

LLVM's code coverage tools, [`llvm-cov`](https://llvm.org/docs/CommandGuide/llvm-cov.html) and
[`llvm-profdata`](https://llvm.org/docs/CommandGuide/llvm-profdata.html), as Python wheels on
PyPI. One `pip install` gives you both commands, for any LLVM version from 12 to 23, on Linux,
macOS and Windows, x86_64 and arm64.

[Website](https://cpp-linter.github.io/) ·
[PyPI](https://pypi.org/project/llvm-cov/) ·
[Source-based coverage guide](https://clang.llvm.org/docs/SourceBasedCodeCoverage.html) ·
[Discussions](https://github.com/orgs/cpp-linter/discussions)

## Quick start

```bash
pip install llvm-cov # or: uv tool install llvm-cov
llvm-cov --version
llvm-profdata --version
```

Pick the version that matches your compiler. The raw profiles that `clang` writes change format
between LLVM releases, so `llvm-profdata` should come from the same major version as `clang`:

```bash
pip install "llvm-cov==18.*" # for clang 18
```

## Usage

Source-based coverage with clang:

```bash
clang++ -fprofile-instr-generate -fcoverage-mapping -o app main.cpp
LLVM_PROFILE_FILE=app.profraw ./app
llvm-profdata merge -sparse app.profraw -o app.profdata
llvm-cov report ./app -instr-profile=app.profdata
llvm-cov export ./app -instr-profile=app.profdata -format=lcov > coverage.lcov
```

With [gcovr](https://gcovr.com) and `--coverage` builds:

```bash
pip install gcovr llvm-cov
gcovr --gcov-executable "llvm-cov gcov"
```

`llvm-cov` and `llvm-profdata` are installed straight into the environment's `bin/` (`Scripts\`
on Windows), with no Python wrapper in between.

## Supported platforms

| Platform | Architecture | Wheel tag |
|----------|-------------|-----------|
| **Linux** (glibc 2.17+ and musl) | x86_64 | `manylinux_2_17_x86_64.manylinux2014_x86_64.musllinux_1_1_x86_64` |
| **Linux** (glibc 2.17+ and musl) | aarch64 | `manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64` |
| **macOS** 15+ | Intel (x86_64) | `macosx_15_0_x86_64` |
| **macOS** 11+ | Apple Silicon (arm64) | `macosx_11_0_arm64` |
| **Windows** | x86_64 | `win_amd64` |
| **Windows** | ARM64 | `win_arm64` |

The Linux binaries are fully static, so one wheel works on both glibc and musl distributions.
The macOS tags carry the minimum macOS version that the binaries declare.

The wheel version is the LLVM version, for example `23.1.6`. A packaging-only fix is released as
`23.1.6.1`.

## Where the binaries come from

The wheels contain the `llvm-cov` and `llvm-profdata` binaries of the
[clang-tools-static-binaries](https://github.com/cpp-linter/clang-tools-static-binaries) releases,
unchanged. Those are built from the official LLVM source releases, with build provenance
attestations. `sources.json` pins the SHA-512 of every file, and the build refuses any download
that does not match.

This is not an official LLVM project, so report problems with the tools themselves
[upstream](https://github.com/llvm/llvm-project/issues).

## Contributing

This package lives in [cpp-linter/wheels](https://github.com/cpp-linter/wheels), with the other
C and C++ tools that cpp-linter packages as wheels.
[Open an issue](https://github.com/cpp-linter/wheels/issues) for packaging bugs and feature
requests, and see the [contributing guide](https://github.com/cpp-linter/wheels/blob/main/CONTRIBUTING.md)
for how the wheels are built and released: a bot releases every new LLVM version on its own.

## License

The files in this directory are released under the
[MIT License](https://github.com/cpp-linter/wheels/blob/main/packages/llvm-cov/LICENSE). LLVM, and so the
wheels, are under the
[Apache License 2.0 with LLVM Exceptions](https://llvm.org/LICENSE.txt); the wheels carry its
license file.
1 change: 1 addition & 0 deletions packages/llvm-cov/llvm_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
23.1.6
67 changes: 67 additions & 0 deletions packages/llvm-cov/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[build-system]
requires = ["hatchling>=1.27", "hatch-prebuilt>=0.3,<1"]
build-backend = "hatchling.build"

[project]
name = "llvm-cov"
description = "llvm-cov and llvm-profdata, LLVM's code coverage tools, packaged as Python wheels"
readme = "README.md"
license = "Apache-2.0 WITH LLVM-exception"
# Staged from the static binaries release by hatch-prebuilt during the build.
license-files = ["upstream/LICENSE.TXT"]
authors = [{ name = "The LLVM project" }]
maintainers = [{ name = "Xianpeng Shen", email = "xianpeng.shen@gmail.com" }]
keywords = ["llvm", "llvm-cov", "llvm-profdata", "coverage", "clang", "c", "c++"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: C",
"Programming Language :: C++",
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
]
# The version is the LLVM version, from llvm_version.txt (or LLVM_VERSION).
dynamic = ["version"]

[project.urls]
Documentation = "https://llvm.org/docs/CommandGuide/llvm-cov.html"
"Source-based coverage" = "https://clang.llvm.org/docs/SourceBasedCodeCoverage.html"
Binaries = "https://github.com/cpp-linter/clang-tools-static-binaries"
Source = "https://github.com/cpp-linter/wheels/tree/main/packages/llvm-cov"
Issues = "https://github.com/cpp-linter/wheels/issues"

[dependency-groups]
build = ["build", "hatch-prebuilt>=0.3,<1"]
dev = [{ include-group = "build" }, "pre-commit"]

# hatch-prebuilt sets the version, downloads the binaries and checks them
# against sources.json (metadata hook), then puts them into the wheel (build
# hook). `python -m hatch_prebuilt update` pins new releases.
[tool.hatch.metadata.hooks.prebuilt]
recipe = "static-binaries"
tools = ["llvm-cov", "llvm-profdata"]

[tool.hatch.build.targets.wheel]
# Only the files added by the build hook, plus the license file.
bypass-selection = true
core-metadata-version = "2.4"

[tool.hatch.build.targets.wheel.hooks.prebuilt]

# How this repository's CI builds, tests and releases the package; see
# scripts/_packages.py. The defaults fit a tool from the static binaries.
[tool.wheels]
moved-from = "cpp-linter/llvm-cov-wheel"

# The whole workflow with a real compiler: build with coverage, run, merge the
# raw profile, report. Raw profiles need llvm-profdata of clang's major
# version, so this tests the LLVM 18 wheel with the clang 18 of Ubuntu 24.04.
[[tool.wheels.extra-tests]]
name = "coverage with clang 18"
os = "ubuntu-24.04"
setup = "sudo apt-get install -y --no-install-recommends clang-18 libclang-rt-18-dev"
version = "18.1.8"
args = "--clang clang-18"
Loading
Loading