{"record":{"id":"2076ca142a3f73aa","repo":"rust-lang/cargo","slug":"cannot-compile-as-the-target-does-not-su","errorCode":null,"errorMessage":"cannot compile `{}` as the target `{}` does not support any of the output crate types","messagePattern":"cannot compile `(.+?)` as the target `(.+?)` does not support any of the output crate types","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/compiler/build_runner/compilation_files.rs","lineNumber":684,"sourceCode":"    ) -> CargoResult<Vec<OutputFile>> {\n        let out_dir = self.output_dir(unit);\n\n        let info = bcx.target_data.info(unit.kind);\n        let triple = bcx.target_data.short_name(&unit.kind);\n        let (file_types, unsupported) =\n            info.rustc_outputs(unit.mode, unit.target.kind(), triple)?;\n        if file_types.is_empty() {\n            if !unsupported.is_empty() {\n                let unsupported_strs: Vec<_> = unsupported.iter().map(|ct| ct.as_str()).collect();\n                anyhow::bail!(\n                    \"cannot produce {} for `{}` as the target `{}` \\\n                     does not support these crate types\",\n                    unsupported_strs.join(\", \"),\n                    unit.pkg,\n                    triple,\n                )\n            }\n            anyhow::bail!(\n                \"cannot compile `{}` as the target `{}` does not \\\n                 support any of the output crate types\",\n                unit.pkg,\n                triple,\n            );\n        }\n\n        // Convert FileType to OutputFile.\n        let mut outputs = Vec::new();\n        for file_type in file_types {\n            let meta = self.metas[unit];\n            let meta_opt = meta.c_extra_filename().map(|h| h.to_string());\n            let path = out_dir.join(file_type.output_filename(&unit.target, meta_opt.as_deref()));\n\n            // If, the `different_binary_name` feature is enabled, the name of the hardlink will\n            // be the name of the binary provided by the user in `Cargo.toml`.\n            let hardlink = self.uplift_to(unit, &file_type, &path, bcx);\n            let export_path = if unit.target.is_custom_build() {","sourceCodeStart":666,"sourceCodeEnd":702,"githubUrl":"https://github.com/rust-lang/cargo/blob/42eee92bc9aa4449f4e25d84e4ceb1cf8e0f87f9/src/compiler/build_runner/compilation_files.rs#L666-L702","documentation":"Same code path as 23 but stricter: `rustc_outputs` returned empty `file_types` AND empty `unsupported`. The target produces none of the requested output types and Cargo cannot even enumerate which were rejected — it can only state the target supports no requested output crate type at all.","triggerScenarios":"Building a `[lib]` with `crate-type` entries that are universally unsupported by the target (e.g. requesting `proc-macro` for a non-host target, or all types filtered out by mode/target combination).","commonSituations":"Building proc-macro crates for a cross target (proc-macros must compile for the host); empty `crate-type = []` combined with an unusual mode; target spec missing `target-c-int-width`/data-layout causing rustc to refuse all outputs.","solutions":["For proc-macro crates, ensure they build for the host: do not pass `--target` or add `package = { ... }` with a host-only build.","Populate `[lib] crate-type` with at least `rlib`/`lib` which is universally supported.","Switch to a well-formed target triple or fix the custom target JSON.","Run `cargo build -vv` and check the underlying rustc invocation."],"exampleFix":"// before\n[lib]\ncrate-type = []\n\n// after\n[lib]\ncrate-type = [\"rlib\"]","handlingStrategy":"validation","validationCode":"fn has_any_output_type(crate_types: &[String], target_supported: &[String]) -> bool {\n    crate_types.iter().any(|c| target_supported.iter().any(|s| s == c))\n}","typeGuard":"fn is_proc_macro_for_host(kind: CompileKind, target_kind: &str) -> bool {\n    target_kind == \"proc-macro\" && !kind.is_host()\n}","tryCatchPattern":"null","preventionTips":["Always include a universally supported type like `rlib` in `crate-type`.","Build proc-macro crates only for the host.","Validate custom target JSON with `rustc --print=target-spec-json`."],"tags":["cargo","crate-type","cross-compile","target","proc-macro"],"backgroundTag":null,"analyzedSha":"42eee92bc9aa4449f4e25d84e4ceb1cf8e0f87f9","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}