diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-04-12 19:40:37 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-04-13 10:19:53 +0000 |
commit | 0944487ccf770cb6bcf6a0f7e5130e5ead72e3f3 (patch) | |
tree | c0bdffeae04b415eae36decb4d8514107ea1c406 /pkgs/development/compilers/rust | |
parent | e4050a496b9356e493ea396717a44eb55abed65a (diff) | |
download | nixlib-0944487ccf770cb6bcf6a0f7e5130e5ead72e3f3.tar nixlib-0944487ccf770cb6bcf6a0f7e5130e5ead72e3f3.tar.gz nixlib-0944487ccf770cb6bcf6a0f7e5130e5ead72e3f3.tar.bz2 nixlib-0944487ccf770cb6bcf6a0f7e5130e5ead72e3f3.tar.lz nixlib-0944487ccf770cb6bcf6a0f7e5130e5ead72e3f3.tar.xz nixlib-0944487ccf770cb6bcf6a0f7e5130e5ead72e3f3.tar.zst nixlib-0944487ccf770cb6bcf6a0f7e5130e5ead72e3f3.zip |
clippy: use the right rustc when cross compiling
When cross compiling, buildPackages.cargo uses a rustc that can build for both the build and host platforms. This was not true of buildPackages.clippy, so it was not possible to use clippy for a cross target. Now it is. I've modified clippy.nix to use rustc from rustPlatform, so we only have to add a single override in default.nix.
Diffstat (limited to 'pkgs/development/compilers/rust')
-rw-r--r-- | pkgs/development/compilers/rust/clippy.nix | 12 | ||||
-rw-r--r-- | pkgs/development/compilers/rust/default.nix | 8 |
2 files changed, 14 insertions, 6 deletions
diff --git a/pkgs/development/compilers/rust/clippy.nix b/pkgs/development/compilers/rust/clippy.nix index 499db45021ea..26c73dba33d6 100644 --- a/pkgs/development/compilers/rust/clippy.nix +++ b/pkgs/development/compilers/rust/clippy.nix @@ -1,7 +1,8 @@ -{ stdenv, lib, rustPlatform, rustc, Security, patchelf }: +{ stdenv, lib, rustPlatform, Security, patchelf }: + rustPlatform.buildRustPackage { pname = "clippy"; - inherit (rustc) version src; + inherit (rustPlatform.rust.rustc) version src; # the rust source tarball already has all the dependencies vendored, no need to fetch them again cargoVendorDir = "vendor"; @@ -10,7 +11,8 @@ rustPlatform.buildRustPackage { # changes hash of vendor directory otherwise dontUpdateAutotoolsGnuConfigScripts = true; - buildInputs = [ rustc.llvm ] ++ lib.optionals stdenv.isDarwin [ Security ]; + buildInputs = [ rustPlatform.rust.rustc.llvm ] + ++ lib.optionals stdenv.isDarwin [ Security ]; # fixes: error: the option `Z` is only accepted on the nightly compiler RUSTC_BOOTSTRAP = 1; @@ -27,8 +29,8 @@ rustPlatform.buildRustPackage { # [0]: https://github.com/rust-lang/rust/blob/f77f4d55bdf9d8955d3292f709bd9830c2fdeca5/src/bootstrap/builder.rs#L1543 # [1]: https://github.com/rust-lang/rust/blob/f77f4d55bdf9d8955d3292f709bd9830c2fdeca5/compiler/rustc_codegen_ssa/src/back/linker.rs#L323-L331 preFixup = lib.optionalString stdenv.isDarwin '' - install_name_tool -add_rpath "${rustc}/lib" "$out/bin/clippy-driver" - install_name_tool -add_rpath "${rustc}/lib" "$out/bin/cargo-clippy" + install_name_tool -add_rpath "${rustPlatform.rust.rustc}/lib" "$out/bin/clippy-driver" + install_name_tool -add_rpath "${rustPlatform.rust.rustc}/lib" "$out/bin/cargo-clippy" ''; meta = with lib; { diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix index 42ca74c7164d..1ef03420ced9 100644 --- a/pkgs/development/compilers/rust/default.nix +++ b/pkgs/development/compilers/rust/default.nix @@ -83,7 +83,13 @@ in }; cargo-auditable = self.callPackage ./cargo-auditable.nix { }; cargo-auditable-cargo-wrapper = self.callPackage ./cargo-auditable-cargo-wrapper.nix { }; - clippy = self.callPackage ./clippy.nix { inherit Security; }; + clippy = callPackage ./clippy.nix { + # We want to use self, not buildRustPackages, so that + # buildPackages.clippy uses the cross compiler and supports + # linting for the target platform. + rustPlatform = makeRustPlatform self; + inherit Security; + }; }); }; } |