Skip to content

"rerun-if-changed" in build script causes causes fingerprint error and extra rebuild #2261

@mbrubeck

Description

@mbrubeck

If a dependency contains the following build script:

fn main() { println!("cargo:rerun-if-changed=build.rs"); }

Then running cargo build twice in a row compile the dependency twice, instead of just once:

$ cargo build
   Compiling a v0.1.0 (file:///home/mbrubeck/src/test/cargotest)
   Compiling cargotest v0.1.0 (file:///home/mbrubeck/src/test/cargotest)
$ cargo build
   Compiling a v0.1.0 (file:///home/mbrubeck/src/test/cargotest)
   Compiling cargotest v0.1.0 (file:///home/mbrubeck/src/test/cargotest)
$ cargo build
$ 

Possibly related: the following message appears in the log output during the second build, but not the first or third build:

INFO:cargo::ops::cargo_rustc::fingerprint: fingerprint error for a v0.1.0 (file:///home/mbrubeck/src/test/cargotest): local fingerprint type has changed

As reported by @cdlm on IRC, this affects the current version of the glutin crate. And here is a minimal test case for this issue: https://github.com/mbrubeck/cargotest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions