cilium/cilium · error
unsupported encoding %v
Error message
unsupported encoding %v
What it means
For btf.Integer, varGoValue only recognizes Signed, Unsigned and Bool encodings. Any other Encoding value (e.g. character or bitfield-flavored encodings from certain toolchains) has no mapping, so the generator refuses to emit a default.
Source
Thrown at tools/dpgen/config.go:257
return nil, fmt.Errorf("unsupported signed integer size %d", t.Size)
}
case btf.Unsigned:
switch t.Size {
case 1:
return getValue[uint8](v)
case 2:
return getValue[uint16](v)
case 4:
return getValue[uint32](v)
case 8:
return getValue[uint64](v)
default:
return nil, fmt.Errorf("unsupported unsigned integer size %d", t.Size)
}
case btf.Bool:
return getValue[bool](v)
default:
return nil, fmt.Errorf("unsupported encoding %v", t.Encoding)
}
case *btf.Union:
needUtils = true
return getCastValue(t.Name, t.Size, v, typesPkg)
case *btf.Struct:
needUtils = true
return getCastValue(t.Name, t.Size, v, typesPkg)
default:
return "", fmt.Errorf("unsupported type %T", t)
}
}
func getValue[T comparable](v *ebpf.VariableSpec) (out T, err error) {
if err := v.Get(&out); err != nil {
return out, fmt.Errorf("getting value: %w", err)View on GitHub (pinned to ac7b90affa)
Solutions
- Replace the type with an explicitly signed/unsigned type or bool so the encoding is one of the three supported.
- Rebuild with a supported clang/LLVM version with -g.
- Inspect the actual Encoding via bpftool btf dump.
- Extend the encoding switch in varGoValue if needed.
Example fix
// before (ambiguous encoding) char mode; // after signed char mode; // or unsigned char / bool
Defensive patterns
Strategy: validation
Validate before calling
if t, ok := btf.UnderlyingType(v.Type).(*btf.Int); ok {
switch t.Encoding {
case btf.Signed, btf.Unsigned, btf.Bool:
default:
return fmt.Errorf("%s: encoding %v unsupported", v.Name, t.Encoding)
}
} Type guard
func hasSupportedIntEncoding(t btf.Type) bool {
i, ok := btf.UnderlyingType(t).(*btf.Int)
if !ok {
return false
}
return i.Encoding == btf.Signed || i.Encoding == btf.Unsigned || i.Encoding == btf.Bool
} Prevention
- Prefer explicitly signed/unsigned types over plain char.
- Use stdbool.h bool for flags so the encoding is btf.Bool.
- Keep the clang/LLVM version consistent with what dpgen supports.
- Inspect encodings via bpftool btf dump when in doubt.
When it happens
Trigger: A config variable whose BTF integer type reports an Encoding other than Signed/Unsigned/Bool while varGoValue runs.
Common situations: Plain 'char' whose encoding resolves oddly across clang versions, or objects built by a compiler emitting encodings the generator doesn't anticipate.
Related errors
- generating config struct: %w
- variable %s has no type information, was the ELF built witho
- variable %s has no doc comment
- variable %s: converting tags to comments: %w
- variable %s: getting default Go value: %w
AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31).
Data as JSON: /api/errors/b91019af9d4028bd.
Report an issue: GitHub.