[llvm] [BPF] Strip map struct names (PR #164851)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 23 11:27:44 PDT 2025


eddyz87 wrote:

> Linux kernel rejects programs which use named structs as map definitions. BPF programs written in C usually follow that restriction by using anonymous structs. But some LLVM frontend (e.g. Rust) don't support defining anonymous structs. To make sure they work, strip the map struct name unconditionally.

By map definition structs, you mean these things:

```c
struct {
        __uint(type, BPF_MAP_TYPE_HASH);
        __uint(max_entries, 1);
        __type(key, long long);
        __type(value, long long);
} map_hash_8b SEC(".maps");
``` 

right?

These are not processed by kernel, but by libbpf, so relaxing the requirement on the libbpf option is also an option.
Don't like adding more flags to `visitTypeEntry`, need to think a bit.

https://github.com/llvm/llvm-project/pull/164851


More information about the llvm-commits mailing list