https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127248
Bug ID: 127248
Summary: bpf: BTF line info does not respect -ffile-prefix-map
for source file paths
Product: gcc
Version: 16.1.1
Status: UNCONFIRMED
Keywords: btf-debug
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: marocketbd at gmail dot com
Target Milestone: ---
Target: bpf-unknown-none
Created attachment 65520
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65520&action=edit
A simple C file to reproduce problem
I would like to build software package with gcc-bpf, but I found that absolute
file path can not be remapped via file-prefix-map.
I'm the maintainer of package ceccomp in Debian, recently ceccomp add a new
module which utilizes eBPF progs. I would like to build the package with
gcc-bpf as gcc-bpf >= 15 should be mature enough to build BPF objects
correctly. However, the absolute source file path can be spotted in .BTF
section, which can be a obstacle of generating reproducible binaries. I tried
-ffile-prefix-map flag, no help. Please consider support -ffile-prefix-map when
generating .BTF section.
Fyi, I used LLM to do some debugging: when adding line info in
gcc/config/bpf/btfext-out.cc::btf_add_line_info_for #L470, relative path is
expanded to absolute path, but these file names will never be processed with
remap_debug_filename or remap_macro_filename.
To reproduce the problem, down below I attached a simple C file. Use bpf-gcc
-O2 -g -S c.c -ffile-prefix-map=$PWD=. -o -, should not spot $PWD in output.