https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121420
Bug ID: 121420
Summary: Failed to build BPF program accepted by Clang (error:
cannot take address of bit-field 'mem_hops')
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: sjames at gcc dot gnu.org
Target Milestone: ---
Created attachment 62063
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62063&action=edit
sample_filter.bpf.i.xz
This is from building perf's BPF skeletons with GCC instead of Clang:
```
$ bpf-unknown-none-gcc -gbtf -O2 -fno-stack-protector \
-Wall -Werror -I/home/sam/git/linux/tools/perf/util/bpf_skel/.tmp/..
-I/home/sam/git/linux/tools/perf/libbpf/include -idirafter
/usr/lib/llvm/20/bin/../../../../lib/clang/20/include -idirafter
/usr/local/include -idirafter /usr/include
-I/home/sam/git/linux/tools/include/uapi \
-include PERF-VERSION-FILE -include util/bpf_skel/perf_version.h \
-c util/bpf_skel/sample_filter.bpf.c -o
/home/sam/git/linux/tools/perf/util/bpf_skel/.tmp/sample_filter.bpf.o
In file included from util/bpf_skel/sample_filter.bpf.c:6:
util/bpf_skel/sample_filter.bpf.c: In function 'perf_get_sample':
/home/sam/git/linux/tools/perf/libbpf/include/bpf/bpf_core_read.h:169:42:
error: cannot take address of bit-field 'mem_hops'
169 | #define ___bpf_field_ref1(field) (&(field))
| ^
/home/sam/git/linux/tools/perf/libbpf/include/bpf/bpf_helpers.h:222:29: note:
in expansion of macro '___bpf_field_ref1'
222 | #define ___bpf_concat(a, b) a ## b
| ^
/home/sam/git/linux/tools/perf/libbpf/include/bpf/bpf_helpers.h:225:29: note:
in expansion of macro '___bpf_concat'
225 | #define ___bpf_apply(fn, n) ___bpf_concat(fn, n)
| ^~~~~~~~~~~~~
/home/sam/git/linux/tools/perf/libbpf/include/bpf/bpf_core_read.h:173:9: note:
in expansion of macro '___bpf_apply'
173 | ___bpf_apply(___bpf_field_ref, ___bpf_narg(args))(args)
| ^~~~~~~~~~~~
/home/sam/git/linux/tools/perf/libbpf/include/bpf/bpf_core_read.h:188:39: note:
in expansion of macro '___bpf_field_ref'
188 | __builtin_preserve_field_info(___bpf_field_ref(field),
BPF_FIELD_EXISTS)
| ^~~~~~~~~~~~~~~~
util/bpf_skel/sample_filter.bpf.c:167:29: note: in expansion of macro
'bpf_core_field_exists'
167 | if (bpf_core_field_exists(data->mem_hops))
| ^~~~~~~~~~~~~~~~~~~~~
cc1: error: argument is not a field access
```