build.rs
Repro
clone https://github.com/stepancheg/cargo-build-rs-twice
cd cargo-build-rs-twice
Stable:
% rm xx/*; cargo +stable build --all-targets && ls xx/
Updating registry `https://github.com/rust-lang/crates.io-index`
Compiling libc v0.2.41
Compiling fgfgf v0.1.0 (file:///Users/nga/tmp/cargo-build-rs-twice)
Finished dev [unoptimized + debuginfo] target(s) in 2.59 secs
50421
Nightly:
% rm xx/*; cargo +nightly build --all-targets && ls xx/
Compiling libc v0.2.41
Compiling fgfgf v0.1.0 (file:///Users/nga/tmp/cargo-build-rs-twice)
Finished dev [unoptimized + debuginfo] target(s) in 2.85s
50513 50514
build.rs writes a pid file into xx/ directory.
Two pid files in xx directory mean that build.rs was executed twice in nightly.
% cargo +nightly version
cargo 1.28.0-nightly (f352115d5 2018-05-15)
% cargo +stable version
cargo 1.26.0 (0e7c5a931 2018-04-06)