Skip to contentSkip to conversation

bitbake.conf: Add -fcanon-prefix-map to DEBUG_PREFIX_MAP

PATCH In review Khem Raj 4 participants 6 messages Apr 28, 2023 – May 27, 2023

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 bitbake.conf: Add -fcanon-prefix-map to DEBUG_PREFIX_MAP

This should help canonicalize the relative paths and symlinks during cross compile, -fcanon-prefix-map is newly added in gcc-13+ [1]

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108464#c8

---
 meta/conf/bitbake.conf | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/conf/bitbake.conf +2 -1
index d94ffe1df9..453bef37a9 100644
@@ -644,7 +644,8 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} "
 # Optimization flags.
 ##################################################################
 # Beware: applied last to first
-DEBUG_PREFIX_MAP ?= "-fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
+DEBUG_PREFIX_MAP ?= "-fcanon-prefix-map \
+ -fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
  -fdebug-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
  -fmacro-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
  -fdebug-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
Signature · 1 line
2.40.1
#1 lore raw

Do you already have a follow-up change for meta-clang which seems to be broken by this change?

clang-16: error: unknown argument: '-fcanon-prefix-map'

Quoted 40 lines · Khem Raj

This should help canonicalize the relative paths and symlinks during cross compile, -fcanon-prefix-map is newly added in gcc-13+ [1]

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108464#c8

---
 meta/conf/bitbake.conf | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/conf/bitbake.conf +0 -0
index d94ffe1df9..453bef37a9 100644
@@ -644,7 +644,8 @@ EXTRA_OEMAKE:prepend:task-install =

"${PARALLEL_MAKEINST} "
# Optimization flags.
##################################################################
# Beware: applied last to first
-DEBUG_PREFIX_MAP ?= "-fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
+DEBUG_PREFIX_MAP ?= "-fcanon-prefix-map \
+ -fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
-fdebug-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
-fmacro-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
-fdebug-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
--
2.40.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#180504):
https://lists.openembedded.org/g/openembedded-core/message/180504
Mute This Topic: https://lists.openembedded.org/mt/98551742/3617156
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

author
#2 lore raw
Quoted 5 lines · Martin Jansa

Do you already have a follow-up change for meta-clang which seems to be broken by this change?

clang-16: error: unknown argument: '-fcanon-prefix-map'

yes
https://github.com/kraj/meta-clang/pull/782

Quoted 40 lines · Khem Raj
Quoted 25 lines

This should help canonicalize the relative paths and symlinks during cross compile, -fcanon-prefix-map is newly added in gcc-13+ [1]

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108464#c8

---
 meta/conf/bitbake.conf | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/conf/bitbake.conf +2 -2
index d94ffe1df9..453bef37a9 100644
@@ -644,7 +644,8 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} "
 # Optimization flags.
 ##################################################################
 # Beware: applied last to first
-DEBUG_PREFIX_MAP ?= "-fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
+DEBUG_PREFIX_MAP ?= "-fcanon-prefix-map \
+ -fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
  -fdebug-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
  -fmacro-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
  -fdebug-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
--
Quoted 5 lines

2.40.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#180526): https://lists.openembedded.org/g/openembedded-core/message/180526
Mute This Topic: https://lists.openembedded.org/mt/98551742/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw
In reply to Khem Raj
Quoted 15 lines · Khem Raj

This should help canonicalize the relative paths and symlinks during cross compile, -fcanon-prefix-map is newly added in gcc-13+ [1]

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108464#c8

---
  meta/conf/bitbake.conf | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
meta/conf/bitbake.conf +0 -0
index d94ffe1df9..453bef37a9 100644

meta/conf/bitbake.conf EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} " · line 651

Quoted 9 lines
meta/conf/bitbake.conf +2 -1
@@ -644,7 +644,8 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} "
  # Optimization flags.
  ##################################################################
  # Beware: applied last to first
-DEBUG_PREFIX_MAP ?= "-fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
+DEBUG_PREFIX_MAP ?= "-fcanon-prefix-map \
+ -fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
   -fdebug-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
   -fmacro-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
   -fdebug-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \

Maybe we can take the opportunity to also cleanup DEBUG_PREFIX_MAP by replacing debug/macro/canon with a single -ffile-prefix-map ?

From the gcc 13.1.1 manpage:

Quoted 6 lines

-ffile-prefix-map=old=new
When compiling files residing in directory old, record any references to them in the result of the compilation as if the files resided in directory new instead. Specifying this option is equivalent to specifying all the individual -f*-prefix-map options. This can be used to make reproducible builds that are location independent. Directories referenced by directives are not affected by these options. See also -fmacro-prefix-map, -fdebug-prefix-map, -fprofile-prefix-map and -fcanon-prefix-map.

Jacob

author
#4 lore raw
Quoted 21 lines · Jacob Kroon
Quoted 19 lines · Khem Raj

This should help canonicalize the relative paths and symlinks during cross compile, -fcanon-prefix-map is newly added in gcc-13+ [1]

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108464#c8

---
  meta/conf/bitbake.conf | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
meta/conf/bitbake.conf +1 -1
index d94ffe1df9..453bef37a9 100644
@@ -644,7 +644,8 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} "
  # Optimization flags.
  ##################################################################
  # Beware: applied last to first
-DEBUG_PREFIX_MAP ?= "-fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
+DEBUG_PREFIX_MAP ?= "-fcanon-prefix-map \
Quoted 8 lines

meta/conf/bitbake.conf EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} " · line 651

Quoted 5 lines
meta/conf/bitbake.conf +1 -0
+ -fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
   -fdebug-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
   -fmacro-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
   -fdebug-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \

Maybe we can take the opportunity to also cleanup DEBUG_PREFIX_MAP by replacing debug/macro/canon with a single -ffile-prefix-map ?

Yes, somewhere I had such a patch and I dropped it from my queue IIRC it was for clang alone maybe
but it is not a simple replacement, we have to adjust
some recipes to this option,

Quoted 11 lines

From the gcc 13.1.1 manpage:

Quoted 6 lines

-ffile-prefix-map=old=new
When compiling files residing in directory old, record any references to them in the result of the compilation as if the files resided in directory new instead. Specifying this option is equivalent to specifying all the individual -f*-prefix-map options. This can be used to make reproducible builds that are location independent. Directories referenced by directives are not affected by these options. See also -fmacro-prefix-map, -fdebug-prefix-map, -fprofile-prefix-map and -fcanon-prefix-map.

Jacob

#5 lore raw
In reply to Jacob Kroon
Quoted 29 lines · Jacob Kroon
Quoted 15 lines · Khem Raj

This should help canonicalize the relative paths and symlinks during cross compile, -fcanon-prefix-map is newly added in gcc-13+ [1]

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108464#c8

---
  meta/conf/bitbake.conf | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
meta/conf/bitbake.conf +0 -0
index d94ffe1df9..453bef37a9 100644

meta/conf/bitbake.conf EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} " · line 651

Quoted 9 lines
meta/conf/bitbake.conf +2 -1
@@ -644,7 +644,8 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} "
  # Optimization flags.
  ##################################################################
  # Beware: applied last to first
-DEBUG_PREFIX_MAP ?= "-fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
+DEBUG_PREFIX_MAP ?= "-fcanon-prefix-map \
+ -fmacro-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
   -fdebug-prefix-map=${S}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
   -fmacro-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \
   -fdebug-prefix-map=${B}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR} \

Maybe we can take the opportunity to also cleanup DEBUG_PREFIX_MAP by replacing debug/macro/canon with a single -ffile-prefix-map ?

Quoted 9 lines

From the gcc 13.1.1 manpage:

Quoted 6 lines

-ffile-prefix-map=old=new
When compiling files residing in directory old, record any references to them in the result of the compilation as if the files resided in directory new instead. Specifying this option is equivalent to specifying all the individual -f*-prefix-map options. This can be used to make reproducible builds that are location independent. Directories referenced by directives are not affected by these options. See also -fmacro-prefix-map, -fdebug-prefix-map, -fprofile-prefix-map and -fcanon-prefix-map.

Sadly not, I'd wondered about this too and tried it fairly recently.

From memory, the issue is that there are tools which only accept one of these (binutils as maybe?) and if we switch, we lose some set of the prefix mapping which causes build reproducible issues.

I'd love to do it but only once it doesn't break things. It may be possible to pass in different options to the different tools but at that point it started looking too complex for the time I had available to test.

Cheers,

Richard