Skip to contentSkip to conversation

package.py: skip dwarfsrcfiles for Clang LTO static libraries

PATCH In review [email protected] 2 participants 2 messages Dec 28, 2025 – Dec 29, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package.py: skip dwarfsrcfiles for Clang LTO static libraries

From: "mark.yang" <[email protected]>

When using Clang toolchain with LTO enabled, static libraries (.a) contain LLVM bitcode objects instead of ELF objects. dwarfsrcfiles cannot process these files and fails with "not a valid ELF file" error.

Rather than catching the error message, guard the dwarfsrcfiles call by checking for the specific conditions: static library (using is_static_lib() magic check) + clang toolchain + lto in DISTRO_FEATURES. When all conditions are met, skip the call silently.

---
 meta/lib/oe/package.py | 8 ++++++++
 1 file changed, 8 insertions(+)
meta/lib/oe/package.py +8 -0
index baaa0cba02..279cd567b3 100644
@@ -770,6 +770,14 @@ def parse_debugsources_from_dwarfsrcfiles_output(dwarfsrcfiles_output):
     return debugfiles.keys()
 
 def source_info(file, d, fatal=True):
+    # Skip static libraries when using Clang toolchain with LTO enabled.
+    # In this case, .a files contain LLVM bitcode instead of ELF objects,
+    # and dwarfsrcfiles cannot process them.
+    if is_static_lib(file):
+        if d.getVar('TOOLCHAIN') == "clang" and bb.utils.contains('DISTRO_FEATURES', 'lto', True, False, d):
+            bb.debug(1, "Skipping dwarfsrcfiles for Clang LTO archive: %s" % file)
+            return []
+
     cmd = ["dwarfsrcfiles", file]
     try:
         output = subprocess.check_output(cmd, universal_newlines=True, stderr=subprocess.STDOUT)
#1 lore raw

Thanks, this should be good.

Alex

Quoted 45 lines · mark.yang via lists.openembedded.org

From: "mark.yang" <[email protected]>

When using Clang toolchain with LTO enabled, static libraries (.a) contain LLVM bitcode objects instead of ELF objects. dwarfsrcfiles cannot process these files and fails with "not a valid ELF file" error.

Rather than catching the error message, guard the dwarfsrcfiles call by checking for the specific conditions: static library (using is_static_lib() magic check) + clang toolchain + lto in DISTRO_FEATURES. When all conditions are met, skip the call silently.

---
 meta/lib/oe/package.py | 8 ++++++++
 1 file changed, 8 insertions(+)
meta/lib/oe/package.py +8 -1
index baaa0cba02..279cd567b3 100644
@@ -770,6 +770,14 @@ def parse_debugsources_from_dwarfsrcfiles_output(dwarfsrcfiles_output):
     return debugfiles.keys()
 
 def source_info(file, d, fatal=True):
+    # Skip static libraries when using Clang toolchain with LTO enabled.
+    # In this case, .a files contain LLVM bitcode instead of ELF objects,
+    # and dwarfsrcfiles cannot process them.
+    if is_static_lib(file):
+        if d.getVar('TOOLCHAIN') == "clang" and bb.utils.contains('DISTRO_FEATURES', 'lto', True, False, d):
+            bb.debug(1, "Skipping dwarfsrcfiles for Clang LTO archive: %s" % file)
+            return []
+
     cmd = ["dwarfsrcfiles", file]
     try:
         output = subprocess.check_output(cmd, universal_newlines=True, stderr=subprocess.STDOUT)
 
-=-=-=-=-=-=-=-=-=-=-=-

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