glibc: Forward -ffile-prefix-map option to assembler flags
PATCH v2 1/2 glibc: Forward -ffile-prefix-map option to assembler flags
---
v2: Rebased
...le-prefix-map-from-CFLAGS-to-ASFLAGS.patch | 24 +++++++++++++++++++ meta/recipes-core/glibc/glibc_2.41.bb | 1 + 2 files changed, 25 insertions(+) create mode 100644 meta/recipes-core/glibc/glibc/0001-Propagate-ffile-prefix-map-from-CFLAGS-to-ASFLAGS.patch
meta/recipes-core/glibc/glibc/0001-Propagate-ffile-prefix-map-from-CFLAGS-to-ASFLAGS.patch new file +24 -0
@@ -0,0 +1,24 @@ +From 603e50d6b8ccadb32d59b0497f76629665c1794b Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Wed, 16 Apr 2025 19:51:01 -0700 +Subject: [PATCH] Propagate -ffile-prefix-map from CFLAGS to ASFLAGS. + +Upstream-Status: Submitted [https://sourceware.org/pipermail/libc-alpha/2025-April/165969.html] +Signed-off-by: Khem Raj <[email protected]> +--- + Makeconfig | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makeconfig b/Makeconfig +index e35c5cfe4e..7a19c731c6 100644 +--- a/Makeconfig ++++ b/Makeconfig +@@ -1176,7 +1176,7 @@ endif + + # The assembler can generate debug information too. + ifndef ASFLAGS +-ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS)) ++ASFLAGS := $(filter -g% -fdebug-prefix-map=% -ffile-prefix-map=%,$(CFLAGS)) + endif + override ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu) +
meta/recipes-core/glibc/glibc_2.41.bb +1 -0
@@ -54,6 +54,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ file://0022-Avoid-hardcoded-build-time-paths-in-the-output-binar.patch \ file://0023-tests-Skip-2-qemu-tests-that-can-hang-in-oe-selftest.patch \ file://0001-stdlib-Add-single-threaded-fast-path-to-rand.patch \ + file://0001-Propagate-ffile-prefix-map-from-CFLAGS-to-ASFLAGS.patch \ " S = "${WORKDIR}/git" B = "${WORKDIR}/build-${TARGET_SYS}"
PATCH 2/2 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/[email protected]/#10281
---
v2: Drop using --ffile-prefix in go
meta/conf/bitbake.conf | 14 +++++--------- meta/recipes-devtools/rust/cargo_1.85.1.bb | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-)
meta/conf/bitbake.conf +5 -9
@@ -652,15 +652,11 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} " ################################################################## TARGET_DBGSRC_DIR ?= "/usr/src/debug/${PN}/${PV}" # Beware: applied last to first -DEBUG_PREFIX_MAP ?= "-fcanon-prefix-map \ - -fmacro-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ - -fdebug-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ - -fmacro-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ - -fdebug-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ - -fdebug-prefix-map=${STAGING_DIR_HOST}= \ - -fmacro-prefix-map=${STAGING_DIR_HOST}= \ - -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ - -fmacro-prefix-map=${STAGING_DIR_NATIVE}= \ +DEBUG_PREFIX_MAP ?= "\ + -ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ + -ffile-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ + -ffile-prefix-map=${STAGING_DIR_HOST}= \ + -ffile-prefix-map=${STAGING_DIR_NATIVE}= \ " DEBUG_LEVELFLAG ?= "-g"
meta/recipes-devtools/rust/cargo_1.85.1.bb +1 -1
@@ -19,7 +19,7 @@ CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor" inherit cargo pkgconfig -DEBUG_PREFIX_MAP += "-fdebug-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}" +DEBUG_PREFIX_MAP += "-ffile-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}" do_cargo_setup_snapshot () { ${UNPACKDIR}/rust-snapshot-components/${CARGO_SNAPSHOT}/install.sh --prefix="${WORKDIR}/${CARGO_SNAPSHOT}" --disable-ldconfig
Re: [OE-core] [PATCH 2/2] bitbake.conf: Switch prefix mapping to use -ffile-prefix-map
Quoted 64 lines · Khem Raj via lists.openembedded.org
-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_MAPto 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/[email protected]/#10281
Signed-off-by Khem Raj <[email protected]>Cc Jacob Kroon <[email protected]>Cc Martin Jansa <[email protected]>---
v2: Drop using --ffile-prefix in gometa/conf/bitbake.conf | 14 +++++--------- meta/recipes-devtools/rust/cargo_1.85.1.bb | 2 +-
2 files changed, 6 insertions(+), 10 deletions(-)meta/conf/bitbake.conf +0
-0@@ -652,15 +652,11 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} " ##################################################################TARGET_DBGSRC_DIR ?= "
/usr/src/debug/${PN}/${PV}" # Beware: applied last to firstmeta/conf/bitbake.conf +5
-9-DEBUG_PREFIX_MAP ?= "-fcanon-prefix-map \ - -fmacro-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ - -fdebug-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ - -fmacro-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ - -fdebug-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ - -fdebug-prefix-map=${STAGING_DIR_HOST}= \ - -fmacro-prefix-map=${STAGING_DIR_HOST}= \ - -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ - -fmacro-prefix-map=${STAGING_DIR_NATIVE}= \ +DEBUG_PREFIX_MAP ?= "\ + -ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ + -ffile-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ + -ffile-prefix-map=${STAGING_DIR_HOST}= \ + -ffile-prefix-map=${STAGING_DIR_NATIVE}= \"
DEBUG_LEVELFLAG ?= "-g"meta/recipes-devtools/rust/cargo_1.85.1.bb +0
-0@@ -19,7 +19,7 @@ CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor"
inherit cargo pkgconfigmeta/recipes-devtools/rust/cargo_1.85.1.bb +1
-1-DEBUG_PREFIX_MAP += "-fdebug-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}" +DEBUG_PREFIX_MAP += "-ffile-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}"
Quoted 3 lines
do_cargo_setup_snapshot () {
${UNPACKDIR}/rust-snapshot-components/${CARGO_SNAPSHOT}/install.sh--prefix="${WORKDIR}/${CARGO_SNAPSHOT}" --disable-ldconfig
I'm a supporter of cleaning this up and doing this but I think we have a selftest failure that needs invesitgation:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/1469
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/1386
I'm thinking it comes from this patch, I'll need to confirm that though.
Cheers,
Richard
Re: [OE-core] [PATCH 2/2] bitbake.conf: Switch prefix mapping to use -ffile-prefix-map
Quoted 72 lines · Richard Purdie
Quoted 59 lines · Khem Raj via lists.openembedded.org
-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_MAPto 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/[email protected]/#10281
Signed-off-by Khem Raj <[email protected]>Cc Jacob Kroon <[email protected]>Cc Martin Jansa <[email protected]>---
v2: Drop using --ffile-prefix in gometa/conf/bitbake.conf | 14 +++++--------- meta/recipes-devtools/rust/cargo_1.85.1.bb | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-)meta/conf/bitbake.conf +5
-9@@ -652,15 +652,11 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} " ################################################################## TARGET_DBGSRC_DIR ?= "/usr/src/debug/${PN}/${PV}" # Beware: applied last to first -DEBUG_PREFIX_MAP ?= "-fcanon-prefix-map \ - -fmacro-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ - -fdebug-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ - -fmacro-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ - -fdebug-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ - -fdebug-prefix-map=${STAGING_DIR_HOST}= \ - -fmacro-prefix-map=${STAGING_DIR_HOST}= \ - -fdebug-prefix-map=${STAGING_DIR_NATIVE}= \ - -fmacro-prefix-map=${STAGING_DIR_NATIVE}= \ +DEBUG_PREFIX_MAP ?= "\ + -ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR} \ + -ffile-prefix-map=${B}=${TARGET_DBGSRC_DIR} \ + -ffile-prefix-map=${STAGING_DIR_HOST}= \ + -ffile-prefix-map=${STAGING_DIR_NATIVE}= \ " DEBUG_LEVELFLAG ?= "-g"meta/recipes-devtools/rust/cargo_1.85.1.bb +0
-0meta/recipes-devtools/rust/cargo_1.85.1.bb CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor" · line 25
Quoted 8 lines
meta/recipes-devtools/rust/cargo_1.85.1.bb +1
-1@@ -19,7 +19,7 @@ CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor" inherit cargo pkgconfig -DEBUG_PREFIX_MAP += "-fdebug-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}" +DEBUG_PREFIX_MAP += "-ffile-prefix-map=${RUSTSRC}/vendor=${TARGET_DBGSRC_DIR}" do_cargo_setup_snapshot () { ${UNPACKDIR}/rust-snapshot-components/${CARGO_SNAPSHOT}/install.sh --prefix="${WORKDIR}/${CARGO_SNAPSHOT}" --disable-ldconfigI'm a supporter of cleaning this up and doing this but I think we have a selftest failure that needs invesitgation:
Quoted 5 lines
https://autobuilder.yoctoproject.org/valkyrie/#/builders/23/builds/1469
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/1386I'm thinking it comes from this patch, I'll need to confirm that though.
I looked further and your suspicion is right. Its in copydebugsources function in package class that
we explicitly look for -fdebug-prefix-map in cflags to map the source file locations which ofcourse was failing now.
I have sent v3 with this fix and some more cleanups.
Quoted 3 lines
Cheers,
Richard