From 8d6e439aae6a5e2e1b89647ec05ca2d0cf8df8b9 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sat, 27 Apr 2024 17:55:27 +0100 Subject: [PATCH] meson: copy prefix mapping CFLAGS when building BPF objects Otherwise the filenames will contain variable paths and break reproducibility --- meson.build | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/meson.build b/meson.build index af282af19c..547039064a 100644 --- a/meson.build +++ b/meson.build @@ -1717,6 +1717,24 @@ if conf.get('BPF_FRAMEWORK') == 1 '-c', ] + # If c_args contains these flags copy them along with the values, in order to avoid breaking + # reproducible builds and other functionality + propagate_cflags = [ + '-ffile-prefix-map=', + '-fdebug-prefix-map=', + '-fmacro-prefix-map=', + ] + + foreach opt : c_args + foreach flag : propagate_cflags + if opt.startswith(flag) + bpf_clang_flags += [opt] + bpf_gcc_flags += [opt] + break + endif + endforeach + endforeach + # Generate defines that are appropriate to tell the compiler what architecture # we're compiling for. By default we just map meson's cpu_family to ____. # This dictionary contains the exceptions where this doesn't work.