rust-lang/rust · error
`rustc_codegen_gcc` doesn't support scalable vectors yet
Error message
`rustc_codegen_gcc` doesn't support scalable vectors yet
What it means
`vscale` — the LLVM intrinsic returning the runtime vector-scale factor for scalable vector types (SVE/RVV/AVX512-style) — is explicitly `unimplemented!("rustc_codegen_gcc doesn't support scalable vectors yet")`. The GCC backend cannot yet represent scalable vector types, so any code reaching this intrinsic panics with a descriptive message rather than emitting incorrect code.
Source
Thrown at compiler/rustc_codegen_gcc/src/builder.rs:1464
size: RValue<'gcc>,
_align: Align,
flags: MemFlags,
) {
assert!(!flags.contains(MemFlags::NONTEMPORAL), "non-temporal memset not supported");
let _is_volatile = flags.contains(MemFlags::VOLATILE);
let ptr = self.pointercast(ptr, self.type_i8p());
let memset = self.context.get_builtin_function("memset");
// FIXME(antoyo): handle align and is_volatile.
let fill_byte = self.context.new_cast(self.location, fill_byte, self.i32_type);
let size = self.intcast(size, self.type_size_t(), false);
self.block.add_eval(
self.location,
self.context.new_call(self.location, memset, &[ptr, fill_byte, size]),
);
}
fn vscale(&mut self, _: Self::Type) -> Self::Value {
unimplemented!("`rustc_codegen_gcc` doesn't support scalable vectors yet")
}
fn select(
&mut self,
cond: RValue<'gcc>,
then_val: RValue<'gcc>,
mut else_val: RValue<'gcc>,
) -> RValue<'gcc> {
let func = self.current_func();
let variable = func.new_local(self.location, then_val.get_type(), "selectVar");
let then_block = func.new_block("then");
let else_block = func.new_block("else");
let after_block = func.new_block("after");
self.llbb().end_with_conditional(self.location, cond, then_block, else_block);
then_block.add_assignment(self.location, variable, then_val);
then_block.end_with_jump(self.location, after_block);
View on GitHub (pinned to 22057b88b0)
Solutions
- Remove scalable-vector target-features (`-sve`/`-sve2`/`-rvv`) so only fixed-width SIMD is generated
- Switch the affected crate to fixed-width SIMD (`std::simd` fixed types, or the `wide`/`pulp`/`packed_simd` crates)
- Use the default LLVM backend (`-Ccodegen-backend=llvm`) for crates requiring scalable vectors until cg_gcc adds support
- Contribute or track the scalable-vector support work in rustc_codegen_gcc
Example fix
# before - .cargo/config.toml [target.aarch64-unknown-linux-gnu] rustflags = ["-C", "target-feature=+sve"] # after [target.aarch64-unknown-linux-gnu] rustflags = [] # cg_gcc cannot lower scalable vectors; omit +sve
Defensive patterns
Strategy: fallback
Validate before calling
// vscale() is unimplemented!() — cg_gcc cannot handle scalable vectors
// (SVE/RVV, <vscale x n x T>). Detect such types and bail to LLVM.
if type_is_scalable_vector(ty) || target_uses_scalable_vectors() {
// compile this crate with -C codegen-backend=llvm instead
return Err("scalable vectors unsupported by cg_gcc; use the LLVM backend");
} Type guard
fn is_scalable_vector_type<'gcc>(ty: Type<'gcc>) -> bool {
// True for SVE/RVV-style <vscale x n x T> types.
// Fixed-width SIMD types return false and ARE supported.
type_is_scalable_vector(ty)
} Try / catch
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
builder.vscale(ty)
})) {
Ok(v) => v,
Err(_) => {
// Recovery only possible by recompiling this unit with the LLVM backend.
switch_backend_to(Backend::Llvm);
return;
}
} Prevention
- Do not enable scalable-vector target features (`+sve`, `+sve2`, `+v` RVV) when targeting the GCC backend.
- Prefer fixed-width SIMD (`std::simd` fixed types, `#[repr(simd)]`) over scalable vectors when using cg_gcc.
- If scalable vectors are mandatory, compile that crate with `-C codegen-backend=llvm`.
When it happens
Trigger: Compiling code that uses scalable SIMD vector types: `core::intrinsics::simd` with scalable vectors, `std::simd` scalable APIs, SVE intrinsics on aarch64, or `#[repr(simd)]` scalable-type usage that lowers to a `vscale` call.
Common situations: Targeting aarch64 with `-Ctarget-feature=+sve`/`+sve2`, or RISC-V with `+v`/`+zve`, using nightly `std::simd` scalable types, or compiling crates (e.g. image/dsp kernels) that auto-detect SVE/RVV and emit scalable-vector code.
Related errors
- not implemented
- Called extract_element on a non-vector type
- not implemented
- first index in inbounds_gep
- internal error: entered unreachable code
AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03).
Data as JSON: /data/errors/b7ad13b005048293.json.
Report an issue: GitHub.