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

missing optimized MIR #34

Open
nsarlin-zama opened this issue Jul 8, 2024 · 6 comments
Open

missing optimized MIR #34

nsarlin-zama opened this issue Jul 8, 2024 · 6 comments

Comments

@nsarlin-zama
Copy link
Contributor

nsarlin-zama commented Jul 8, 2024

I don't know exactly what is the exact trigger for this, but I sometimes encounter a "missing optimized MIR" error when using tools built using this crate. This can be reproduced for example by running the example tool on itself, after having commented out the OddFunctionLineCount pass:

fn main() {
    let cargo_args = std::env::args().skip(2).collect::<Vec<_>>();
    rustc_tools::cargo_integration(&cargo_args, |args| {
        with_lints(args, vec![], |store: &mut LintStore| {
            store.register_early_pass(|| Box::new(warn_generics::WarnGenerics));
            //store.register_late_pass(|_| Box::new(odd_function_line_count::OddFunctionLineCount));
            store.register_late_pass(|_| Box::new(unwrap_call::UnwrapCall));
        })
        .expect("with_lints failed");
    })
    .expect("cargo_integration failed");
}
error: missing optimized MIR for an item in the crate `rustc_tools`
   |
note: missing optimized MIR for this item (was the crate `rustc_tools` compiled with `--emit=metadata`?)
  --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustc-tools-0.78.1/src/cargo.rs:27:1
   |
27 | / pub fn cargo_integration<T, F: Fn(&[String]) -> T>(
28 | |     cargo_args: &[String],
29 | |     f: F,
30 | | ) -> Result<T, String> {
   | |______________________^

error: aborting due to 1 previous error; 1 warning emitted

Adding --emit=metadata to the compiler flags seems to fix it but I don't know if this is the best solution. One side-effect is that it generates a libmain.rmeta file.

fn main() {
    let cargo_args = std::env::args().skip(2).collect::<Vec<_>>();
    rustc_tools::cargo_integration(&cargo_args, |args| {
        let mut args = args.to_vec();
        args.push("--emit=metadata".to_string());
        with_lints(&args, vec![], |store: &mut LintStore| {
            store.register_early_pass(|| Box::new(warn_generics::WarnGenerics));
            //store.register_late_pass(|_| Box::new(odd_function_line_count::OddFunctionLineCount));
            store.register_late_pass(|_| Box::new(unwrap_call::UnwrapCall));
        })
        .expect("with_lints failed");
    })
    .expect("cargo_integration failed");
}
@nsarlin-zama
Copy link
Contributor Author

Maybe this is related to rust-lang/rust#126012

@GuillaumeGomez
Copy link
Owner

So it will be fixed once the compiler version is updated I suppose. Not great though. :-/

@nsarlin-zama
Copy link
Contributor Author

I think that 1.80 should fix this ? I can do the upgrade to the latest compiler if it can help you and if you haven't started working on it.
The toolchain that should be used is nightly-2024-07-25, right ?

@GuillaumeGomez
Copy link
Owner

I think so yes. If you're motivated to do it, it's very welcome. :)

@nsarlin-zama
Copy link
Contributor Author

Sadly upgrading the compiler version does not seem to fix it, it might not be related to the linked issue...

@GuillaumeGomez
Copy link
Owner

Hum, interesting. Gonna try to take a look when I have some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants