You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unstable flag --out-dir is unsafe in presence of multiple packages with build scripts & parallel build.
What I think is happening is with flag --out-dir cargo places compiled build.rs in a same location for all packages. For example, if I set --out-dir=./target, all build scripts will be compiled into target/build-script-build.
In case of a parallel build, this causes race condition between multiple processes. Eventually, build fails, either because script is deleted by another process or when wrong script is executed.
When build scripts do things like setting extra rustc arguments or generate files, build fails in a particularly spectacular way.
As an example, this is what we periodically get on our CI:
error[E0277]: the trait bound `i128: traits::Num` is not satisfied
--> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/num-integer-0.1.39/src/roots.rs:136:14
|
136 | impl Roots for $T {
| ^^^^^ the trait `traits::Num` is not implemented for `i128`
...
170 | signed_roots!(i128, u128);
| -------------------------- in this macro invocation
I think, this happens because num-traits uses build.rs to set has_i128. So, if "wrong" build.rs is being executed, package does not get this flag and eventually its dependency num-integer fails because of an error above (because it sets this flag independently).
Problem
Unstable flag
--out-dir
is unsafe in presence of multiple packages with build scripts & parallel build.What I think is happening is with flag
--out-dir
cargo places compiledbuild.rs
in a same location for all packages. For example, if I set--out-dir=./target
, all build scripts will be compiled intotarget/build-script-build
.In case of a parallel build, this causes race condition between multiple processes. Eventually, build fails, either because script is deleted by another process or when wrong script is executed.
When build scripts do things like setting extra rustc arguments or generate files, build fails in a particularly spectacular way.
As an example, this is what we periodically get on our CI:
I think, this happens because num-traits uses build.rs to set
has_i128
. So, if "wrong" build.rs is being executed, package does not get this flag and eventually its dependencynum-integer
fails because of an error above (because it sets this flag independently).Steps
build.rs
files.cargo build
-- everything works finecargo -Z unstable-options build --out-dir=./target
Possible Solution(s)
Maybe, treat
build.rs
output specially from regular outputs? Never place it into the directory specified by--out-dir
?Notes
Output of
cargo version
:The text was updated successfully, but these errors were encountered: