{"record":{"id":"c992c6c66dd1d636","repo":"rust-lang/rust","slug":"unsupported-apple-pointer-width-pointer-width","errorCode":null,"errorMessage":"unsupported Apple pointer width {pointer_width:?}","messagePattern":"unsupported Apple pointer width (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_ssa/src/back/apple.rs","lineNumber":95,"sourceCode":"/// ```console\n/// objdump --macho --reloc foo.o\n/// objdump --macho --full-contents foo.o\n/// ```\npub(super) fn add_data_and_relocation(\n    file: &mut object::write::Object<'_>,\n    section: object::write::SectionId,\n    symbol: object::write::SymbolId,\n    target: &Target,\n    kind: SymbolExportKind,\n) -> object::write::Result<()> {\n    let authenticated_pointer =\n        kind == SymbolExportKind::Text && target.llvm_target.starts_with(\"arm64e\");\n\n    let data: &[u8] = match target.pointer_width {\n        _ if authenticated_pointer => &[0, 0, 0, 0, 0, 0, 0, 0x80],\n        32 => &[0; 4],\n        64 => &[0; 8],\n        pointer_width => unimplemented!(\"unsupported Apple pointer width {pointer_width:?}\"),\n    };\n\n    if target.arch == Arch::X86_64 {\n        // Force alignment for the entire section to be 16 on x86_64.\n        file.section_mut(section).append_data(&[], 16);\n    } else {\n        // Elsewhere, the section alignment is the same as the pointer width.\n        file.section_mut(section).append_data(&[], target.pointer_width as u64);\n    }\n\n    let offset = file.section_mut(section).append_data(data, data.len() as u64);\n\n    let flags = if authenticated_pointer {\n        object::write::RelocationFlags::MachO {\n            r_type: object::macho::ARM64_RELOC_AUTHENTICATED_POINTER,\n            r_pcrel: false,\n            r_length: 3,\n        }","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_codegen_ssa/src/back/apple.rs#L77-L113","documentation":"An `unimplemented!(\"unsupported Apple pointer width {pointer_width:?}\")` panic in rustc_codegen_ssa's Apple relocation emitter (`add_data_and_relocation`). It chooses the relocation placeholder bytes (4 for 32-bit, 8 for 64-bit, plus an arm64e authenticated-pointer form). Any other `pointer_width` (e.g. a hypothetical 16-bit or 128-bit Apple target) has no defined placeholder and panics. This is a defensive guard, not normally reachable.","triggerScenarios":"Targeting an Apple platform whose target spec sets `pointer_width` to a value other than 32, 64, or the arm64e authenticated case. Triggered during linker-object emission for an undefined-symbol relocation.","commonSituations":"Almost never in practice: would require a custom/buggy Apple target spec with an invalid `pointer_width`, or a future Apple architecture with a non-standard pointer size that the linker object format cannot describe.","solutions":["Verify your `--target`/target spec has `pointer_width` set to `32` or `64` (the only supported Apple widths).","If you defined a custom target spec, fix its `pointer_width` field to a supported value.","Use a built-in Apple target triple (`aarch64-apple-darwin`, `x86_64-apple-darwin`, etc.) instead of a hand-rolled spec."],"exampleFix":"// before — custom spec with bad width\n// { \"pointer-width\": 128, ... }\nrustc --target custom-apple.json crate.rs\n\n// after — standard 64-bit Apple target\nrustc --target aarch64-apple-darwin crate.rs","handlingStrategy":"validation","validationCode":"# Validate Apple target spec pointer width before building\npython3 - <<'PY'\nimport json,sys\nspec=json.load(open('custom-apple.json'))\nassert spec.get('pointer-width') in (32,64), f\"unsupported Apple pointer width: {spec.get('pointer-width')}\"\nPY","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a built-in Apple target triple rather than a custom spec.","If you author a target spec, set `pointer-width` to 32 or 64 only.","Validate target-spec JSON before first compile."],"tags":["rustc","codegen-ssa","apple","linking","pointer-width","ice","compiler-internal","target-spec"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}