lto.inc: add DEBUG_PREFIX_MAP back to TARGET_LDFLAGS
PATCH 1/1 lto.inc: add DEBUG_PREFIX_MAP back to TARGET_LDFLAGS
From: Changqing Li <[email protected]>
DEBUG_PREFIX_MAP is appended to TARGET_LDFLAGS in commit [1] for fixing reproducible issue when LTO is enabled. It is removed in comit [2] since this commit causes cgo binary not reproducible. But actually, we still need this DEBUG_PREFIX_MAP in LDFLAGS when LTO enabled. So, only appened it when LTO is enabled. Refer [3] for the history, with this patch, patch [4] is also needed for cgo + lto enabled.
[1] https://git.openembedded.org/openembedded-core/commit/?id=fddaecc88979967d0e00e2fafdbaaabec030da9f
[2] https://git.openembedded.org/openembedded-core/commit/?id=1797741aad02b8bf429fac4b81e30cdda64b5448
[3] https://lists.openembedded.org/g/openembedded-core/topic/patch_bitbake_conf_remove/117408334
[4] https://lists.openembedded.org/g/openembedded-core/message/230059
--- meta/conf/distro/include/lto.inc | 1 + 1 file changed, 1 insertion(+)
meta/conf/distro/include/lto.inc +1 -0
@@ -49,5 +49,6 @@ LTO:toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flt SELECTED_OPTIMIZATION:append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" +TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${DEBUG_PREFIX_MAP}', '', d)}" SELECTED_OPTIMIZATION[vardeps] += "LTO LTOEXTRA"
Signature · 1 line
2.34.1
Quoted 24 lines · On Wed, 2026-02-04 at 13:26 +0800, [email protected] wrote:
From: Changqing Li <[email protected]>
DEBUG_PREFIX_MAPis appended toTARGET_LDFLAGSin commit [1] for fixing reproducible issue when LTO is enabled. It is removed in comit [2] since this commit causes cgo binary not reproducible. But actually, we still need thisDEBUG_PREFIX_MAPin LDFLAGS when LTO enabled. So, only appened it when LTO is enabled. Refer [3] for the history, with this patch, patch [4] is also needed for cgo + lto enabled.[1] https://git.openembedded.org/openembedded-core/commit/?id=fddaecc88979967d0e00e2fafdbaaabec030da9f
[2] https://git.openembedded.org/openembedded-core/commit/?id=1797741aad02b8bf429fac4b81e30cdda64b5448
[3] https://lists.openembedded.org/g/openembedded-core/topic/patch_bitbake_conf_remove/117408334
[4] https://lists.openembedded.org/g/openembedded-core/message/230059Signed-off-by Changqing Li <[email protected]>---
meta/conf/distro/include/lto.inc | 1 +1 file changed, 1 insertion(+)meta/conf/distro/include/lto.inc +0
-0@@ -49,5 +49,6 @@ LTO:toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flt
Quoted 6 lines
SELECTED_OPTIMIZATION:append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" +TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${DEBUG_PREFIX_MAP}', '', d)}"
SELECTED_OPTIMIZATION[vardeps] += "LTO LTOEXTRA"
We need a bit more information. Which version of gcc did you see this issue with?
gcc see this as a bug, for example they added this to fix it:
https://gcc.gnu.org/cgit/gcc/commit/?id=7cc2df084b7977653a9b59cbc34a9ad500ae619c
In:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101473#c21
"I think it is a bug - -fdebug-prefix-map should be fully reflected in the LTO IL and thus we should not end up creating un-remapped references to files (we should not create many references to files late anyway)."
i.e. it is a bug if we have to set this in LDFLAGS if I understand correctly. So we should file a bug with gcc about this, assuming you were using gcc 12 or later.
Cheers,
Richard
Quoted 25 lines · On Wed, Feb 4, 2026 at 2:26 AM <[email protected]> wrote:
From: Changqing Li <[email protected]>
DEBUG_PREFIX_MAPis appended toTARGET_LDFLAGSin commit [1] for fixing reproducible issue when LTO is enabled. It is removed in comit [2] since this commit causes cgo binary not reproducible. But actually, we still need thisDEBUG_PREFIX_MAPin LDFLAGS when LTO enabled. So, only appened it when LTO is enabled. Refer [3] for the history, with this patch, patch [4] is also needed for cgo + lto enabled.[1] https://git.openembedded.org/openembedded-core/commit/?id=fddaecc88979967d0e00e2fafdbaaabec030da9f
[2] https://git.openembedded.org/openembedded-core/commit/?id=1797741aad02b8bf429fac4b81e30cdda64b5448
[3] https://lists.openembedded.org/g/openembedded-core/topic/patch_bitbake_conf_remove/117408334
[4] https://lists.openembedded.org/g/openembedded-core/message/230059Signed-off-by Changqing Li <[email protected]>--- meta/conf/distro/include/lto.inc | 1 + 1 file changed, 1 insertion(+)meta/conf/distro/include/lto.inc +0
-0
meta/conf/distro/include/lto.inc LTO:toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flt · line 54
Quoted 6 lines
meta/conf/distro/include/lto.inc +1
-0@@ -49,5 +49,6 @@ LTO:toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flt SELECTED_OPTIMIZATION:append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" +TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${DEBUG_PREFIX_MAP}', '', d)}" SELECTED_OPTIMIZATION[vardeps] += "LTO LTOEXTRA"
As raised by Randolph in the previous thread
(https://lists.openembedded.org/g/openembedded-core/message/230469),
this will only fix the build for users that are enabling LTO in OE, but we still have quite a few recipes enabling LTO as part of the project meson/make/etc files (e.g. lxc) even when lto.inc is not used.
Thanks,
Ricardo
Quoted 31 lines · Ricardo de Araujo (Salveti)
Quoted 30 lines · On Wed, Feb 4, 2026 at 2:26 AM <[email protected]> wrote:
From: Changqing Li <[email protected]>
DEBUG_PREFIX_MAPis appended toTARGET_LDFLAGSin commit [1] for fixing reproducible issue when LTO is enabled. It is removed in comit [2] since this commit causes cgo binary not reproducible. But actually, we still need thisDEBUG_PREFIX_MAPin LDFLAGS when LTO enabled. So, only appened it when LTO is enabled. Refer [3] for the history, with this patch, patch [4] is also needed for cgo + lto enabled.[1] https://git.openembedded.org/openembedded-core/commit/?id=fddaecc88979967d0e00e2fafdbaaabec030da9f
[2] https://git.openembedded.org/openembedded-core/commit/?id=1797741aad02b8bf429fac4b81e30cdda64b5448
[3] https://lists.openembedded.org/g/openembedded-core/topic/patch_bitbake_conf_remove/117408334
[4] https://lists.openembedded.org/g/openembedded-core/message/230059Signed-off-by Changqing Li <[email protected]>---
meta/conf/distro/include/lto.inc | 1 +1 file changed, 1 insertion(+)meta/conf/distro/include/lto.inc +0
-0@@ -49,5 +49,6 @@ LTO:toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-fltSELECTED_OPTIMIZATION:append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" +TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${DEBUG_PREFIX_MAP}', '', d)}"
Quoted 7 lines
Quoted 1 line
SELECTED_OPTIMIZATION[vardeps] += "LTO LTOEXTRA"
As raised by Randolph in the previous thread
(https://lists.openembedded.org/g/openembedded-core/message/230469),
this will only fix the build for users that are enabling LTO in OE, but we still have quite a few recipes enabling LTO as part of the project meson/make/etc files (e.g. lxc) even when lto.inc is not used.
See my other reply. According to the bug report links where this was discussed, upstream think this is a bug in gcc/binutils itself and you shouldn't have to pass these options to the linker.
I think we do need to narrow down a test case for upstream and see if this really is a bug or not.
It may be we have to work around this in recipes that are forcing LTO unconditionally, I'd hope there aren't that many of them? Perhaps just force the include for those recipes?
Cheers,
Richard
Changqing Li via lists.openembedded.org schrieb am Mi 04. Feb, 13:26 (+0800):
Quoted 8 lines
From: Changqing Li <[email protected]>
DEBUG_PREFIX_MAPis appended toTARGET_LDFLAGSin commit [1] for fixing reproducible issue when LTO is enabled. It is removed in comit [2] since this commit causes cgo binary not reproducible. But actually, we still need thisDEBUG_PREFIX_MAPin LDFLAGS when LTO enabled. So, only appened it when LTO is enabled. Refer [3] for the history, with this patch, patch [4] is also needed for cgo + lto enabled.
Gentle ping. This patch is missing, otherwise QA check buildpaths matches in nearly all packages.
But this still leaves some packages with buildpaths, because there's a bug in gcc that it does not apply -ffile-prefix-map:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124581
meta/conf/distro/include/lto.inc LTO:toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flt · line 52
Quoted 9 lines
meta/conf/distro/include/lto.inc +1
-0@@ -49,5 +49,6 @@ LTO:toolchain-clang = "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flt SELECTED_OPTIMIZATION:append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" +TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${DEBUG_PREFIX_MAP}', '', d)}"
Possibly, I would join these lines.
Best regards Jörg
Signature · 6 lines
Navimatix GmbH T: 03641 - 327 99 0 Tatzendpromenade 2 F: 03641 - 526 306 07745 Jena www.navimatix.de Geschäftsführer: Steffen Späthe, Jan Rommeley Registergericht: Amtsgericht Jena, HRB 501480
1. Hello,
Quoted 15 lines · Jörg Sommer via lists.openembedded.org
Changqing Li via lists.openembedded.org schrieb am Mi 04. Feb, 13:26 (+0800):
Quoted 12 lines
From: Changqing Li <[email protected]>
DEBUG_PREFIX_MAPis appended toTARGET_LDFLAGSin commit [1] for fixing
reproducible issue when LTO is enabled. It is removed in comit [2] since
this commit causes cgo binary not reproducible. But actually, we still
need thisDEBUG_PREFIX_MAPin LDFLAGS when LTO enabled. So, only appened
it when LTO is enabled. Refer [3] for the history, with this patch, patch [4] is also needed for cgo + lto enabled.
Quoted 3 lines
Gentle ping. This patch is missing, otherwise QA check buildpaths matches in
nearly all packages.
I confirm this patch is required to fix QA check build paths for a few packages.
Kind regards,
Thomas Perrot
Quoted 26 lines
But this still leaves some packages with buildpaths, because there's a bug
in gcc that it does not apply -ffile-prefix-map:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124581Quoted 7 lines
meta/conf/distro/include/lto.inc +0
-0@@ -49,5 +49,6 @@ LTO:toolchain-clang ="${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flt
Quoted 8 lines
SELECTED_OPTIMIZATION:append = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${LTO}', '', d)}" +TARGET_LDFLAGS:append:class-target = "${@bb.utils.contains('DISTRO_FEATURES', 'lto', ' ${DEBUG_PREFIX_MAP}', '', d)}"Possibly, I would join these lines.
Best regards Jörg
Signature · 2 lines
Thomas Perrot, Bootlin Embedded Linux and kernel engineering https://bootlin.com
Quoted 22 lines · Thomas Perrot
1. Hello,
Quoted 18 lines · Jörg Sommer via lists.openembedded.org
Changqing Li via lists.openembedded.org schrieb am Mi 04. Feb, 13:26
(+0800):Quoted 14 lines
From: Changqing Li <[email protected]>
DEBUG_PREFIX_MAPis appended toTARGET_LDFLAGSin commit [1] for fixing
reproducible issue when LTO is enabled. It is removed in comit
[2]
since
this commit causes cgo binary not reproducible. But actually, we still
need thisDEBUG_PREFIX_MAPin LDFLAGS when LTO enabled. So, only appened
it when LTO is enabled. Refer [3] for the history, with this patch,
patch [4] is also needed for cgo + lto enabled.
Quoted 6 lines
Quoted 3 lines
Gentle ping. This patch is missing, otherwise QA check buildpaths matches in
nearly all packages.I confirm this patch is required to fix QA check build paths for a few packages.
Can someone please work out a smaller reproducer to provide to upstream gcc/binutils so we can try and get the underlying bug fixed?
Thanks,
Richard
Richard Purdie schrieb am Mo 30. Mär, 11:18 (+0100):
Quoted 27 lines · Thomas Perrot
Quoted 26 lines
1. Hello,
Quoted 21 lines · Jörg Sommer via lists.openembedded.org
Changqing Li via lists.openembedded.org schrieb am Mi 04. Feb, 13:26
(+0800):Quoted 14 lines
From: Changqing Li <[email protected]>
DEBUG_PREFIX_MAPis appended toTARGET_LDFLAGSin commit [1] for fixing
reproducible issue when LTO is enabled. It is removed in comit
[2]
since
this commit causes cgo binary not reproducible. But actually, we still
need thisDEBUG_PREFIX_MAPin LDFLAGS when LTO enabled. So, only appened
it when LTO is enabled. Refer [3] for the history, with this patch,
patch [4] is also needed for cgo + lto enabled.Gentle ping. This patch is missing, otherwise QA check buildpaths matches in
nearly all packages.
Quoted 5 lines
Quoted 2 lines
I confirm this patch is required to fix QA check build paths for a few packages.
Can someone please work out a smaller reproducer to provide to upstream gcc/binutils so we can try and get the underlying bug fixed?
I've send some simple test cases in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124581
Best regards Jörg
Signature · 6 lines
Navimatix GmbH T: 03641 - 327 99 0 Tatzendpromenade 2 F: 03641 - 526 306 07745 Jena www.navimatix.de Geschäftsführer: Steffen Späthe, Jan Rommeley Registergericht: Amtsgericht Jena, HRB 501480
Quoted 6 lines · Jörg Sommer
Richard Purdie schrieb am Mo 30. Mär, 11:18 (+0100):
Quoted 5 lines · Thomas Perrot
Quoted 4 lines
Quoted 1 line · Jörg Sommer via lists.openembedded.org
Changqing Li via lists.openembedded.org schrieb am Mi 04. Feb,
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
I confirm this patch is required to fix QA check build paths for a few packages.
Can someone please work out a smaller reproducer to provide to upstream gcc/binutils so we can try and get the underlying bug fixed?
I've send some simple test cases in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124581
Thanks, I've tried to raise awareness in the other bug.
Cheers,
Richard