rust-lang/rust · error
not implemented
Error message
not implemented
What it means
`codegen_static` (consts.rs:83-97) reads a static initializer; if the value's LLVM type is `i1` (`val_llty == self.type_i1()`) it hits `unimplemented!()` at line 96. The comment at lines 92-93 explains: boolean SSA values are i1 but must be stored in i8 slots, otherwise LLVM optimization passes misbehave. rustc_codegen_gcc has not implemented the i1→i8 widening for static initializers, so any `static` of type `bool` (or an enum/struct whose initializer lowers to an i1) aborts codegen.
Source
Thrown at compiler/rustc_codegen_gcc/src/consts.rs:96
.global_set_readonly();
self.const_globals.borrow_mut().insert(cv, global_value);
global_value
}
fn codegen_static(&mut self, def_id: DefId) {
let attrs = self.tcx.codegen_fn_attrs(def_id);
let Ok((value, alloc)) = codegen_static_initializer(self, def_id) else {
// Error has already been reported
return;
};
let alloc = alloc.inner();
// boolean SSA values are i1, but they have to be stored in i8 slots,
// otherwise some LLVM optimization passes don't work as expected
let val_llty = self.val_ty(value);
if val_llty == self.type_i1() {
unimplemented!();
};
let is_thread_local = attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
let global = self.get_static_inner(def_id, val_llty);
#[cfg(feature = "master")]
if global.to_rvalue().get_type() != val_llty {
global.to_rvalue().set_type(val_llty);
}
// NOTE: Alignment from attributes has already been applied to the allocation.
set_global_alignment(self, global, alloc.align);
global.global_set_initializer_rvalue(value);
// As an optimization, all shared statics which do not have interior
// mutability are placed into read-only memory.
if alloc.mutability.is_not() {View on GitHub (pinned to 22057b88b0)
Solutions
- Avoid i1 statics in the crate being compiled: change `static X: bool = ...;` to `const X: bool = ...;` or store as `u8`/`u32` (e.g. `static X: u8 = 1;`) and convert at use sites.
- If you cannot edit the source, patch rustc_codegen_gcc's `codegen_static` to widen i1 initializers to i8 before storage (mirror the LLVM backend's behavior).
- Track/file the upstream issue: this is a known unimplemented branch, not a runtime config problem.
Example fix
// before (user code triggering consts.rs:96) static ENABLED: bool = true; // after const ENABLED: bool = true; // or, if a static is required: static ENABLED: u8 = 1;
Defensive patterns
Strategy: fallback
Validate before calling
// consts.rs:96 -> unimplemented!() when a static's value lowers to i1 (bool SSA). // Widen bool statics to i8 in source, or route the crate through LLVM. // In source: prefer `static FLAG: u8 = 1;` over `static FLAG: bool = true;`.
Prevention
- Avoid `static`/`const` items whose final SSA value is a bare bool; store as u8/i8 and convert at use sites.
- If one crate hits this, compile just that crate with the LLVM backend and keep the gcc backend for the rest of the graph.
- Track the upstream FIXME at consts.rs:92-97 - i1 static storage is unimplemented by design, so the fix is avoidance, not a patch.
When it happens
Trigger: Declaring a `static` item whose initializer evaluates to a boolean value, e.g. `static FLAG: bool = true;`, or a static of a type whose backend representation is `i1`. Reached via `codegen_static(def_id)` → the `val_llty == self.type_i1()` branch at consts.rs:95-97.
Common situations: Compiling a crate that defines a top-level `static` boolean (very common in feature-flag/config code). Not a config/env issue — it is a genuine missing-feature in rustc_codegen_gcc. Worked around in user code by avoiding i1 statics.
Related errors
- prologue for {:?}
- epilogue for {:?}
- epilogue_noreturn for {:?}
- save_register for {:?}
- restore_register for {:?}
AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03).
Data as JSON: /data/errors/b5131a9c43f5d0bb.json.
Report an issue: GitHub.