diff mbox series

fluentbit: improve path munging in debug source files

Message ID 20260324121755.3059617-1-ravi@prevas.dk
State Under Review
Headers show
Series fluentbit: improve path munging in debug source files | expand

Commit Message

Rasmus Villemoes March 24, 2026, 12:17 p.m. UTC
From: Rasmus Villemoes <ravi@prevas.dk>

Just remapping TMPDIR to TARGET_DBGSRC_DIR results in the files that
end up in the -src package containing lines such as

  #line 196 "/usr/src/debug/fluentbit/4.0.1//work/cortexa76-oe-linux/fluentbit/4.0.1/sources/fluentbit-4.0.1/lib/cmetrics/src/cmt_decode_prometheus.l"
  #line 1561 "/usr/src/debug/fluentbit/4.0.1//work/cortexa76-oe-linux/fluentbit/4.0.1/build/lib/cmetrics/cmt_decode_prometheus_parser.c"

By instead remapping both B and S, we strip more of the irrelevant
part of WORKDIR, and one ends up with line directives in the -src
package that actually match the source files' location in that
package:

  #line 196 "/usr/src/debug/fluentbit/4.0.1/lib/cmetrics/src/cmt_decode_prometheus.l"
  #line 1561 "/usr/src/debug/fluentbit/4.0.1/lib/cmetrics/cmt_decode_prometheus_parser.c"

  $ find packages-split/fluentbit-src/ -name cmt_decode_prometheus*.[cl] | sort
  packages-split/fluentbit-src/usr/src/debug/fluentbit/4.0.1/lib/cmetrics/cmt_decode_prometheus_lexer.c
  packages-split/fluentbit-src/usr/src/debug/fluentbit/4.0.1/lib/cmetrics/cmt_decode_prometheus_parser.c
  packages-split/fluentbit-src/usr/src/debug/fluentbit/4.0.1/lib/cmetrics/src/cmt_decode_prometheus.c
  packages-split/fluentbit-src/usr/src/debug/fluentbit/4.0.1/lib/cmetrics/src/cmt_decode_prometheus.l
  packages-split/fluentbit-src/usr/src/debug/fluentbit/4.0.1/lib/cmetrics/src/cmt_decode_prometheus_remote_write.c

and that also matches the remapping that the compiler is instructed to
do via the -ffile-prefix-map mechanism.

Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
---
 meta-oe/recipes-extended/fluentbit/fluentbit_4.2.3.1.bb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta-oe/recipes-extended/fluentbit/fluentbit_4.2.3.1.bb b/meta-oe/recipes-extended/fluentbit/fluentbit_4.2.3.1.bb
index b476206437..03f9e0e003 100644
--- a/meta-oe/recipes-extended/fluentbit/fluentbit_4.2.3.1.bb
+++ b/meta-oe/recipes-extended/fluentbit/fluentbit_4.2.3.1.bb
@@ -144,7 +144,8 @@  do_configure:prepend() {
 
 # flex hardcodes the input file in #line directives leading to TMPDIR contamination of debug sources.
 do_compile:append() {
-    find ${B} -name '*.c' -or -name '*.h' | xargs sed -i -e 's|${TMPDIR}|${TARGET_DBGSRC_DIR}/|g'
+    find ${B} -name '*.c' -or -name '*.h' | xargs sed -i -e 's|${B}|${TARGET_DBGSRC_DIR}|g'
+    find ${B} -name '*.c' -or -name '*.h' | xargs sed -i -e 's|${S}|${TARGET_DBGSRC_DIR}|g'
 }
 
 # needed for shared-lib package config