{"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":679,"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, bcx.gctx)?;\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":661,"sourceCodeEnd":697,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/compiler/build_runner/compilation_files.rs#L661-L697","documentation":"In calc_outputs_rustc (compilation_files.rs:679-684), the fallback arm of the empty-outputs check: rustc produces NO file types for the unit's target kind, and the unsupported list is empty (so there is nothing specific to name). Cargo reports the target supports none of the output crate types at all.","triggerScenarios":"A unit whose target/kind combination yields zero producible output file types on the selected target, with no specific unsupported entry to enumerate — e.g. trying to build a `bin` target on a target/configuration where no bin output type is available, or an example/procmacro on a target that cannot emit those.","commonSituations":"Building an inappropriate target kind for a triple (e.g. a proc-macro for a non-host target); a misconfigured custom target JSON missing output flavor mappings; `cargo build --target` with a kind incompatible with that triple.","solutions":["Verify the unit's kind (bin/lib/example) is buildable for the target triple.","For proc-macros, build for the host (do not pass `--target`, or use the host triple).","If using a custom target JSON, ensure `data-layout`/`llvm-target`/output fields are correct.","Drop `--target` or switch to a compatible triple."],"exampleFix":"// before\n$ cargo build --target thumbv6m-none-eabi --example my-example\nerror: cannot compile `my-crate` as the target `thumbv6m-none-eabi` does not support any of the output crate types\n\n// after\n$ cargo build --example my-example   // build for host","handlingStrategy":"validation","validationCode":"// Ensure the unit kind is buildable for the target\nif is_proc_macro(&unit) && unit.kind != CompileKind::Host {\n    return Err(\"proc-macros must build for the host target\");\n}\nif !kind_supported_for(unit.target.kind(), triple) {\n    return Err(format!(\"target {triple} supports none of {:?}\", unit.target.kind()));\n}","typeGuard":"fn kind_buildable_for(kind: &TargetKind, triple: &str) -> bool {\n    supported_kinds_for(triple).iter().any(|k| k == kind)\n}\n","tryCatchPattern":null,"preventionTips":["Build proc-macros for the host (no --target, or host triple).","Validate custom target JSON output mappings before building.","Cross-check unit kinds against target capabilities in CI."],"tags":["cargo","build","crate-type","cross-compile","target"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}