diff options
author | Khem Raj <raj.khem@gmail.com> | 2025-04-21 10:29:15 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-04-23 09:47:42 +0100 |
commit | ea00dbbcf3bacf6e115fb261d9880f52be25ca05 (patch) | |
tree | 52c389798e1d0e8bdac5a9ef7f861a3c9266911a | |
parent | 15a20fdcbae2b6a540039b75a78082e34c19772c (diff) | |
download | poky-ea00dbbcf3bacf6e115fb261d9880f52be25ca05.tar.gz |
bitbake.conf: Switch prefix mapping to use -ffile-prefix-map
-ffile-prefix map is more comprehensive when it comes to reproducible
builds and its superset of all prefix-mapping options in compilers
This makes is cleaner and workable across gcc and clang, clang does not
support -fcanon-prefix-map and it has to be explicitly omitted when using
clang.
There are lambdas generated in templates by clang which still get the
absolute paths despite -fdebug-prefix-map, this helps with that as well.
nasm is an outlier and we have fixed it by adding -fdebug-prefix-map option
luckily we do not pass DEBUG_PREFIX_MAP to nasm, in all recipes which use
nasm either pass -fdebug-prefix-map explicitly to nasm or they rewrite it
to use nasm flags syntax.
We have discussed this in past [1]
[1] https://patchwork.yoctoproject.org/project/oe-core/patch/20230428032030.2047920-1-raj.khem@gmail.com/#10281
(From OE-Core rev: ff73fa7ef7666a6dbe34f15515bc3ab6e574c5b0)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Jacob Kroon <jacob.kroon@gmail.com>
Cc: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes-recipe/kernel-arch.bbclass | 6 | ||||
-rw-r--r-- | meta/conf/bitbake.conf | 14 | ||||
-rw-r--r-- | meta/lib/oe/package.py | 2 | ||||
-rw-r--r-- | meta/recipes-devtools/gcc/libgfortran.inc | 2 | ||||
-rw-r--r-- | meta/recipes-devtools/python/python3-maturin_1.8.3.bb | 2 | ||||
-rw-r--r-- | meta/recipes-devtools/rust/cargo_1.85.1.bb | 2 |
6 files changed, 11 insertions, 17 deletions
diff --git a/meta/classes-recipe/kernel-arch.bbclass b/meta/classes-recipe/kernel-arch.bbclass index 36a6e0a60a..749a266ea3 100644 --- a/meta/classes-recipe/kernel-arch.bbclass +++ b/meta/classes-recipe/kernel-arch.bbclass | |||
@@ -73,10 +73,8 @@ HOST_OBJCOPY_KERNEL_ARCH ?= "${TARGET_OBJCOPY_KERNEL_ARCH}" | |||
73 | 73 | ||
74 | KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} \ | 74 | KERNEL_CC = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_KERNEL_ARCH} \ |
75 | -fuse-ld=bfd ${DEBUG_PREFIX_MAP} \ | 75 | -fuse-ld=bfd ${DEBUG_PREFIX_MAP} \ |
76 | -fdebug-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} \ | 76 | -ffile-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} \ |
77 | -fmacro-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} \ | 77 | -ffile-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH} \ |
78 | -fdebug-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH} \ | ||
79 | -fmacro-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH} \ | ||
80 | " | 78 | " |
81 | KERNEL_LD = "${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}" | 79 | KERNEL_LD = "${HOST_PREFIX}ld.bfd ${HOST_LD_KERNEL_ARCH}" |
82 | KERNEL_AR = "${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}" | 80 | KERNEL_AR = "${HOST_PREFIX}ar ${HOST_AR_KERNEL_ARCH}" |
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index 501808204e..b1dae17267 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf | |||
@@ -652,15 +652,11 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} " | |||
652 | ################################################################## | 652 | ################################################################## |
653 | TARGET_DBGSRC_DIR ?= "/usr/src/debug/${PN}/${PV}" | 653 | TARGET_DBGSRC_DIR ?= "/usr/src/debug/${PN}/${PV}" |
654 | # Beware: applied last to first | 654 | # Beware: applied last to first |
655 | DEBUG_PREFIX_MAP ?= "-fcanon-prefix-map \ | 655 | DEBUG_PREFIX_MAP ?= "\ |
656 | -fmacro-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ | 656 | -ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ |
657 | -fdebug-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ | 657 | -ffile-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ |
658 | -fmacro-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ | 658 | -ffile-prefix-map=${STAGING_DIR_HOST}= \ |
659 | -fdebug-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ | 659 | -ffile-prefix-map=${STAGING_DIR_NATIVE}= \ |
660 | -fdebug-prefix-map=${STAGING_DIR_HOST}= \ | ||
661 | -fmacro-prefix-map=${STAGING_DIR_HOST}= \ | ||
662 | -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ | ||
663 | -fmacro-prefix-map=${STAGING_DIR_NATIVE}= \ | ||
664 | " | 660 | " |
665 | DEBUG_LEVELFLAG ?= "-g" | 661 | DEBUG_LEVELFLAG ?= "-g" |
666 | 662 | ||
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py index 0db14f2164..0bcc04ea54 100644 --- a/meta/lib/oe/package.py +++ b/meta/lib/oe/package.py | |||
@@ -991,7 +991,7 @@ def copydebugsources(debugsrcdir, sources, d): | |||
991 | 991 | ||
992 | prefixmap = {} | 992 | prefixmap = {} |
993 | for flag in cflags.split(): | 993 | for flag in cflags.split(): |
994 | if not flag.startswith("-fdebug-prefix-map"): | 994 | if not flag.startswith("-ffile-prefix-map"): |
995 | continue | 995 | continue |
996 | if "recipe-sysroot" in flag: | 996 | if "recipe-sysroot" in flag: |
997 | continue | 997 | continue |
diff --git a/meta/recipes-devtools/gcc/libgfortran.inc b/meta/recipes-devtools/gcc/libgfortran.inc index 4560421ed1..fa6aecaaa3 100644 --- a/meta/recipes-devtools/gcc/libgfortran.inc +++ b/meta/recipes-devtools/gcc/libgfortran.inc | |||
@@ -8,7 +8,7 @@ EXTRA_OECONF_PATHS = "\ | |||
8 | # An arm hard float target like raspberrypi4 won't build | 8 | # An arm hard float target like raspberrypi4 won't build |
9 | # as CFLAGS don't make it to the fortran compiler otherwise | 9 | # as CFLAGS don't make it to the fortran compiler otherwise |
10 | # (the configure script sets FC to $GFORTRAN unconditionally) | 10 | # (the configure script sets FC to $GFORTRAN unconditionally) |
11 | export GFORTRAN = "${FC} -fcanon-prefix-map -fdebug-prefix-map=${S}=${TARGET_DBGSRC_DIR} -fdebug-prefix-map=${B}=${TARGET_DBGSRC_DIR} -gno-record-gcc-switches" | 11 | export GFORTRAN = "${FC} -ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR} -ffile-prefix-map=${B}=${TARGET_DBGSRC_DIR} -gno-record-gcc-switches" |
12 | 12 | ||
13 | do_configure () { | 13 | do_configure () { |
14 | for target in libbacktrace libgfortran | 14 | for target in libbacktrace libgfortran |
diff --git a/meta/recipes-devtools/python/python3-maturin_1.8.3.bb b/meta/recipes-devtools/python/python3-maturin_1.8.3.bb index 3ec4d0c103..08975e177f 100644 --- a/meta/recipes-devtools/python/python3-maturin_1.8.3.bb +++ b/meta/recipes-devtools/python/python3-maturin_1.8.3.bb | |||
@@ -10,7 +10,7 @@ SRC_URI[sha256sum] = "304762f86fd53a8031b1bf006d12572a2aa0a5235485031113195cc015 | |||
10 | 10 | ||
11 | S = "${WORKDIR}/maturin-${PV}" | 11 | S = "${WORKDIR}/maturin-${PV}" |
12 | 12 | ||
13 | CFLAGS += "-fdebug-prefix-map=${CARGO_HOME}=${TARGET_DBGSRC_DIR}/cargo_home" | 13 | CFLAGS += "-ffile-prefix-map=${CARGO_HOME}=${TARGET_DBGSRC_DIR}/cargo_home" |
14 | 14 | ||
15 | DEPENDS += "\ | 15 | DEPENDS += "\ |
16 | python3-setuptools-rust-native \ | 16 | python3-setuptools-rust-native \ |
diff --git a/meta/recipes-devtools/rust/cargo_1.85.1.bb b/meta/recipes-devtools/rust/cargo_1.85.1.bb index db18ecfda9..150c2d2b80 100644 --- a/meta/recipes-devtools/rust/cargo_1.85.1.bb +++ b/meta/recipes-devtools/rust/cargo_1.85.1.bb | |||
@@ -19,7 +19,7 @@ CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor" | |||
19 | 19 | ||
20 | inherit cargo pkgconfig | 20 | inherit cargo pkgconfig |
21 | 21 | ||
22 | DEBUG_PREFIX_MAP += "-fdebug-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}" | 22 | DEBUG_PREFIX_MAP += "-ffile-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}" |
23 | 23 | ||
24 | do_cargo_setup_snapshot () { | 24 | do_cargo_setup_snapshot () { |
25 | ${UNPACKDIR}/rust-snapshot-components/${CARGO_SNAPSHOT}/install.sh --prefix="${WORKDIR}/${CARGO_SNAPSHOT}" --disable-ldconfig | 25 | ${UNPACKDIR}/rust-snapshot-components/${CARGO_SNAPSHOT}/install.sh --prefix="${WORKDIR}/${CARGO_SNAPSHOT}" --disable-ldconfig |