Repository navigation
fix: resolve relative __FILE__ against the compiler's directory - #58
Merged
Merged
Conversation
Hooray! CodSpeed harness just leveled up!The base and head of this comparison were measured with different runner settings, so their benchmark values are not directly comparable. What changed between base and head:
Re-run the base with the same settings to get a valid performance comparison. Comparing |
lvaroqui
force-pushed
the
fix/resolve-relative-file-against-compile-dir
branch
2 times, most recently
from
November 26, 2026 10:28
0993a15 to
d848843
Compare
lvaroqui
marked this pull request as ready for review
November 26, 2026 10:29
[Medium impact] The PR appears safe to merge; no new actionable issue was established. SummaryThe PR passes the compiler’s working directory into benchmark path resolution so ccache-relative
|
With ccache and `base_dir` set, `__FILE__` is relative to the directory the compiler ran in. `get_path_relative_to_workspace` resolved it against the directory the benchmark runs in instead, so benchmark URIs started with `../../../` and pointed outside the repository. CMake now gives every target that links codspeed a `CODSPEED_COMPILE_DIR` definition: the top build directory with Ninja, the target's build directory with other generators. `CUR_FILE` passes it to `get_path_relative_to_workspace`, which joins it to a relative path before making it relative to the workspace. It only does so when the file exists there. `-fmacro-prefix-map=<root>/=` also makes `__FILE__` relative, but to the repository root, and joining it to the compile directory would break URIs that are correct today. The check uses the lexically normalized path, so it still works when the build directory was deleted after the build. Otherwise, and for absolute paths, Bazel builds and build systems that don't set the definition, the behavior is unchanged. Benchmark URIs of projects built with ccache `base_dir` change, so their history restarts. Refs COD-4223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The installed `benchmarkTargets.cmake` stored the compile directory of the build that compiled codspeed: an absolute path with Ninja, or a generator expression that is only right for Makefile consumers. A project using the installed package now gets no compile directory, so its URIs are computed as before this change. Refs COD-4223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both macOS jobs pinned the runner to `branch:main`. The action installs a branch by sourcing `~/.cargo/env`, which does not exist on `macos-latest`, so the jobs failed before running any benchmark. The released runner now supports macOS (v5.8.0 ships an `aarch64-apple-darwin` build), so drop the pin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lvaroqui
force-pushed
the
fix/resolve-relative-file-against-compile-dir
branch
from
November 26, 2026 11:12
d848843 to
35818bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves a relative
__FILE__against the directory the compiler ran in, so benchmark URIs stay inside the repository when ccache rewrites paths.With ccache and
base_dir(CCACHE_BASEDIR) set, ccache rewrites the absolute source path CMake passes to the compiler into a path relative to the compiler's working directory.get_path_relative_to_workspacethen resolved that relative path against the directory the benchmark runs in, so URIs became../../../tests/benchmarks/bench.cpp::…. The number of..also depended on how deep the checkout is.core/CMakeLists.txtadds anINTERFACEdefinitionCODSPEED_COMPILE_DIRto every target that linkscodspeed:CMAKE_BINARY_DIRwith Ninja (which compiles everything from the top build directory), the consuming target'sBINARY_DIRotherwise (Makefiles compile from each target's build directory).CUR_FILE(benchmark.h) passes it toget_path_relative_to_workspace, which joins it to a relative path before making it relative to the workspace root.get_path_relative_to_workspaceuses the compile directory only when the file exists there. Otherwise it keeps the previous behavior. This matters for-fmacro-prefix-map=<root>/=, which also makes__FILE__relative, but to the repository root.$<BUILD_INTERFACE:…>, so the installed package doesn't carry the compile directory of the build that compiled codspeed.__FILE__,-fmacro-prefix-map, Bazel, installed packages, and build systems that don't set the definition behave as before.Reproduced in Docker (checkout at
/home/runner/work/repro/repro, benchmark attests/benchmarks/bench.cpp, ccache 4.12.3):__FILE__../../../tests/benchmarks/bench.cpp../../../tests/benchmarks/bench.cpp::BM_sum../tests/benchmarks/bench.cpp../tests/benchmarks/bench.cpp::BM_sum../../../tests/benchmarks/bench.cpptests/benchmarks/bench.cpp::BM_sum../tests/benchmarks/bench.cpptests/benchmarks/bench.cpp::BM_sumAccepted gaps
BINARY_DIRbranch.base_dirchange, so their benchmark history restarts.base_dirstill get../URIs: the package can't know their compile directory.Refs COD-4223 (the issue also covers fixes in other integrations and the platform, so it stays open)