{"id":"b7ad13b005048293","repo":"rust-lang/rust","slug":"rustc-codegen-gcc-doesn-t-support-scalable-vecto","errorCode":null,"errorMessage":"`rustc_codegen_gcc` doesn't support scalable vectors yet","messagePattern":"`rustc_codegen_gcc` doesn't support scalable vectors yet","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/rustc_codegen_gcc/src/builder.rs","lineNumber":1464,"sourceCode":"        size: RValue<'gcc>,\n        _align: Align,\n        flags: MemFlags,\n    ) {\n        assert!(!flags.contains(MemFlags::NONTEMPORAL), \"non-temporal memset not supported\");\n        let _is_volatile = flags.contains(MemFlags::VOLATILE);\n        let ptr = self.pointercast(ptr, self.type_i8p());\n        let memset = self.context.get_builtin_function(\"memset\");\n        // FIXME(antoyo): handle align and is_volatile.\n        let fill_byte = self.context.new_cast(self.location, fill_byte, self.i32_type);\n        let size = self.intcast(size, self.type_size_t(), false);\n        self.block.add_eval(\n            self.location,\n            self.context.new_call(self.location, memset, &[ptr, fill_byte, size]),\n        );\n    }\n\n    fn vscale(&mut self, _: Self::Type) -> Self::Value {\n        unimplemented!(\"`rustc_codegen_gcc` doesn't support scalable vectors yet\")\n    }\n\n    fn select(\n        &mut self,\n        cond: RValue<'gcc>,\n        then_val: RValue<'gcc>,\n        mut else_val: RValue<'gcc>,\n    ) -> RValue<'gcc> {\n        let func = self.current_func();\n        let variable = func.new_local(self.location, then_val.get_type(), \"selectVar\");\n        let then_block = func.new_block(\"then\");\n        let else_block = func.new_block(\"else\");\n        let after_block = func.new_block(\"after\");\n        self.llbb().end_with_conditional(self.location, cond, then_block, else_block);\n\n        then_block.add_assignment(self.location, variable, then_val);\n        then_block.end_with_jump(self.location, after_block);\n","sourceCodeStart":1446,"sourceCodeEnd":1482,"githubUrl":"https://github.com/rust-lang/rust/blob/22057b88b091743bc0fd8d592a9264f0a6951403/compiler/rustc_codegen_gcc/src/builder.rs#L1446-L1482","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before - .cargo/config.toml\n[target.aarch64-unknown-linux-gnu]\nrustflags = [\"-C\", \"target-feature=+sve\"]\n\n# after\n[target.aarch64-unknown-linux-gnu]\nrustflags = []  # cg_gcc cannot lower scalable vectors; omit +sve","handlingStrategy":"fallback","validationCode":"// vscale() is unimplemented!() — cg_gcc cannot handle scalable vectors\n// (SVE/RVV, <vscale x n x T>). Detect such types and bail to LLVM.\nif type_is_scalable_vector(ty) || target_uses_scalable_vectors() {\n    // compile this crate with -C codegen-backend=llvm instead\n    return Err(\"scalable vectors unsupported by cg_gcc; use the LLVM backend\");\n}","typeGuard":"fn is_scalable_vector_type<'gcc>(ty: Type<'gcc>) -> bool {\n    // True for SVE/RVV-style <vscale x n x T> types.\n    // Fixed-width SIMD types return false and ARE supported.\n    type_is_scalable_vector(ty)\n}","tryCatchPattern":"match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {\n    builder.vscale(ty)\n})) {\n    Ok(v) => v,\n    Err(_) => {\n        // Recovery only possible by recompiling this unit with the LLVM backend.\n        switch_backend_to(Backend::Llvm);\n        return;\n    }\n}","preventionTips":["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`."],"tags":["rust","codegen","gcc","gccjit","simd","scalable-vectors","sve","unimplemented"],"analyzedSha":"22057b88b091743bc0fd8d592a9264f0a6951403","analyzedAt":"2026-08-03T08:09:25.915Z","schemaVersion":2}