Since #85 (auto-generating wrapper.h from installed MLIR headers), every cargo build / cargo test recompiles mlir-sys and everything downstream of it, even with no source changes.
Cause: build.rs writes $OUT_DIR/wrapper.h via fs::write and passes its path to bindgen via .header(...). Bindgen's CargoCallbacks then registers the wrapper file as a rerun-if-changed input. The wrapper is rewritten on every script invocation, and its mtime is set later than the build script's output file (because cargo finalizes output from captured stdout before the script reaches the fs::write call).
Cargo's fingerprinter compares each rerun-if-changed input's mtime against the build script's output file from the previous run; if the input is newer, the script is considered stale and rerun. Because wrapper.h is rewritten after the script's stdout has already been captured into output, it's always newer, and cargo always reruns the script — which regenerates wrapper.h with a yet-newer mtime, so the loop persists indefinitely.
Fix coming in a PR.
Assisted by Claude (Anthropic).
Since #85 (auto-generating
wrapper.hfrom installed MLIR headers), everycargo build/cargo testrecompilesmlir-sysand everything downstream of it, even with no source changes.Cause:
build.rswrites$OUT_DIR/wrapper.hviafs::writeand passes its path to bindgen via.header(...). Bindgen'sCargoCallbacksthen registers the wrapper file as arerun-if-changedinput. The wrapper is rewritten on every script invocation, and its mtime is set later than the build script'soutputfile (because cargo finalizesoutputfrom captured stdout before the script reaches thefs::writecall).Cargo's fingerprinter compares each
rerun-if-changedinput's mtime against the build script'soutputfile from the previous run; if the input is newer, the script is considered stale and rerun. Becausewrapper.his rewritten after the script's stdout has already been captured intooutput, it's always newer, and cargo always reruns the script — which regenerateswrapper.hwith a yet-newer mtime, so the loop persists indefinitely.Fix coming in a PR.
Assisted by Claude (Anthropic).