Skip to contentSkip to conversation

lib/oe/package: remove unused and optional fatal argument to source_info()

PATCH New Ross Burton 1 participant 4 messages Sep 24

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 lib/oe/package: remove unused and optional fatal argument to source_info()

Nothing uses this, so clean up the code slightly.

---
 meta/lib/oe/package.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
meta/lib/oe/package.py +2 -4
index b7030643d2b..777bf99331c 100644
@@ -755,7 +755,7 @@ def parse_debugsources_from_dwarfsrcfiles_output(dwarfsrcfiles_output):
 
     return debugfiles.keys()
 
-def source_info(file, d, fatal=True):
+def source_info(file, d):
     # 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.
@@ -775,9 +775,7 @@ def source_info(file, d, fatal=True):
     # 255 means a specific file wasn't fully parsed to get the debug file list, which is not a fatal failure
     if retval != 0 and retval != 255:
         msg = "dwarfsrcfiles failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else "")
-        if fatal:
-            bb.fatal(msg)
-        bb.note(msg)
+        bb.fatal(msg)
 
     debugsources = parse_debugsources_from_dwarfsrcfiles_output(output)
 
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/4 elfutils: fix handling of DWARF5 compilation units

If a source file doesn't contain any functions or variable then it won't appear in the source file list for the generated object if the debug information is DWARF5. Details of why this is are in the patch header.

Backport a patch from upstream to fix this oversight, adding files to the -src packages that were previously missing.

---
 .../elfutils/elfutils_0.196.bb                |  1 +
 .../elfutils/files/srcfiles.patch             | 65 +++++++++++++++++++
 2 files changed, 66 insertions(+)
 create mode 100644 meta/recipes-devtools/elfutils/files/srcfiles.patch
meta/recipes-devtools/elfutils/elfutils_0.196.bb +1 -0
index c2466134cdc..4541000840b 100644
@@ -20,6 +20,7 @@ SRC_URI = "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \
            file://0001-tests-Makefile.am-compile-test_nlist-with-standard-C.patch \
            file://0001-config-eu.am-do-not-force-Werror.patch \
            file://0001-backends-use-sys-uio.h-instead-of-linux-uio.h-for-s.patch \
+           file://srcfiles.patch \
            "
 SRC_URI:append:libc-musl = " \
            file://0003-musl-utils.patch \
meta/recipes-devtools/elfutils/files/srcfiles.patch new file +65 -0

65 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw

PATCH 3/4 classes/package: use eu-srcfiles instead of dwarfsrcfiles

In reply to Ross Burton

elfutils gained a srcfiles command in 0.190[1], which is essentially the same as our dwarfsrcfiles. This obsoletes our dwarfsrcfiles, so change the packaging class to use it instead of dwarfsrcfiles.

Apart from removing code we need to maintain, eu-srcfiles also has better output and results in some more source files being identified. Across a core-image-sato, the following changes occur from more source files being added to the -src packages:

curl-src: PKGSIZE changed from 6198005 to 8919864 (+44%)
flac-src: PKGSIZE changed from 2282162 to 2526447 (+11%)
libjpeg-turbo-src: PKGSIZE changed from 2673297 to 2977880 (+11%)
libseccomp-src: PKGSIZE changed from 716039 to 1048204 (+46%)
sbc-src: PKGSIZE changed from 110274 to 176011 (+60%)

[1] elfutils cb4f0e0f ("PR 30000: debuginfod-find should have a source-list verb")

---
 meta/classes-global/package.bbclass |  4 ++--
 meta/lib/oe/package.py              | 28 +++-------------------------
 2 files changed, 5 insertions(+), 27 deletions(-)
meta/classes-global/package.bbclass +2 -2
index e21350a06f4..b54f4c0063a 100644
@@ -57,8 +57,8 @@ LOCALE_SECTION ?= ''
 ALL_MULTILIB_PACKAGE_ARCHS = "${@oe.utils.all_multilib_tune_values(d, 'PACKAGE_ARCHS')}"
 
 # rpm is used for the per-file dependency identification
-# dwarfsrcfiles is used to determine the list of debug source files
-PACKAGE_DEPENDS += "rpm-native dwarfsrcfiles-native"
+# elfutils is used to determine the list of debug source files (eu-srcfiles)
+PACKAGE_DEPENDS += "rpm-native elfutils-native"
 
 # If your postinstall can execute at rootfs creation time rather than on
 # target but depends on a native/cross tool in order to execute, you need to
meta/lib/oe/package.py +3 -25
index 777bf99331c..5d4966be295 100644
@@ -746,15 +746,6 @@ def package_debug_vars(d):
     return debug_vars
 
 
-def parse_debugsources_from_dwarfsrcfiles_output(dwarfsrcfiles_output):
-    debugfiles = {}
-
-    for line in dwarfsrcfiles_output.splitlines():
-        if line.startswith("\t"):
-            debugfiles[os.path.normpath(line.split()[0])] = ""
-
-    return debugfiles.keys()
-
 def source_info(file, d):
     # Skip static libraries when using Clang toolchain with LTO enabled.
     # In this case, .a files contain LLVM bitcode instead of ELF objects,
@@ -764,22 +755,9 @@ def source_info(file, 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)
-        retval = 0
-    except subprocess.CalledProcessError as exc:
-        output = exc.output
-        retval = exc.returncode
-
-    # 255 means a specific file wasn't fully parsed to get the debug file list, which is not a fatal failure
-    if retval != 0 and retval != 255:
-        msg = "dwarfsrcfiles failed with exit code %s (cmd was %s)%s" % (retval, cmd, ":\n%s" % output if output else "")
-        bb.fatal(msg)
-
-    debugsources = parse_debugsources_from_dwarfsrcfiles_output(output)
-
-    return list(debugsources)
+    cmd = ["eu-srcfiles", "--null", "--debuginfo-path=/not/exist", "--executable", file]
+    output = subprocess.check_output(cmd, text=True, stderr=subprocess.STDOUT)
+    return output.split("\0")
 
 def splitdebuginfo(file, dvar, dv, d):
     # Function to split a single file into two components, one is the stripped
Signature · 1 line
2.43.0
#3 lore raw

PATCH 4/4 dwarfsrcfiles: remove

In reply to Ross Burton

We now use srcfiles from elfutils, so we can delete this.

---
 meta/conf/distro/include/maintainers.inc      |   1 -
 .../dwarfsrcfiles/dwarfsrcfiles.bb            |  25 ----
 .../dwarfsrcfiles/files/dwarfsrcfiles.c       | 118 ------------------
 3 files changed, 144 deletions(-)
 delete mode 100644 meta/recipes-devtools/dwarfsrcfiles/dwarfsrcfiles.bb
 delete mode 100644 meta/recipes-devtools/dwarfsrcfiles/files/dwarfsrcfiles.c
meta/conf/distro/include/maintainers.inc +0 -1
index 53f5e6bf92a..3b2342527c3 100644
@@ -165,7 +165,6 @@ RECIPE_MAINTAINER:pn-dosfstools = "Yi Zhao <[email protected]>"
 RECIPE_MAINTAINER:pn-dpkg = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-dropbear = "Yi Zhao <[email protected]>"
 RECIPE_MAINTAINER:pn-dtc = "Wang Mingyu <[email protected]>"
-RECIPE_MAINTAINER:pn-dwarfsrcfiles = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-e2fsprogs = "Robert Yang <[email protected]>"
 RECIPE_MAINTAINER:pn-ed = "Unassigned <[email protected]>"
 RECIPE_MAINTAINER:pn-efibootmgr = "Ross Burton <[email protected]>"
meta/recipes-devtools/dwarfsrcfiles/dwarfsrcfiles.bb deleted +0 -25
deleted file mode 100644
index c1eca13107b..00000000000
@@ -1,25 +0,0 @@
-SUMMARY = "A small utility for printing debug source file locations embedded in binaries"
-DESCRIPTION = "${SUMMARY}"
-LICENSE = "GPL-2.0-or-later"
-LIC_FILES_CHKSUM = "file://dwarfsrcfiles.c;md5=31483894e453a77acbb67847565f1b5c;beginline=1;endline=8"
-
-SRC_URI = "file://dwarfsrcfiles.c"
-BBCLASSEXTEND = "native"
-DEPENDS = "elfutils"
-DEPENDS:append:libc-musl = " argp-standalone"
-
-S = "${UNPACKDIR}"
-
-do_compile () {
-	${CC} ${CFLAGS} ${LDFLAGS} -o dwarfsrcfiles ${S}/dwarfsrcfiles.c -lelf -ldw
-}
-
-do_compile:libc-musl () {
-	${CC} ${CFLAGS} ${LDFLAGS} -o dwarfsrcfiles ${S}/dwarfsrcfiles.c -lelf -ldw -largp
-}
-
-do_install () {
-	install -d ${D}${bindir}
-	install -t ${D}${bindir} dwarfsrcfiles
-}
-
meta/recipes-devtools/dwarfsrcfiles/files/dwarfsrcfiles.c deleted +0 -118

118 lines not on this page · raw message

Signature · 1 line
2.43.0