rust-lang/rust · error

This rustc version was not built with LLVM Offload support!

Error message

This rustc version was not built with LLVM Offload support!

What it means

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.

Source

Thrown at compiler/rustc_codegen_llvm/src/llvm/ffi.rs:1755

        );
    }
}

#[cfg(not(feature = "llvm_offload"))]
pub(crate) use self::Offload_fallback::*;

#[cfg(not(feature = "llvm_offload"))]
mod Offload_fallback {
    use super::*;
    /// Processes the module and writes it in an offload compatible way into a "device.bin" file.
    /// Marked as unsafe to match the real offload wrapper which is unsafe due to FFI.
    #[allow(unused_unsafe)]
    pub(crate) unsafe fn LLVMRustBundleImages<'a>(
        _M: &'a Module,
        _TM: &'a TargetMachine,
        _device_bin: *const c_char,
    ) -> bool {
        unimplemented!("This rustc version was not built with LLVM Offload support!");
    }
    pub(crate) unsafe fn LLVMRustOffloadEmbedBufferInModule<'a>(
        _M: &'a Module,
        _device_bin: *const c_char,
    ) -> bool {
        unimplemented!("This rustc version was not built with LLVM Offload support!");
    }
    #[allow(unused_unsafe)]
    pub(crate) unsafe fn LLVMRustOffloadMapper<'a>(
        _OldFn: &'a Value,
        _NewFn: &'a Value,
        _RebuiltArgs: *const &Value,
    ) {
        unimplemented!("This rustc version was not built with LLVM Offload support!");
    }
}

// FFI bindings for `DIBuilder` functions in the LLVM-C API.

View on GitHub (pinned to 22057b88b0)

Solutions

  1. 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.
  2. Use a rustc distribution that explicitly ships offload support if one is available for your target.
  3. Remove the offload-triggering flags/target and compile for the host CPU instead.
  4. Verify with `rustc --version --verbose` and the build configuration that offload was actually compiled in.

Example fix

// before
rustc -Zoffload --target=nvptx64-nvidia-cuda kernel.rs   # stock toolchain
// after
./x.py build --features llvm_offload    # rebuild rustc, then:
rustc -Zoffload --target=nvptx64-nvidia-cuda kernel.rs
Defensive patterns

Strategy: validation

Validate before calling

# LLVMRustBundleImages panics unless rustc was compiled with the
# `llvm_offload` cargo feature. Detect the capability before requesting
# offload bundling (e.g. -Zoffload, offload-only crate types).
rustc --print=cfg 2>/dev/null | grep -q '^target_feature="offload"$' \
  && { echo 'offload supported'; exit 0; }
# No target_feature=offload => bundling will hit the unimplemented! fallback.
if cargo rustc -- --help 2>/dev/null | grep -q -- '-Zoffload'; then
  echo 'NOTE: -Zoffload flag present, but this rustc has no LLVM offload backend' >&2
fi
exit 0

Try / catch

out="$(cargo build 2>&1)"; rc=$?
if [ $rc -ne 0 ]; then
  case "$out" in
    *"not built with LLVM Offload support"*)
      echo "requested offload bundling but rustc was built without the llvm_offload feature" >&2
      echo "fix: build rustc with --set llvm.rust-offload=true, or drop -Zoffload/offload targets" >&2 ;;
    *) echo "$out" >&2 ;;
  esac
  exit $rc
fi

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03). Data as JSON: /data/errors/025990065fcd0c41.json. Report an issue: GitHub.