From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB24FE8FDD5 for ; Sat, 27 Dec 2025 08:46:46 +0000 (UTC) Subject: Re: [PATCH] package.py: warn if target is not a valid ELF file in dwarfsrcfiles To: openembedded-core@lists.openembedded.org From: "mark.yang" X-Originating-Location: Gwanak-gu, Seoul, KR (203.247.149.209) X-Originating-Platform: Windows Firefox 146 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Sat, 27 Dec 2025 00:46:21 -0800 References: <20251226073545.11152-1-mark.yang@lge.com> In-Reply-To: Message-ID: <359949.1766825181217178563@lists.openembedded.org> Content-Type: multipart/alternative; boundary="KNudPR20UwA4aa4f9sio" List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sat, 27 Dec 2025 08:46:46 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/228553 --KNudPR20UwA4aa4f9sio Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable My error report is as follows. https://errors.yoctoproject.org/Errors/Details/892988/ I am using only the openembedded-core layer, with nodistro. local.conf >=20 > PREFERRED_TOOLCHAIN_TARGET =3D "clang" > DISTRO_FEATURES:append =3D " ld-is-lld" > require conf/distro/include/lto.inc > DISTRO_FEATURES:append =3D " lto" > # The settings below were taken from meta-clang. > LTO:toolchain-clang:class-target =3D > "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flto=3Dthin', '-fl= to > -fuse-ld=3Dlld', d)}" > LTO:toolchain-clang:class-nativesdk =3D > "${@bb.utils.contains('DISTRO_FEATURES', 'thin-lto', '-flto=3Dthin', '-fl= to > -fuse-ld=3Dlld', d)}" >=20 dwarfsrcfiles checks .a files during the package process. Whether using LTO or not, DWARF information is extracted by iterating throu= gh .o files inside .a files. However, they must be ELF objects. To summarize, it is as follows. The problem is that when using clang + LTO, the .o files are not ELF but LL= VM IR bitcode. On Sat, Dec 27, 2025 at 03:31 AM, Alexander Kanavin wrote: >=20 > Can you please provide a way to reproduce and observe the issue? I'm > somewhat confused as to what the original issue is: is dwarfsrcfiles > called on an .a file? That is not an ELF file regardless of whether > clang-with-lto is enabled, so why does it work in one case but not in > the other? >=20 > Alex > On Fri, 26 Dec 2025 at 08:36, mark.yang via lists.openembedded.org > wrote: >=20 >>=20 >> From: "mark.yang" >>=20 >> When using the Clang toolchain with LTO, intermediate .o files are >> generated as >> LLVM bitcode files instead of ELF files. While .so libraries are >> ultimately >> ELF, .a files are not. In this case, dwarfsrcfiles always fails. >>=20 >> Adding the -ffat-lto-objects option allows the Clang toolchain to produc= e >> .o >> files that are recognized as ELF, but this is not always a suitable >> solution >> as it causes issues when used in conjunction with -fsanitize=3Dcfi. >>=20 >> Therefore, we need to handle cases where dwarfsrcfiles encounters a file >> that >> is not a valid ELF. Change the behavior from a fatal error to a warning = to >>=20 >> notify the user. >>=20 >> Signed-off-by: mark.yang >> --- >> meta/lib/oe/package.py | 8 ++++++-- >> 1 file changed, 6 insertions(+), 2 deletions(-) >>=20 >> diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py >> index baaa0cba02..56b9bcd546 100644 >> --- a/meta/lib/oe/package.py >> +++ b/meta/lib/oe/package.py >> @@ -782,8 +782,12 @@ def source_info(file, d, fatal=3DTrue): >> if retval !=3D 0 and retval !=3D 255: >> msg =3D "dwarfsrcfiles failed with exit code %s (cmd was %s)%s" % (retva= l, >> cmd, ":\n%s" % output if output else "") >> if fatal: >> - bb.fatal(msg) >> - bb.note(msg) >> + if "not a valid ELF file" in output: >> + bb.warn(msg) >> + else: >> + bb.fatal(msg) >> + else: >> + bb.note(msg) >>=20 >> debugsources =3D parse_debugsources_from_dwarfsrcfiles_output(output) >>=20 >>=20 >>=20 >>=20 >=20 > --KNudPR20UwA4aa4f9sio Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
 
I am using only the openembedded-core layer, with nodistro.
local.conf
PREFERRED_TOOLCHAIN_TARGET =3D "clang"
DISTRO_FEATURES:append =3D= " ld-is-lld"
require conf/distro/include/lto.inc
DISTRO_FEATURES= :append =3D " lto"
# The settings below were taken from meta-clang.LTO:toolchain-clang:class-target =3D "${@bb.utils.contains('DISTRO_FEATU= RES', 'thin-lto', '-flto=3Dthin', '-flto -fuse-ld=3Dlld', d)}"
LTO:too= lchain-clang:class-nativesdk =3D "${@bb.utils.contains('DISTRO_FEATURES', '= thin-lto', '-flto=3Dthin', '-flto -fuse-ld=3Dlld', d)}"
 
dwarfsrcfiles checks .a files during the package process.
Whether= using LTO or not, DWARF information is extracted by iterating through .o f= iles inside .a files.
However, they must be ELF objects.
 
To summarize, it is as follows.
The problem is that when using clang + LTO, the .o files are not ELF b= ut LLVM IR bitcode.
 
On Sat, Dec 27, 2025 at 03:31 AM, Alexander Kanavin wrote:
Can you please provide a way to reproduce and observe the issue= ? I'm
somewhat confused as to what the original issue is: is dwarfsrcf= iles
called on an .a file? That is not an ELF file regardless of wheth= er
clang-with-lto is enabled, so why does it work in one case but not = in
the other?

Alex
On Fri, 26 Dec 2025 at 08:36, mark.= yang via lists.openembedded.org
<mark.yang=3Dlge.com@lists.openembe= dded.org> wrote:

From: "mark.yang" <mark.yang@lge.com>

Wh= en using the Clang toolchain with LTO, intermediate .o files are generated = as
LLVM bitcode files instead of ELF files. While .so libraries are ul= timately
ELF, .a files are not. In this case, dwarfsrcfiles always fai= ls.

Adding the -ffat-lto-objects option allows the Clang toolcha= in to produce .o
files that are recognized as ELF, but this is not alw= ays a suitable solution
as it causes issues when used in conjunction w= ith -fsanitize=3Dcfi.

Therefore, we need to handle cases where d= warfsrcfiles encounters a file that
is not a valid ELF. Change the beh= avior from a fatal error to a warning to
notify the user.

S= igned-off-by: mark.yang <mark.yang@lge.com>
---
meta/lib/oe= /package.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(= -)

diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py<= br />index baaa0cba02..56b9bcd546 100644
--- a/meta/lib/oe/package.py<= br />+++ b/meta/lib/oe/package.py
@@ -782,8 +782,12 @@ def source_info= (file, d, fatal=3DTrue):
if retval !=3D 0 and retval !=3D 255:
ms= g =3D "dwarfsrcfiles failed with exit code %s (cmd was %s)%s" % (retval, cm= d, ":\n%s" % output if output else "")
if fatal:
- bb.fatal(msg)<= br />- bb.note(msg)
+ if "not a valid ELF file" in output:
+ bb.w= arn(msg)
+ else:
+ bb.fatal(msg)
+ else:
+ bb.note(msg)=

debugsources =3D parse_debugsources_from_dwarfsrcfiles_output(o= utput)



--KNudPR20UwA4aa4f9sio--