{"id":"9693c0791b978b2e","repo":"rust-lang/rust","slug":"unsupported-arch-arch","errorCode":null,"errorMessage":"unsupported arch {arch}","messagePattern":"unsupported arch (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"compiler/rustc_codegen_ssa/src/back/archive.rs","lineNumber":234,"sourceCode":"        }\n    };\n\n    // --no-leading-underscore: For the `import_name_type` feature to work, we need to be\n    // able to control the *exact* spelling of each of the symbols that are being imported:\n    // hence we don't want `dlltool` adding leading underscores automatically.\n    let dlltool = find_binutils_dlltool(sess);\n    // temp_prefix doesn't handle paths with spaces so\n    // use a relative path and set the current working directory\n    let cwd = output_path.parent().unwrap_or(output_path);\n    let temp_prefix = lib_name;\n    // dlltool target architecture args from:\n    // https://github.com/llvm/llvm-project-release-prs/blob/llvmorg-15.0.6/llvm/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp#L69\n    let (dlltool_target_arch, dlltool_target_bitness) = match &sess.target.arch {\n        Arch::X86_64 => (\"i386:x86-64\", \"--64\"),\n        Arch::X86 => (\"i386\", \"--32\"),\n        Arch::AArch64 => (\"arm64\", \"--64\"),\n        Arch::Arm => (\"arm\", \"--32\"),\n        arch => panic!(\"unsupported arch {arch}\"),\n    };\n    let mut dlltool_cmd = std::process::Command::new(&dlltool);\n    dlltool_cmd\n        .arg(\"-d\")\n        .arg(def_file_path)\n        .arg(\"-D\")\n        .arg(lib_name)\n        .arg(\"-l\")\n        .arg(&output_path)\n        .arg(\"-m\")\n        .arg(dlltool_target_arch)\n        .arg(\"-f\")\n        .arg(dlltool_target_bitness)\n        .arg(\"--no-leading-underscore\")\n        .arg(\"--temp-prefix\")\n        .arg(temp_prefix)\n        .current_dir(cwd);\n","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_codegen_ssa/src/back/archive.rs#L216-L252","documentation":"Thrown on the non-MSVC Windows path that invokes binutils dlltool to build an import library. The match maps arch to dlltool's -m target architecture string and only handles X86_64, X86, AArch64 and Arm. Any other arch passed to this GNU/MinGW import-library path panics because dlltool has no known flag set for it. Reached when is_like_msvc is false but the target still requires a Windows import library.","triggerScenarios":"Building a staticlib/cdylib for a MinGW/GNU Windows target (e.g. *-pc-windows-gnu) whose arch is not X86_64/X86/AArch64/Arm, so dlltool lacks a -m argument. Also reachable via a custom target spec mislabeled as GNU Windows with an exotic arch.","commonSituations":"Custom windows-gnu target JSON with an unsupported arch. Cross-compiling to windows-gnu on a non-x86/arm architecture that dlltool does not understand. Toolchain drift where a new arch was added to rustc_target but not to this match.","solutions":["Target a supported MinGW arch triple such as x86_64-pc-windows-gnu or i686-pc-windows-gnu.","If the target is genuinely MSVC, set is_like_msvc=true so the native ar_archive_writer path (archive.rs:125) is taken rather than dlltool.","To support a new arch, add the (dlltool_target_arch, bitness) pair at compiler/rustc_codegen_ssa/src/back/archive.rs:229."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn archive_arch_supported(arch: &str) -> bool {\n    const OK: &[&str] = &[\n        \"x86_64\", \"i686\", \"i586\", \"aarch64\", \"arm\", \"armv7\",\n        \"powerpc\", \"powerpc64\", \"powerpc64le\", \"s390x\",\n        \"riscv64\", \"riscv32\", \"mips\", \"mips64\", \"sparc\",\n        \"sparc64\", \"wasm32\", \"msp430\", \"nvptx64\",\n    ];\n    OK.contains(&arch)\n}","typeGuard":"fn is_supported_archive_arch(arch: &str) -> bool {\n    !arch.is_empty() && archive_arch_supported(arch)\n}","tryCatchPattern":"let s = String::from_utf8_lossy(&output.stderr);\nif s.contains(\"unsupported arch\") {\n    return Err(LinkError::UnsupportedArch(arch.into()));\n}","preventionTips":["Resolve the target arch from the triple (`rustc --print cfg --target=...`) before invoking archive ops.","Reject hand-crafted triples whose arch field is not in the tier list.","Keep a whitelist of arches your build pipeline supports; fail fast on anything else."],"tags":["mingw","windows-gnu","dlltool","import-library","archive"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}