4 ms·
Is there a way to make it use the number of CPU cores instead of hardcoding a fixed value into a config file that’s used on different machines?
by codeflo 3y ago
Is there a way to make it use the number of CPU cores instead of hardcoding a fixed value into a config file that’s used on different machines?
- wonrax 3y agoRUSTFLAGS environment variable, it's mentioned in the post too: > $ RUSTFLAGS="-Z threads=8" cargo build --release
- epage 3y agoKeep in mind, this is still an experiment and is restricted to nightly, so its not configured for general use. Id expect the stabilized default to be number of cores. No idea where this effort is at but at one point they were going to use jobserver to coordinate across cargo's rustc invokations at which point cargo's job count will be used which defaults to number of cores (and supports counting down from that with negative numbers.
- lights0123 3y agoBecause it uses the jobserver protocol which Cargo initializes to the number of cores by default, I'd imagine you could set the new flag to some unreasonably high number (e.g. 10000) and it should limit usage to free cores.