bug(build): invalidated source package still installed after changing package definition
Summary
Changing [package.build.config] (e.g. extra-args) does not produce a package built with the new
configuration. pixi logs that it noticed the change, then installs the previously built artifact
in a few milliseconds without rebuilding:
INFO ... build_backend_metadata: found cached outputs with different build configuration, invalidating cache.
INFO ... the lock file is up-to-date
INFO ... Installed environment 'default' in 10.401751ms
✔ The default environment has been installed.pixi clean is the only way to pick up the change. The command exits 0 and reports success, so unless
you are watching the configure log there is no signal that the manifest and the installed binary
disagree.
There is a second, related mechanism: even when a rebuild is triggered by some other change,
pixi-build-cmake's build script skips the CMake configure step whenever build.ninja already
exists, so the new configure arguments are still not applied (see "Second mechanism" below).
Reproduction
CMakeLists.txt:
cmake_minimum_required(VERSION 3.20)
project(demo CXX)
option(MYFLAG "demo toggle" ON)
message(STATUS "MYFLAG: ${MYFLAG}")
add_executable(demo main.cpp)
install(TARGETS demo)main.cpp: int main() { return 0; }
pixi.toml:
[workspace]
preview = ["pixi-build"]
channels = ["https://prefix.dev/pixi-build-backends", "conda-forge"]
platforms = ["linux-64"]
[package]
name = "demo"
version = "0.1.0"
[package.build.backend]
name = "pixi-build-cmake"
version = "*"
[package.build.config]
extra-args = ["-DMYFLAG=OFF"]
[dependencies]
demo = { path = "." }| step | manifest | observed |
|---|---|---|
1. pixi install |
-DMYFLAG=OFF |
-- MYFLAG: OFF ✅ |
2. edit to -DMYFLAG=ON, pixi install |
-DMYFLAG=ON |
no configure runs; no -- MYFLAG: line; installed in ~10 ms; exit 0 ❌ |
3. pixi clean && pixi install |
-DMYFLAG=ON |
-- MYFLAG: ON ✅ |
Expected at step 2: a rebuild with the new configuration, or at minimum a warning that the installed artifact does not match the requested build configuration.
Cause
The build configuration does not appear to participate in the built package's identity, so after the metadata cache is invalidated the existing artifact is still considered valid for the environment and is installed as-is.
Second mechanism
Independently, crates/pixi_build_cmake/src/build_script.j2 guards the configure step on the build
artifact rather than on whether the configuration changed:
if [ ! -f "build.ninja" ]; then
cmake {{ cmake_args | join(" \\\n ") }}
fi
cmake --build . --target installThis came from pixi-build-backends#126 (fixing #3436), whose reasoning — "if any cmake file changed ninja itself will reconfigure the project" — holds for source changes but not for changes to the configure arguments.
To see it, edit CMakeLists.txt in the same change that edits extra-args. The package is then
rebuilt, and Ninja does regenerate ([1/2] Re-running CMake...) — but it re-runs CMake with the
originally cached command line, so the new extra-args is still not applied. The stale value is
compiled and linked in.
Impact
For flags that only affect optimisation this is surprising but harmless. For flags that select types, function signatures, or linked libraries it silently produces a binary that does not match the manifest.
We hit it in a scientific-computing stack where a CMake option selects between a CPU and a GPU code
path, changing public function signatures. Flipping that option in the manifest left the package
configured the old way; the resulting objects were then linked against a dependency built with the
new setting, producing several thousand undefined references to the other configuration's signatures
(f(..., void*) against f(..., cusolverDnContext*)).
That failure was at least loud. The same staleness with both sides consistently stale would link cleanly and simply run the wrong code path.
Suggested fixes
We understand from #126 that unconditionally re-running cmake was already considered and rejected on
overhead grounds, so these aim to keep that optimisation while closing the gap:
- Include the resolved build configuration in the built package's identity, so a changed
extra-args/envproduces a different artifact rather than reusing the old one. As a bonus, two configurations of the same package could coexist and be switched between without a full rebuild. - Include the resolved config in the build-directory cache key, so a configuration change gets a
fresh directory and the
build.ninjaguard does the right thing. No extracmakeinvocations in the common case, and #3436's failed-configure scenario stays fixed. - Stamp the configure arguments into the build directory and re-run
cmakeonly when they differ. - At minimum, warn instead of silently installing an artifact built with a different configuration — pixi already detects this and logs it at INFO.
Environment
pixi0.80.0pixi-build-cmake0.4.6.20260821.1400.40f3f4c, negotiated build-API version 7- linux-64
(Also reproduced on pixi 0.70.2 with pixi-build-cmake 0.3.14 / API v4, so this is not a recent
regression.)
Source: prefix-dev/pixi