diff mbox series

[1/2] bitbake.conf, gcc toolchain: add -fcanon-prefix-map to map-prefixes

Message ID 20251120121947.3473848-2-skandigraun@gmail.com
State Accepted, archived
Commit 3dbc4a79f01ebfc54da024c1460c06772659088d
Headers show
Series -fcanon-file-prefix and cc-rs compiler flag mixing | expand

Commit Message

Gyorgy Sarvari Nov. 20, 2025, 12:19 p.m. UTC
This patch adds -fcanon-prefix-map to the list of compile file-prefixes
list in case at least gcc 13 is used (it's a gcc-only flag).

This flag used to be part of this list in the past, but was removed with [1].

Since then the source file paths are not canonicalized, which makes
the system to miss some (and sometimes all) source files to include
in the corresponding -src packages. As an example sqlite3 and audiofile
(from meta-oe) produces empty src packages, mostly due to the pathes:
they frequently use relative paths that don't match up with the
absolute path specified in the file-preifx map:
`pwd`/../../foo.cpp and ${S}/foo.cpp might refer to the same file, but
the first one won't match the prefix-map, so it is omitted.

This patch adds this option again with gcc: for class-target it is uses
always, and for class-native it is used when the host gcc is at least
version 13.

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 meta/classes/toolchain/gcc-native.bbclass | 3 +++
 meta/classes/toolchain/gcc.bbclass        | 2 ++
 meta/conf/bitbake.conf                    | 2 +-
 3 files changed, 6 insertions(+), 1 deletion(-)

Comments

Khem Raj Nov. 20, 2025, 8:28 p.m. UTC | #1
Looks good to me. Covers all cases that I brought up.

On Thu, Nov 20, 2025 at 4:19 AM Gyorgy Sarvari via lists.openembedded.org
<skandigraun=gmail.com@lists.openembedded.org> wrote:

> This patch adds -fcanon-prefix-map to the list of compile file-prefixes
> list in case at least gcc 13 is used (it's a gcc-only flag).
>
> This flag used to be part of this list in the past, but was removed with
> [1].
>
> Since then the source file paths are not canonicalized, which makes
> the system to miss some (and sometimes all) source files to include
> in the corresponding -src packages. As an example sqlite3 and audiofile
> (from meta-oe) produces empty src packages, mostly due to the pathes:
> they frequently use relative paths that don't match up with the
> absolute path specified in the file-preifx map:
> `pwd`/../../foo.cpp and ${S}/foo.cpp might refer to the same file, but
> the first one won't match the prefix-map, so it is omitted.
>
> This patch adds this option again with gcc: for class-target it is uses
> always, and for class-native it is used when the host gcc is at least
> version 13.
>
> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
> ---
>  meta/classes/toolchain/gcc-native.bbclass | 3 +++
>  meta/classes/toolchain/gcc.bbclass        | 2 ++
>  meta/conf/bitbake.conf                    | 2 +-
>  3 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/meta/classes/toolchain/gcc-native.bbclass
> b/meta/classes/toolchain/gcc-native.bbclass
> index a708bd0389..8708ad0211 100644
> --- a/meta/classes/toolchain/gcc-native.bbclass
> +++ b/meta/classes/toolchain/gcc-native.bbclass
> @@ -13,3 +13,6 @@ BUILD_OBJDUMP = "${BUILD_PREFIX}objdump"
>  BUILD_NM = "${BUILD_PREFIX}nm"
>  BUILD_READELF = "${BUILD_PREFIX}readelf"
>
> +# gcc started to support -fcanon-prefix-map from version 13
> +DEBUG_PREFIX_MAP_EXTRA:class-native = \
> +    "${@'-fcanon-prefix-map' if
> bb.utils.vercmp_string_op(oe.utils.get_host_gcc_version(d), '13.0.0', '>=')
> else ''}"
> diff --git a/meta/classes/toolchain/gcc.bbclass
> b/meta/classes/toolchain/gcc.bbclass
> index a5adb5ca37..0ed49ba892 100644
> --- a/meta/classes/toolchain/gcc.bbclass
> +++ b/meta/classes/toolchain/gcc.bbclass
> @@ -30,4 +30,6 @@
> PREFERRED_PROVIDER_virtual/nativesdk-cross-cc:class-cross-canadian =
> "gcc-crosss
>  PREFERRED_PROVIDER_virtual/nativesdk-cross-c++:class-cross-canadian =
> "gcc-crosssdk-${SDK_SYS}"
>  PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs:class-cross-canadian =
> "nativesdk-gcc-runtime"
>
> +DEBUG_PREFIX_MAP_EXTRA = "-fcanon-prefix-map"
> +
>  TCOVERRIDE = "toolchain-gcc"
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index 5406e542db..600d4baffb 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -650,7 +650,7 @@ EXTRA_OEMAKE:prepend:task-install =
> "${PARALLEL_MAKEINST} "
>  ##################################################################
>  TARGET_DBGSRC_DIR ?= "/usr/src/debug/${PN}/${PV}"
>  # Beware: applied last to first
> -DEBUG_PREFIX_MAP ?= "\
> +DEBUG_PREFIX_MAP ?= "${DEBUG_PREFIX_MAP_EXTRA} \
>   -ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR} \
>   -ffile-prefix-map=${B}=${TARGET_DBGSRC_DIR} \
>   -ffile-prefix-map=${STAGING_DIR_HOST}= \
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#226618):
> https://lists.openembedded.org/g/openembedded-core/message/226618
> Mute This Topic: https://lists.openembedded.org/mt/116389619/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Richard Purdie Nov. 20, 2025, 10:48 p.m. UTC | #2
On Thu, 2025-11-20 at 13:19 +0100, Gyorgy Sarvari via lists.openembedded.org wrote:
> This patch adds -fcanon-prefix-map to the list of compile file-prefixes
> list in case at least gcc 13 is used (it's a gcc-only flag).
> 
> This flag used to be part of this list in the past, but was removed with [1].
> 
> Since then the source file paths are not canonicalized, which makes
> the system to miss some (and sometimes all) source files to include
> in the corresponding -src packages. As an example sqlite3 and audiofile
> (from meta-oe) produces empty src packages, mostly due to the pathes:
> they frequently use relative paths that don't match up with the
> absolute path specified in the file-preifx map:
> `pwd`/../../foo.cpp and ${S}/foo.cpp might refer to the same file, but
> the first one won't match the prefix-map, so it is omitted.
> 
> This patch adds this option again with gcc: for class-target it is uses
> always, and for class-native it is used when the host gcc is at least
> version 13.
> 
> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
> ---
>  meta/classes/toolchain/gcc-native.bbclass | 3 +++
>  meta/classes/toolchain/gcc.bbclass        | 2 ++
>  meta/conf/bitbake.conf                    | 2 +-
>  3 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/toolchain/gcc-native.bbclass b/meta/classes/toolchain/gcc-native.bbclass
> index a708bd0389..8708ad0211 100644
> --- a/meta/classes/toolchain/gcc-native.bbclass
> +++ b/meta/classes/toolchain/gcc-native.bbclass
> @@ -13,3 +13,6 @@ BUILD_OBJDUMP = "${BUILD_PREFIX}objdump"
>  BUILD_NM = "${BUILD_PREFIX}nm"
>  BUILD_READELF = "${BUILD_PREFIX}readelf"
>  
> +# gcc started to support -fcanon-prefix-map from version 13
> +DEBUG_PREFIX_MAP_EXTRA:class-native = \
> +    "${@'-fcanon-prefix-map' if bb.utils.vercmp_string_op(oe.utils.get_host_gcc_version(d), '13.0.0', '>=') else ''}"
> diff --git a/meta/classes/toolchain/gcc.bbclass b/meta/classes/toolchain/gcc.bbclass
> index a5adb5ca37..0ed49ba892 100644
> --- a/meta/classes/toolchain/gcc.bbclass
> +++ b/meta/classes/toolchain/gcc.bbclass
> @@ -30,4 +30,6 @@ PREFERRED_PROVIDER_virtual/nativesdk-cross-cc:class-cross-canadian = "gcc-crosss
>  PREFERRED_PROVIDER_virtual/nativesdk-cross-c++:class-cross-canadian = "gcc-crosssdk-${SDK_SYS}"
>  PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs:class-cross-canadian = "nativesdk-gcc-runtime"
>  
> +DEBUG_PREFIX_MAP_EXTRA = "-fcanon-prefix-map"
> +
>  TCOVERRIDE = "toolchain-gcc"
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index 5406e542db..600d4baffb 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -650,7 +650,7 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} "
>  ##################################################################
>  TARGET_DBGSRC_DIR ?= "/usr/src/debug/${PN}/${PV}"
>  # Beware: applied last to first
> -DEBUG_PREFIX_MAP ?= "\
> +DEBUG_PREFIX_MAP ?= "${DEBUG_PREFIX_MAP_EXTRA} \
>   -ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR} \
>   -ffile-prefix-map=${B}=${TARGET_DBGSRC_DIR} \
>   -ffile-prefix-map=${STAGING_DIR_HOST}= \
> 

I think we should do something like this patch but just with only the
target pieces, not the native ones.

The gcc version check is a slow function call since it execs a command
and we really don't want a call like that dropped inside a variable.

native components don't have -src packages so I'm not sure we need that
element of this. The simplest thing would be to drop that piece.

This issue was identified as a release blocker so I'll probably hack
the patch and put something into master-next for testing overnight.

Cheers,

Richard
Khem Raj Nov. 20, 2025, 10:58 p.m. UTC | #3
On Thu, Nov 20, 2025 at 2:49 PM Richard Purdie via lists.openembedded.org
<richard.purdie=linuxfoundation.org@lists.openembedded.org> wrote:

> On Thu, 2025-11-20 at 13:19 +0100, Gyorgy Sarvari via
> lists.openembedded.org wrote:
> > This patch adds -fcanon-prefix-map to the list of compile file-prefixes
> > list in case at least gcc 13 is used (it's a gcc-only flag).
> >
> > This flag used to be part of this list in the past, but was removed with
> [1].
> >
> > Since then the source file paths are not canonicalized, which makes
> > the system to miss some (and sometimes all) source files to include
> > in the corresponding -src packages. As an example sqlite3 and audiofile
> > (from meta-oe) produces empty src packages, mostly due to the pathes:
> > they frequently use relative paths that don't match up with the
> > absolute path specified in the file-preifx map:
> > `pwd`/../../foo.cpp and ${S}/foo.cpp might refer to the same file, but
> > the first one won't match the prefix-map, so it is omitted.
> >
> > This patch adds this option again with gcc: for class-target it is uses
> > always, and for class-native it is used when the host gcc is at least
> > version 13.
> >
> > Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
> > ---
> >  meta/classes/toolchain/gcc-native.bbclass | 3 +++
> >  meta/classes/toolchain/gcc.bbclass        | 2 ++
> >  meta/conf/bitbake.conf                    | 2 +-
> >  3 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/meta/classes/toolchain/gcc-native.bbclass
> b/meta/classes/toolchain/gcc-native.bbclass
> > index a708bd0389..8708ad0211 100644
> > --- a/meta/classes/toolchain/gcc-native.bbclass
> > +++ b/meta/classes/toolchain/gcc-native.bbclass
> > @@ -13,3 +13,6 @@ BUILD_OBJDUMP = "${BUILD_PREFIX}objdump"
> >  BUILD_NM = "${BUILD_PREFIX}nm"
> >  BUILD_READELF = "${BUILD_PREFIX}readelf"
> >
> > +# gcc started to support -fcanon-prefix-map from version 13
> > +DEBUG_PREFIX_MAP_EXTRA:class-native = \
> > +    "${@'-fcanon-prefix-map' if
> bb.utils.vercmp_string_op(oe.utils.get_host_gcc_version(d), '13.0.0', '>=')
> else ''}"
> > diff --git a/meta/classes/toolchain/gcc.bbclass
> b/meta/classes/toolchain/gcc.bbclass
> > index a5adb5ca37..0ed49ba892 100644
> > --- a/meta/classes/toolchain/gcc.bbclass
> > +++ b/meta/classes/toolchain/gcc.bbclass
> > @@ -30,4 +30,6 @@
> PREFERRED_PROVIDER_virtual/nativesdk-cross-cc:class-cross-canadian =
> "gcc-crosss
> >  PREFERRED_PROVIDER_virtual/nativesdk-cross-c++:class-cross-canadian =
> "gcc-crosssdk-${SDK_SYS}"
> >  PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs:class-cross-canadian
> = "nativesdk-gcc-runtime"
> >
> > +DEBUG_PREFIX_MAP_EXTRA = "-fcanon-prefix-map"
> > +
> >  TCOVERRIDE = "toolchain-gcc"
> > diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> > index 5406e542db..600d4baffb 100644
> > --- a/meta/conf/bitbake.conf
> > +++ b/meta/conf/bitbake.conf
> > @@ -650,7 +650,7 @@ EXTRA_OEMAKE:prepend:task-install =
> "${PARALLEL_MAKEINST} "
> >  ##################################################################
> >  TARGET_DBGSRC_DIR ?= "/usr/src/debug/${PN}/${PV}"
> >  # Beware: applied last to first
> > -DEBUG_PREFIX_MAP ?= "\
> > +DEBUG_PREFIX_MAP ?= "${DEBUG_PREFIX_MAP_EXTRA} \
> >   -ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR} \
> >   -ffile-prefix-map=${B}=${TARGET_DBGSRC_DIR} \
> >   -ffile-prefix-map=${STAGING_DIR_HOST}= \
> >
>
> I think we should do something like this patch but just with only the
> target pieces, not the native ones.
>

cc-rs is perhaps the problematic bit, if thats sorted with the second patch
then I agree, we can keep it from target alone.


>
> The gcc version check is a slow function call since it execs a command
> and we really don't want a call like that dropped inside a variable.
>
> native components don't have -src packages so I'm not sure we need that
> element of this. The simplest thing would be to drop that piece.
>
> This issue was identified as a release blocker so I'll probably hack
> the patch and put something into master-next for testing overnight.
>
> Cheers,
>
> Richard
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#226641):
> https://lists.openembedded.org/g/openembedded-core/message/226641
> Mute This Topic: https://lists.openembedded.org/mt/116389619/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Gyorgy Sarvari Nov. 21, 2025, 8:30 a.m. UTC | #4
Please try the v2 of the cc-rs patch - I see that v1 got into
master-next, but it will fail selftests.


On 11/20/25 23:48, Richard Purdie wrote:
> On Thu, 2025-11-20 at 13:19 +0100, Gyorgy Sarvari via lists.openembedded.org wrote:
>> This patch adds -fcanon-prefix-map to the list of compile file-prefixes
>> list in case at least gcc 13 is used (it's a gcc-only flag).
>>
>> This flag used to be part of this list in the past, but was removed with [1].
>>
>> Since then the source file paths are not canonicalized, which makes
>> the system to miss some (and sometimes all) source files to include
>> in the corresponding -src packages. As an example sqlite3 and audiofile
>> (from meta-oe) produces empty src packages, mostly due to the pathes:
>> they frequently use relative paths that don't match up with the
>> absolute path specified in the file-preifx map:
>> `pwd`/../../foo.cpp and ${S}/foo.cpp might refer to the same file, but
>> the first one won't match the prefix-map, so it is omitted.
>>
>> This patch adds this option again with gcc: for class-target it is uses
>> always, and for class-native it is used when the host gcc is at least
>> version 13.
>>
>> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
>> ---
>>  meta/classes/toolchain/gcc-native.bbclass | 3 +++
>>  meta/classes/toolchain/gcc.bbclass        | 2 ++
>>  meta/conf/bitbake.conf                    | 2 +-
>>  3 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/meta/classes/toolchain/gcc-native.bbclass b/meta/classes/toolchain/gcc-native.bbclass
>> index a708bd0389..8708ad0211 100644
>> --- a/meta/classes/toolchain/gcc-native.bbclass
>> +++ b/meta/classes/toolchain/gcc-native.bbclass
>> @@ -13,3 +13,6 @@ BUILD_OBJDUMP = "${BUILD_PREFIX}objdump"
>>  BUILD_NM = "${BUILD_PREFIX}nm"
>>  BUILD_READELF = "${BUILD_PREFIX}readelf"
>>  
>> +# gcc started to support -fcanon-prefix-map from version 13
>> +DEBUG_PREFIX_MAP_EXTRA:class-native = \
>> +    "${@'-fcanon-prefix-map' if bb.utils.vercmp_string_op(oe.utils.get_host_gcc_version(d), '13.0.0', '>=') else ''}"
>> diff --git a/meta/classes/toolchain/gcc.bbclass b/meta/classes/toolchain/gcc.bbclass
>> index a5adb5ca37..0ed49ba892 100644
>> --- a/meta/classes/toolchain/gcc.bbclass
>> +++ b/meta/classes/toolchain/gcc.bbclass
>> @@ -30,4 +30,6 @@ PREFERRED_PROVIDER_virtual/nativesdk-cross-cc:class-cross-canadian = "gcc-crosss
>>  PREFERRED_PROVIDER_virtual/nativesdk-cross-c++:class-cross-canadian = "gcc-crosssdk-${SDK_SYS}"
>>  PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs:class-cross-canadian = "nativesdk-gcc-runtime"
>>  
>> +DEBUG_PREFIX_MAP_EXTRA = "-fcanon-prefix-map"
>> +
>>  TCOVERRIDE = "toolchain-gcc"
>> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
>> index 5406e542db..600d4baffb 100644
>> --- a/meta/conf/bitbake.conf
>> +++ b/meta/conf/bitbake.conf
>> @@ -650,7 +650,7 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} "
>>  ##################################################################
>>  TARGET_DBGSRC_DIR ?= "/usr/src/debug/${PN}/${PV}"
>>  # Beware: applied last to first
>> -DEBUG_PREFIX_MAP ?= "\
>> +DEBUG_PREFIX_MAP ?= "${DEBUG_PREFIX_MAP_EXTRA} \
>>   -ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR} \
>>   -ffile-prefix-map=${B}=${TARGET_DBGSRC_DIR} \
>>   -ffile-prefix-map=${STAGING_DIR_HOST}= \
>>
> I think we should do something like this patch but just with only the
> target pieces, not the native ones.
>
> The gcc version check is a slow function call since it execs a command
> and we really don't want a call like that dropped inside a variable.
>
> native components don't have -src packages so I'm not sure we need that
> element of this. The simplest thing would be to drop that piece.
>
> This issue was identified as a release blocker so I'll probably hack
> the patch and put something into master-next for testing overnight.
>
> Cheers,
>
> Richard
Martin Jansa Nov. 21, 2025, 8:57 a.m. UTC | #5
I think we also need weak assignment DEBUG_PREFIX_MAP_EXTRA to empty
in bitbake.conf, because the unexpanded variable with clang instead of
gcc (with v2 from ML as well as the version currently in master-next)
causes:

meta-oe/meta-oe/recipes-extended/ostree/ostree_2024.10.bb: Error
during parse shell code, the last 5 lines are:
                fi
        else
                bbfatal "no configure script found at $cfgscript"
        fi

WARNING: meta-oe/meta-oe/recipes-extended/ostree/ostree_2024.10.bb:
Exception during build_dependencies for oe_runconf
WARNING: meta-oe/meta-oe/recipes-extended/ostree/ostree_2024.10.bb:
Error during finalise of
meta-oe/meta-oe/recipes-extended/ostree/ostree_2024.10.bb
ERROR: Unable to parse meta-oe/meta-oe/recipes-extended/ostree/ostree_2024.10.bb
Traceback (most recent call last):
  File "bitbake/lib/bb/cooker.py", line 2312, in parse_next
    raise result
bb.pysh.pyshlex.NeedMore

ERROR: Parsing halted due to errors, see error messages above

On Fri, Nov 21, 2025 at 9:30 AM Gyorgy Sarvari via
lists.openembedded.org <skandigraun=gmail.com@lists.openembedded.org>
wrote:
>
> Please try the v2 of the cc-rs patch - I see that v1 got into
> master-next, but it will fail selftests.
>
>
> On 11/20/25 23:48, Richard Purdie wrote:
> > On Thu, 2025-11-20 at 13:19 +0100, Gyorgy Sarvari via lists.openembedded.org wrote:
> >> This patch adds -fcanon-prefix-map to the list of compile file-prefixes
> >> list in case at least gcc 13 is used (it's a gcc-only flag).
> >>
> >> This flag used to be part of this list in the past, but was removed with [1].
> >>
> >> Since then the source file paths are not canonicalized, which makes
> >> the system to miss some (and sometimes all) source files to include
> >> in the corresponding -src packages. As an example sqlite3 and audiofile
> >> (from meta-oe) produces empty src packages, mostly due to the pathes:
> >> they frequently use relative paths that don't match up with the
> >> absolute path specified in the file-preifx map:
> >> `pwd`/../../foo.cpp and ${S}/foo.cpp might refer to the same file, but
> >> the first one won't match the prefix-map, so it is omitted.
> >>
> >> This patch adds this option again with gcc: for class-target it is uses
> >> always, and for class-native it is used when the host gcc is at least
> >> version 13.
> >>
> >> Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
> >> ---
> >>  meta/classes/toolchain/gcc-native.bbclass | 3 +++
> >>  meta/classes/toolchain/gcc.bbclass        | 2 ++
> >>  meta/conf/bitbake.conf                    | 2 +-
> >>  3 files changed, 6 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/meta/classes/toolchain/gcc-native.bbclass b/meta/classes/toolchain/gcc-native.bbclass
> >> index a708bd0389..8708ad0211 100644
> >> --- a/meta/classes/toolchain/gcc-native.bbclass
> >> +++ b/meta/classes/toolchain/gcc-native.bbclass
> >> @@ -13,3 +13,6 @@ BUILD_OBJDUMP = "${BUILD_PREFIX}objdump"
> >>  BUILD_NM = "${BUILD_PREFIX}nm"
> >>  BUILD_READELF = "${BUILD_PREFIX}readelf"
> >>
> >> +# gcc started to support -fcanon-prefix-map from version 13
> >> +DEBUG_PREFIX_MAP_EXTRA:class-native = \
> >> +    "${@'-fcanon-prefix-map' if bb.utils.vercmp_string_op(oe.utils.get_host_gcc_version(d), '13.0.0', '>=') else ''}"
> >> diff --git a/meta/classes/toolchain/gcc.bbclass b/meta/classes/toolchain/gcc.bbclass
> >> index a5adb5ca37..0ed49ba892 100644
> >> --- a/meta/classes/toolchain/gcc.bbclass
> >> +++ b/meta/classes/toolchain/gcc.bbclass
> >> @@ -30,4 +30,6 @@ PREFERRED_PROVIDER_virtual/nativesdk-cross-cc:class-cross-canadian = "gcc-crosss
> >>  PREFERRED_PROVIDER_virtual/nativesdk-cross-c++:class-cross-canadian = "gcc-crosssdk-${SDK_SYS}"
> >>  PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs:class-cross-canadian = "nativesdk-gcc-runtime"
> >>
> >> +DEBUG_PREFIX_MAP_EXTRA = "-fcanon-prefix-map"
> >> +
> >>  TCOVERRIDE = "toolchain-gcc"
> >> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> >> index 5406e542db..600d4baffb 100644
> >> --- a/meta/conf/bitbake.conf
> >> +++ b/meta/conf/bitbake.conf
> >> @@ -650,7 +650,7 @@ EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} "
> >>  ##################################################################
> >>  TARGET_DBGSRC_DIR ?= "/usr/src/debug/${PN}/${PV}"
> >>  # Beware: applied last to first
> >> -DEBUG_PREFIX_MAP ?= "\
> >> +DEBUG_PREFIX_MAP ?= "${DEBUG_PREFIX_MAP_EXTRA} \
> >>   -ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR} \
> >>   -ffile-prefix-map=${B}=${TARGET_DBGSRC_DIR} \
> >>   -ffile-prefix-map=${STAGING_DIR_HOST}= \
> >>
> > I think we should do something like this patch but just with only the
> > target pieces, not the native ones.
> >
> > The gcc version check is a slow function call since it execs a command
> > and we really don't want a call like that dropped inside a variable.
> >
> > native components don't have -src packages so I'm not sure we need that
> > element of this. The simplest thing would be to drop that piece.
> >
> > This issue was identified as a release blocker so I'll probably hack
> > the patch and put something into master-next for testing overnight.
> >
> > Cheers,
> >
> > Richard
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#226652): https://lists.openembedded.org/g/openembedded-core/message/226652
> Mute This Topic: https://lists.openembedded.org/mt/116389619/3617156
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [martin.jansa@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/classes/toolchain/gcc-native.bbclass b/meta/classes/toolchain/gcc-native.bbclass
index a708bd0389..8708ad0211 100644
--- a/meta/classes/toolchain/gcc-native.bbclass
+++ b/meta/classes/toolchain/gcc-native.bbclass
@@ -13,3 +13,6 @@  BUILD_OBJDUMP = "${BUILD_PREFIX}objdump"
 BUILD_NM = "${BUILD_PREFIX}nm"
 BUILD_READELF = "${BUILD_PREFIX}readelf"
 
+# gcc started to support -fcanon-prefix-map from version 13
+DEBUG_PREFIX_MAP_EXTRA:class-native = \
+    "${@'-fcanon-prefix-map' if bb.utils.vercmp_string_op(oe.utils.get_host_gcc_version(d), '13.0.0', '>=') else ''}"
diff --git a/meta/classes/toolchain/gcc.bbclass b/meta/classes/toolchain/gcc.bbclass
index a5adb5ca37..0ed49ba892 100644
--- a/meta/classes/toolchain/gcc.bbclass
+++ b/meta/classes/toolchain/gcc.bbclass
@@ -30,4 +30,6 @@  PREFERRED_PROVIDER_virtual/nativesdk-cross-cc:class-cross-canadian = "gcc-crosss
 PREFERRED_PROVIDER_virtual/nativesdk-cross-c++:class-cross-canadian = "gcc-crosssdk-${SDK_SYS}"
 PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs:class-cross-canadian = "nativesdk-gcc-runtime"
 
+DEBUG_PREFIX_MAP_EXTRA = "-fcanon-prefix-map"
+
 TCOVERRIDE = "toolchain-gcc"
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 5406e542db..600d4baffb 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -650,7 +650,7 @@  EXTRA_OEMAKE:prepend:task-install = "${PARALLEL_MAKEINST} "
 ##################################################################
 TARGET_DBGSRC_DIR ?= "/usr/src/debug/${PN}/${PV}"
 # Beware: applied last to first
-DEBUG_PREFIX_MAP ?= "\
+DEBUG_PREFIX_MAP ?= "${DEBUG_PREFIX_MAP_EXTRA} \
  -ffile-prefix-map=${S}=${TARGET_DBGSRC_DIR} \
  -ffile-prefix-map=${B}=${TARGET_DBGSRC_DIR} \
  -ffile-prefix-map=${STAGING_DIR_HOST}= \