Skip to content

rustfmt: fix on darwin#231078

Merged
winterqt merged 1 commit intoNixOS:masterfrom
PuercoPop:fix-rustfmt-darwin
May 12, 2023
Merged

rustfmt: fix on darwin#231078
winterqt merged 1 commit intoNixOS:masterfrom
PuercoPop:fix-rustfmt-darwin

Conversation

@PuercoPop
Copy link
Copy Markdown
Contributor

Description of changes

Without this patch rustfmt installs successfully but upon running it it throws the following error

  $ rustfmt
  dyld[68147]: Library not loaded: @rpath/librustc_driver-c577224f5690b349.dylib
    Referenced from: <no uuid> /nix/store/w46inc6cad6xg2kw09v9n629iqb7aqrw-rustfmt-1.69.0/bin/rustfmt
    Reason: tried: '/nix/store/ih18sy1kcbl5kdgq2l8l1lm70ai6aybj-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/librustc_driver-c577224f5690b349.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/nix/store/ih18sy1kcbl5kdgq2l8l1lm70ai6aybj-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/librustc_driver-c577224f5690b349.dylib' (no such file), '/nix/store/ih18sy1kcbl5kdgq2l8l1lm70ai6aybj-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/librustc_driver-c577224f5690b349.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/nix/store/ih18sy1kcbl5kdgq2l8l1lm70ai6aybj-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/librustc_driver-c577224f5690b349.dylib' (no such file), '/usr/local/lib/librustc_driver-c577224f5690b349.dylib' (no such file), '/usr/lib/librustc_driver-c577224f5690b349.dylib' (no such file, not in dyld cache)
  Abort trap: 6

Reading this rust-issue it seems that we have to link against rustc_driver. The clippy.nix expression already does something similar

Of the 4 executables found in the result of building rustfmt only rustfmt and git-rustfmt needed to be linked. The other worked without linking to rustc_driver.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@github-actions github-actions Bot added the 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. label May 10, 2023
@PuercoPop
Copy link
Copy Markdown
Contributor Author

The editorconfig check is failing, I can't find the error message in the web UI. I tried reproducing the failure locally but it doesn't seem to complain:

cd ~/src/nixpkgs
$ nix-shell -p editorconfig-checker

[nix-shell:~/src/nixpkgs]$ editorconfig-checker -disable-indent-size pkgs/development/compilers/rust/rustfmt.nix 

[nix-shell:~/src/nixpkgs]$ echo $?
0

@winterqt
Copy link
Copy Markdown
Member

Blame GitHub -- I re-ran it, and it passed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Might be worth adding my comment from Clippy's derivation here, or just reference it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree that it should be commented. I was unsure on what was the best way to do so. I've copied the comment verbatim.

Copy link
Copy Markdown
Member

@winterqt winterqt left a comment

Choose a reason for hiding this comment

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

Commit message needs to be in proper form, e.g. rustfmt: fix on darwin.

@winterqt
Copy link
Copy Markdown
Member

I'd also argue that the commit message can be shortened significantly, as we already explain why this workaround is needed in the Clippy derivation/commits, but maybe I'm nitpicking too much :)

@ofborg ofborg Bot added the 6.topic: darwin Running or building packages on Darwin label May 10, 2023
@ofborg ofborg Bot requested review from basvandijk and globin May 10, 2023 14:38
@ofborg ofborg Bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. labels May 10, 2023
@PuercoPop PuercoPop force-pushed the fix-rustfmt-darwin branch 2 times, most recently from 469544f to 580f3f3 Compare May 10, 2023 15:01
@PuercoPop
Copy link
Copy Markdown
Contributor Author

PuercoPop commented May 10, 2023

Thanks for the swift review. I've updated the commit header line as requested and removed some of the specific details of the commit message. Let me know what you think

Reading this [rust-issue] it seems that we have to link against
rustc_driver. The [clippy.nix] expression already does something similar

Of the 4 executables found in the result of building rustfmt only
rustfmt and git-rustfmt needed to be linked. The other worked without
linking to rustc_driver.

[rust-issue]: rust-lang/rust#105609
[clippy.nix]: https://github.com/NixOS/nixpkgs/blob/c8cf570dae9b41f30395b71f9b432418b4ff0ebc/pkgs/development/compilers/rust/clippy.nix#L27-L36
@winterqt winterqt force-pushed the fix-rustfmt-darwin branch from 580f3f3 to 4e00120 Compare May 12, 2023 21:44
@winterqt winterqt changed the title fix rustfmt in darwin rustfmt: fix on darwin May 12, 2023
@winterqt
Copy link
Copy Markdown
Member

Just changed the commit message to remove the extraneous Darwin mention.

Copy link
Copy Markdown
Member

@winterqt winterqt left a comment

Choose a reason for hiding this comment

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

Tested, thanks!

@winterqt
Copy link
Copy Markdown
Member

Skipping OfBorg because I've already tested this extensively, and it seems to be very backed up right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. 12.first-time contribution This PR is the author's first one; please be gentle!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants