{"id":"025990065fcd0c41","repo":"rust-lang/rust","slug":"this-rustc-version-was-not-built-with-llvm-offload","errorCode":null,"errorMessage":"This rustc version was not built with LLVM Offload support!","messagePattern":"This rustc version was not built with LLVM Offload support!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_llvm/src/llvm/ffi.rs","lineNumber":1755,"sourceCode":"        );\n    }\n}\n\n#[cfg(not(feature = \"llvm_offload\"))]\npub(crate) use self::Offload_fallback::*;\n\n#[cfg(not(feature = \"llvm_offload\"))]\nmod Offload_fallback {\n    use super::*;\n    /// Processes the module and writes it in an offload compatible way into a \"device.bin\" file.\n    /// Marked as unsafe to match the real offload wrapper which is unsafe due to FFI.\n    #[allow(unused_unsafe)]\n    pub(crate) unsafe fn LLVMRustBundleImages<'a>(\n        _M: &'a Module,\n        _TM: &'a TargetMachine,\n        _device_bin: *const c_char,\n    ) -> bool {\n        unimplemented!(\"This rustc version was not built with LLVM Offload support!\");\n    }\n    pub(crate) unsafe fn LLVMRustOffloadEmbedBufferInModule<'a>(\n        _M: &'a Module,\n        _device_bin: *const c_char,\n    ) -> bool {\n        unimplemented!(\"This rustc version was not built with LLVM Offload support!\");\n    }\n    #[allow(unused_unsafe)]\n    pub(crate) unsafe fn LLVMRustOffloadMapper<'a>(\n        _OldFn: &'a Value,\n        _NewFn: &'a Value,\n        _RebuiltArgs: *const &Value,\n    ) {\n        unimplemented!(\"This rustc version was not built with LLVM Offload support!\");\n    }\n}\n\n// FFI bindings for `DIBuilder` functions in the LLVM-C API.","sourceCodeStart":1737,"sourceCodeEnd":1773,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_codegen_llvm/src/llvm/ffi.rs#L1737-L1773","documentation":"This `unimplemented!()` panic comes from the `Offload_fallback` module (ffi.rs:1745-1756), which is compiled only when rustc is built WITHOUT the `llvm_offload` cargo feature. The fallback stub `LLVMRustBundleImages` exists so non-offload rustc builds still link, but if the codegen path reaches it (e.g. to bundle device images into a host module for GPU offloading) it panics, because the real LLVM offload wrapper is absent. It signals that the binary was built without GPU offload support yet an offload operation was requested.","triggerScenarios":"Compiling with `-Ctarget-cpu`/offload flags or targeting a GPU architecture (nvptx/amdgpu offload, `-Zoffload`, or an offload bundler call) on a rustc built without `--features llvm_offload`. The panic fires inside the `LLVMRustBundleImages` fallback when codegen attempts to bundle device binary into the module.","commonSituations":"A stock rustc release that does not ship offload support; building rustc with `./x.py build` without enabling the `llvm_offload` feature; trying to compile CUDA/HIP offload code on a default toolchain.","solutions":["Build rustc with the offload feature enabled (pass the feature to the rustc_llvm/rustc_codegen_llvm build) and link an LLVM built with offload support.","Use a rustc distribution that explicitly ships offload support if one is available for your target.","Remove the offload-triggering flags/target and compile for the host CPU instead.","Verify with `rustc --version --verbose` and the build configuration that offload was actually compiled in."],"exampleFix":"// before\nrustc -Zoffload --target=nvptx64-nvidia-cuda kernel.rs   # stock toolchain\n// after\n./x.py build --features llvm_offload    # rebuild rustc, then:\nrustc -Zoffload --target=nvptx64-nvidia-cuda kernel.rs","handlingStrategy":"validation","validationCode":"# LLVMRustBundleImages panics unless rustc was compiled with the\n# `llvm_offload` cargo feature. Detect the capability before requesting\n# offload bundling (e.g. -Zoffload, offload-only crate types).\nrustc --print=cfg 2>/dev/null | grep -q '^target_feature=\"offload\"$' \\\n  && { echo 'offload supported'; exit 0; }\n# No target_feature=offload => bundling will hit the unimplemented! fallback.\nif cargo rustc -- --help 2>/dev/null | grep -q -- '-Zoffload'; then\n  echo 'NOTE: -Zoffload flag present, but this rustc has no LLVM offload backend' >&2\nfi\nexit 0","typeGuard":null,"tryCatchPattern":"out=\"$(cargo build 2>&1)\"; rc=$?\nif [ $rc -ne 0 ]; then\n  case \"$out\" in\n    *\"not built with LLVM Offload support\"*)\n      echo \"requested offload bundling but rustc was built without the llvm_offload feature\" >&2\n      echo \"fix: build rustc with --set llvm.rust-offload=true, or drop -Zoffload/offload targets\" >&2 ;;\n    *) echo \"$out\" >&2 ;;\n  esac\n  exit $rc\nfi","preventionTips":["Check `rustc --print=cfg | grep offload` before enabling any offload-related flag.","Only request offload on a rustc built from source with the `llvm_offload` cargo feature.","Gate offload code paths behind a build-script cfg probe so non-offload toolchains skip them.","Document the required custom toolchain in your project README; stock rustup builds do not include offload.","Avoid pinning offload in CI without first asserting the runner's rustc has the feature."],"tags":["llvm","gpu","offload","build-feature","panic"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}