Skip to content

Do not pass -jN to make, use cargo jobserver instead #92

@tmpolaczyk

Description

@tmpolaczyk

When compiling a crate that has jemallocator-sys as a dependency with cargo build -j4, I see a short spike where the number of cpu cores used is 8 instead of 4. The cause is this crate using the NUM_JOBS env var to call make, which ignores that cargo already has other running jobs, thus bringing the total number of running jobs to be higher than NUM_JOBS. This doesn't happen in any of the other *-sys crates, I guess because they use the cc crate with the parallel feature enabled instead of manually calling make.

The fix is to remove the -jN arg to make if the CARGO_MAKEFLAGS env var exists, and set MAKEFLAGS to CARGO_MAKEFLAGS instead.

I expect the implementation to be similar to this:

https://github.com/rust-lang/cmake-rs/blob/c4a60dd154dd90e469dffc41a1faa717704f90b3/src/lib.rs#L830

I guess using a crate to call make instead of doing it manually would handle this and other issues automatically, but I don't know what's the standard so I can't recommend any crates.

Metadata

Metadata

Assignees

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