Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildRustCrate: set NUM_JOBS to NIX_BUILD_CORES #105787

Merged
merged 1 commit into from Dec 16, 2020

Conversation

danieldk
Copy link
Contributor

@danieldk danieldk commented Dec 3, 2020

Motivation for this change

Bofore this change, NUM_JOBS was set to 1. Some crates for building
C/C++ code (e.g. the cc and cmake crates), rely on this variable to
set the number of jobs. As a consequence, we were compiling embedded
libraries serially. Change this to NIX_BUILD_CORES to permit parallel
builds.

Prior discussion:

#50452 (comment)

I think the comment about jobservers does not apply, since we are not
using Cargo, but rustc directly. For one crate that uses cmake, this
change reduces build time from 150 seconds to 36 seconds on my 3700X.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Bofore this change, NUM_JOBS was set to 1. Some crates for building
C/C++ code (e.g. the cc and cmake crates), rely on this variable to
set the number of jobs. As a consequence, we were compiling embedded
libraries serially. Change this to NIX_BUILD_CORES to permit parallel
builds.

Prior discussion:

NixOS#50452 (comment)
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/403

Copy link
Contributor

@drewrisinger drewrisinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approving b/c I don't know enough about the Rust infrastructure or why this was limited, but the rest of this evaluates the details of the PR. I think this is a positive change, though.

  • Diff LGTM
  • Commits LGTM
  • Didn't attempt build

@danieldk danieldk merged commit 00941cd into NixOS:master Dec 16, 2020
@danieldk danieldk deleted the build-rust-crate-njobs branch December 16, 2020 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants