Don't think this is true, after changing my cmake script.
Previously, I wrap cargo inside flock to ensure it is run in serial.
After removing the flock, the following errors occur in my CI.
All of them seems to be caused missing proper file locking
error: failed to run custom build command for `quote v1.0.29`
Caused by:
could not execute process `XXXXXX/target/release/build/quote-fb2d7e989f9b47f6/build-script-build` (never executed)
Caused by:
No such file or directory (os error 2)
error: failed to run custom build command for `serde v1.0.167`
error: failed to run custom build command for `serde v1.0.167`
Caused by:
could not execute process `XXXXX/target/release/build/serde-8f20938a6fc124bb/build-script-build` (never executed)
Caused by:
Text file busy (os error 26)
error: failed to build archive: No such file or directory
and also errors from linker
"-o" "XXXXX/target/debug/build/doc-comment-dc57ebc3b6cb89ee/build_script_build-dc57ebc3b6cb89ee" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
= note: /usr/bin/ld: failed to set dynamic section sizes: File truncated
Not sure if generated build script is properly locked
I don't think support for two cargo build is supported.
This is NOT documented any where for cargo,
or at least this is at least not properly tested.
I don't observe rust-analyzer that itself runs multiple cargo build in parallel.
I ask this question because I am running cargo in CMake.
I think the only proper solutions are one of:
- Wrap
cargo inside flock, to ensure only one instance is run
- Compile each cargo crate in separate target directory, so
cargo build is safe to run in parallel
This is what Corrosion does. But this will duplicate lots of compilation, especially when there are lots of shared build script dependencies, making compilation slow
I want to avoid the second method,
because I want to ensure cmake --build and cargo build in the terminal,
shares the same output path