Skip to content

Commit

Permalink
clippy: fix on darwin
Browse files Browse the repository at this point in the history
As of Rust 1.67.0, the cargo-clippy binary now relies on the rustc_private
libraries [0], so let's do the RPATH fixup to it too.

I've also added a comment to explain the RPATH situation, as it took me
a bit to figure out.

[0]: rust-lang/rust-clippy#9541
  • Loading branch information
winterqt committed Feb 19, 2023
1 parent 1f97488 commit b626233
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkgs/development/compilers/rust/clippy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ rustPlatform.buildRustPackage {
# (/private/tmp/nix-build-clippy-1.36.0.drv-0/rustc-1.36.0-src/src/librustc_llvm)
doCheck = false;

# Clippy uses the rustc_driver and std private libraries, and Rust's build process forces them to have
# an install name of `@rpath/...` [0] [1] instead of the standard on macOS, which is an absolute path
# to itself.
#
# [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/clippy-driver"
install_name_tool -add_rpath "${rustc}/lib" "$out/bin/cargo-clippy"
'';

meta = with lib; {
Expand Down

0 comments on commit b626233

Please sign in to comment.