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

rustPackages.clippy fails to compile: can't find crate fmt_macros #77358

Closed
curiousleo opened this issue Jan 9, 2020 · 18 comments
Closed

rustPackages.clippy fails to compile: can't find crate fmt_macros #77358

curiousleo opened this issue Jan 9, 2020 · 18 comments
Labels
0.kind: bug Something is broken 6.topic: rust

Comments

@curiousleo
Copy link
Contributor

Describe the bug

nix-build . -A rustPackages.clippy fails on master since e82fae1 with this error:

   Compiling clippy_lints v0.0.212 (/build/rustc-1.40.0-src/src/tools/clippy/clippy_lints)
error[E0463]: can't find crate for `fmt_macros`
  --> src/tools/clippy/clippy_lints/src/lib.rs:20:1
   |
20 | extern crate fmt_macros;
   | ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

To Reproduce
Steps to reproduce the behavior:

  1. Check out any commit between e82fae1 and master
  2. nix-build . -A rustPackages.clippy
  3. Observe the compilation failure pasted above.

Expected behavior
nix-build . -A rustPackages.clippy should succeed.

Additional context
I discovered this build failure in the context of #77327.

Metadata

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 4.19.93, NixOS, 19.09.1778.db3e8325a9b (Loris)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.1`
 - channels(root): `"nixos-19.09.1778.db3e8325a9b"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@curiousleo curiousleo added the 0.kind: bug Something is broken label Jan 9, 2020
@curiousleo
Copy link
Contributor Author

rust-lang/rust-clippy#4651 points to rust-lang/rust#64823 being the root cause of this type of error - it looks like we'll need to pull in the rustc-dev component somehow and build clippy against that.

@curiousleo curiousleo changed the title rustPackages.clippy is broken rustPackages.clippy fails to compile: can't find crate fmt_macros Jan 9, 2020
@curiousleo
Copy link
Contributor Author

rust-lang/rust#64823 was reverted in rust-lang/rust#65342 due to rust-lang/rust#65335 ...

@curiousleo
Copy link
Contributor Author

... and then re-applied with some changes: rust-lang/rust#65474.

@curiousleo
Copy link
Contributor Author

... and then in rust-lang/rust#67469, rustc-dev (on which clippy_lints depends) was removed from the default set of components shipped with Rust nightly.

@curiousleo
Copy link
Contributor Author

On the clippy side, this PR (re-)introduced the extern crate declarations that lead to the compilation error (though this is probably just a symptom, not the cause): rust-lang/rust-clippy#3189

@curiousleo
Copy link
Contributor Author

@curiousleo
Copy link
Contributor Author

There may be an alternative way of building clippy: together with rustc, via --tools=clippy in https://github.com/rust-lang/rust/blob/1.40.0/src/bootstrap/configure.py#L157, which is forwarded to the install script here: https://github.com/rust-lang/rust/blob/1.40.0/src/bootstrap/install.rs#L160

@Mic92
Copy link
Member

Mic92 commented Jan 10, 2020

How does upstream build clippy?

@mati865
Copy link

mati865 commented Jan 10, 2020

How does upstream build clippy?

By enabling this option.

@curiousleo
Copy link
Contributor Author

How does upstream build clippy?

Good question :) Looking into this, I filed rust-lang/rust-clippy#5037.

clippy is referenced from the rust repository as a submodule.

The commit at which clippy is pinned in rust 1.40 is rust-lang/rust-clippy@c8e3cfb. Interestingly, that commit actually failed CI, though I can't tell why.

@curiousleo
Copy link
Contributor Author

How does upstream build clippy?

By enabling this option.

Alternatively, as per my suggestion above: setting the tools option.

@curiousleo
Copy link
Contributor Author

curiousleo commented Jan 10, 2020

@mati865, do you happen to know the entry point (a script or CI configuration) that is used to release clippy (as opposed to the CI in the clippy repo used for testing purposes)?

@mati865
Copy link

mati865 commented Jan 10, 2020

@curiousleo tools option is the list of the tools that will be built if extended option (which I linked above) is enabled.

Clippy is using unstable compiler API and thus is not meant to be built separately (stable and beta compilers will throw an error about unstable features unless unsupported hack is applied). AFAIK Clippy releases are done manually.

@curiousleo
Copy link
Contributor Author

@curiousleo tools option is the list of the tools that will be built if extended option (which I linked above) is enabled.

Awesome, I missed that! I don't think the way the comments are phrased make this unambiguous. Okay, I'll see if I can get this to work using --extended.

Clippy is using unstable compiler API and thus is not meant to be built separately (stable and beta compilers will throw an error about unstable features unless unsupported hack is applied). AFAIK Clippy releases are done manually.

Good to know. Thanks!

@curiousleo
Copy link
Contributor Author

I've managed to build clippy by adding --enable-extended and --tools=clippy to the rustc build arguments. That could be one way of getting clippy built.

Currently testing whether #77529 simply fixes this issue.

@curiousleo
Copy link
Contributor Author

I can confirm that #77529 allows nix-build . -A clippy to go through without an error.

I'll leave this issue open until #77529 is in master.

@curiousleo
Copy link
Contributor Author

@curiousleo
Copy link
Contributor Author

#77739 has been merged, and nix-build . -A clippy now succeeds on master. Closing.

Profpatsch added a commit to target/lorri that referenced this issue Mar 2, 2020
`rustPackages.clippy` exists in nixpkgs again:
NixOS/nixpkgs#77358 (comment)
Our nixpkgs pin is newer than when that change was merged.

We also enabled cachix on macOS, so even if clippy had to be built, it
can be cached.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: rust
Projects
None yet
Development

No branches or pull requests

4 participants