Skip to contentSkip to conversation

systemd: more optimistic dlopen notes processing

PATCH In review Dan McGregor 2 participants 3 messages Nov 25, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 systemd: more optimistic dlopen notes processing

From: Dan McGregor <[email protected]>

Ignore shared object names that differ from names we've already processed only by their version number. This assumes that the highest priority is first in the list, and ignores those later in the list if we've alredy found one.

I saw this with the qrencode PACKAGECONFIG enabled. Its note lists both libqrencode.so.4 and libqrencode.so.3, which led to a packaging warning.

---
 meta/recipes-core/systemd/dlopen-deps.inc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
meta/recipes-core/systemd/dlopen-deps.inc +6 -2
index e0b333398c2..18768d43491 100644
@@ -3,7 +3,7 @@ PACKAGEFUNCS =+ "package_generate_dlopen_deps"
 python package_generate_dlopen_deps() {
     # https://systemd.io/ELF_DLOPEN_METADATA/
 
-    import struct, json
+    import struct, json, re
 
     def extract_segment(filename, segment):
         """
@@ -66,14 +66,18 @@ python package_generate_dlopen_deps() {
                     elf = oe.qa.ELFFile(f)
                     elf.open()
                     for dep in parse(extract_segment(f, ".note.dlopen"), elf.isLittleEndian()):
+                        # Ignore sonames if a higher priority version is found
+                        seen_sonames = []
                         for soname in dep["soname"]:
+                            base_soname = re.sub(r'\.so($|\..*$)', '', soname)
                             if soname in shlibs:
                                 # TODO assumes the first match is good
                                 package, version = list(shlibs[soname].values())[0]
                                 dependency = dep_map[dep["priority"]]
                                 bb.note(f"{pkg}: adding {dependency} on {package} via .note.dlopen")
                                 d.appendVar(f"{dependency}:{pkg}", f" {package} (>= {version})")
-                            else:
+                                seen_sonames.append(base_soname)
+                            elif base_soname not in seen_sonames:
                                 bb.warn(f"cannot find {soname}")
                 except oe.qa.NotELFFileError as e:
                     bb.note(f"Cannot extract ELF notes: {e}")
Signature · 1 line
2.47.0
#1 lore raw
Quoted 11 lines · Dan McGregor via lists.openembedded.org

From: Dan McGregor <[email protected]>

Ignore shared object names that differ from names we've already processed only by their version number. This assumes that the highest priority is first in the list, and ignores those later in the list if we've alredy found one.

I saw this with the qrencode PACKAGECONFIG enabled. Its note lists both libqrencode.so.4 and libqrencode.so.3, which led to a packaging warning.

I’m unconvinced that “just take the first one” is the right solution here. What was the resulting dependency without this patch? Our qrencode recipe is version 4.1.1 so libqrencode.so <http://libqrencode.so/>.4 should have found the qrencode package, but libqrencode.so <http://libqrencode.so/>.3 shouldn’t have found anything and so a dependency shouldn’t have been created.

Unless my code is buggy in a different way, of course…

Ross

#2 lore raw
Quoted 10 lines · Ross Burton
Quoted 8 lines · Dan McGregor via lists.openembedded.org

From: Dan McGregor <[email protected]>

Ignore shared object names that differ from names we've already processed only by their version number. This assumes that the highest priority is first in the list, and ignores those later in the list if we've alredy found one.

Quoted 7 lines
Quoted 3 lines

I saw this with the qrencode PACKAGECONFIG enabled. Its note lists both libqrencode.so.4 and libqrencode.so.3, which led to a packaging warning.

I’m unconvinced that “just take the first one” is the right solution here. What was the resulting dependency without this patch? Our qrencode recipe is version 4.1.1 so libqrencode.so <http://libqrencode.so/>.4 should have found the qrencode package, but libqrencode.so <http://libqrencode.so/>.3 shouldn’t have found anything and so a dependency shouldn’t have been created.

Unless my code is buggy in a different way, of course…

The dependency generated was correct. It found libqrencode.so.4, but the note called for both libqrencode.so.4 and libqrencode.so.3.. see
https://github.com/systemd/systemd/blob/main/src/shared/qrcode-util.c#L28
When it then went looking for libqrencode.so.3 it didn't find anything, so emitted a warning about not finding libqrencode.so.3. The goal with this change is just to silence the warning if we've already found a package.

Quoted 2 lines

Ross