{"record":{"id":"000315b84817814c","repo":"rust-lang/rust","slug":"toolchain-name-000315","errorCode":null,"errorMessage":"TOOLCHAIN_NAME","messagePattern":"TOOLCHAIN_NAME","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_cranelift/scripts/rustc-clif.rs","lineNumber":49,"sourceCode":"    if !passed_args\n        .iter()\n        .any(|arg| arg == \"--sysroot\" || arg.to_str().is_some_and(|s| s.starts_with(\"--sysroot=\")))\n    {\n        args.push(OsString::from(\"--sysroot\"));\n        args.push(OsString::from(sysroot.to_str().unwrap()));\n    }\n    if passed_args.is_empty() {\n        // Don't pass any arguments when the user didn't pass any arguments\n        // either to ensure the help message is shown.\n        args.clear();\n    }\n    args.extend(passed_args);\n\n    let rustc = if let Some(rustc) = option_env!(\"RUSTC\") {\n        rustc\n    } else {\n        // Ensure that the right toolchain is used\n        env::set_var(\"RUSTUP_TOOLCHAIN\", option_env!(\"TOOLCHAIN_NAME\").expect(\"TOOLCHAIN_NAME\"));\n        \"rustc\"\n    };\n\n    #[cfg(unix)]\n    panic!(\"Failed to spawn rustc: {}\", Command::new(rustc).args(args).exec());\n\n    #[cfg(not(unix))]\n    std::process::exit(\n        Command::new(rustc).args(args).spawn().unwrap().wait().unwrap().code().unwrap_or(1),\n    );\n}\n","sourceCodeStart":31,"sourceCodeEnd":61,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_codegen_cranelift/scripts/rustc-clif.rs#L31-L61","documentation":"This panic fires in the `rustc-clif` wrapper script for the Cranelift codegen backend. Identical in cause to [266]: `option_env!(\"TOOLCHAIN_NAME\").expect(\"TOOLCHAIN_NAME\")` at line 49. The script sets `RUSTUP_TOOLCHAIN` to the value of `TOOLCHAIN_NAME` to ensure the right toolchain is used when invoking `rustc`. If the variable wasn't set at script-compile time, the script panics on launch.","triggerScenarios":"Running `rustc-clif` (the Cranelift backend's rustc wrapper) when the binary was compiled without `TOOLCHAIN_NAME` in the build environment. Occurs when the wrapper was built outside the cg_clif build system.","commonSituations":"Manually building the cg_clif scripts without the build system, or installing a pre-built binary that was compiled without proper environment setup. The `rustc-clif` wrapper is what actually invokes rustc with `-Zcodegen-backend=<cranelift dylib>`, so it's needed for every cg_clif compilation.","solutions":["Use the official `y.rs` build system which sets `TOOLCHAIN_NAME` during compilation.","Set `TOOLCHAIN_NAME` manually: `TOOLCHAIN_NAME=stage2 cargo build --manifest-path scripts/Cargo.toml`.","Set the `RUSTC` environment variable to your rustc binary; the script will use it directly and bypass the `TOOLCHAIN_NAME` path.","Reinstall cg_clif following the README's exact build instructions."],"exampleFix":"# before (rustc-clif built without TOOLCHAIN_NAME → panic)\nrustc-clif --version\n\n# after (set RUSTC env to bypass toolchain lookup)\nRUSTC=$(rustup which rustc) rustc-clif --version\n# or rebuild properly:\nTOOLCHAIN_NAME=nightly cargo build --manifest-path scripts/Cargo.toml","handlingStrategy":"validation","validationCode":"// Same as [266]: ensure TOOLCHAIN_NAME is set at build time\n// test -n \"$TOOLCHAIN_NAME\" || export TOOLCHAIN_NAME=$(rustc --version)\n// Or set RUSTC to bypass:\n// export RUSTC=$(rustup which rustc)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use y.rs build system for cg_clif.","Set RUSTC env var to bypass TOOLCHAIN_NAME entirely.","Pin TOOLCHAIN_NAME to a specific stage in CI.","Never copy cg_clif wrapper binaries built outside the build system."],"tags":["rustc","cranelift","codegen-backend","build-config","toolchain","env-var","cg-clif"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}