Open Notgnoshi opened 1 year ago
I'm now convinced this is a cc-rs issue. Using binary search, I was able to narrow it down to the 1.0.42 release of cc-rs, which is the release that first included jobserver
support. So I don't think this is a regression, just unexpected behavior. I'll go file a cc-rs issue shortly.
TL;DR - cmake-rs 0.1.49 breaks parallel builds when the build script also performs a cc-rs build with the
"parallel"
feature enabled.I don't think this is a cmake-rs bug, but it's the cmake-rs behavior that isn't right, so I thought this was the right place to file the issue.
At work, we have a project that uses https://github.com/dtolnay/cxx to wrap a quite large CMake C++ library with Rust bindings. I can't share the project, but the build script looks something like
I was able to reproduce the issue with a much smaller example project here: https://github.com/Notgnoshi/cmake-jobserver-bug. I tried to use the commit history to help narrow in on the issue.
My attempt at explaining the example project
I see the same behavior whether I export
MAKEFLAGS=-j16
orNUM_JOBS=16
.When I update the cmake-rs submodule to revert the commits
the behavior changes:
but I still don't think this is right - it should share the same jobserver as
cc-rs
andcargo
instead if starting a new one for just thespdlog
build.What I think the cause is
Notice that in the Cargo.toml, there's something suspicious:
We do this in our work project, because the cxx_bridge build is slow (it's a quite large project, and there's lots of files). Building in parallel made things magically better <3
If we instead do
the
spdlog
parallel CMake build works as expected (I visually verified that the build was parallel by watchinghtop
in a separate window)but the cc-rs build (and the cxx_bridge build in our work project) is no longer parallel :(
I think this points the finger at an awkward jobserver interplay between cmake-rs and cc-rs when the cc-rs
"parallel"
feature is enabled.version details: