]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
insane: rewrite package_qa_check_arch
authorRoss Burton <ross.burton@arm.com>
Thu, 10 Oct 2024 16:06:23 +0000 (17:06 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 11 Oct 2024 11:16:59 +0000 (12:16 +0100)
Reorder and comment the architecture checks to make it clearer what they
are actually checking.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-global/insane.bbclass

index 2d69bdec8d32f9ae22927cefa7149049f5e22982..36b139a20d076e541913a85c7791d4a4d65b9d8e 100644 (file)
@@ -325,32 +325,41 @@ def package_qa_check_arch(path,name,d, elf):
 
     host_os   = d.getVar('HOST_OS')
     host_arch = d.getVar('HOST_ARCH')
-    provides = d.getVar('PROVIDES')
-    bpn = d.getVar('BPN')
+    provides  = d.getVar('PROVIDES')
 
     if host_arch == "allarch":
-        pn = d.getVar('PN')
-        oe.qa.handle_error("arch", pn + ": Recipe inherits the allarch class, but has packaged architecture-specific binaries", d)
+        oe.qa.handle_error("arch", "%s: inherits the allarch class, but has architecture-specific binaries %s" % \
+            (name, package_qa_clean_path(path, d, name)), d)
         return
 
-    #if this will throw an exception, then fix the dict above
-    (machine, osabi, abiversion, littleendian, bits) \
+    # If this throws an exception, the machine_dict needs expanding
+    (expected_machine, expected_osabi, expected_abiversion, expected_littleendian, expected_bits) \
         = oe.elf.machine_dict(d)[host_os][host_arch]
 
+    actual_machine = elf.machine()
+    actual_bits = elf.abiSize()
+    actual_littleendian = elf.isLittleEndian()
+
+    # BPF don't match the target
+    if oe.qa.elf_machine_to_string(actual_machine) == "BPF":
+        return
+
+    # These targets have 32-bit userspace but 64-bit kernel, so fudge the expected values
+    if (("virtual/kernel" in provides) or bb.data.inherits_class("module", d)) and (host_os in ("linux-gnux32", "linux-muslx32", "linux-gnu_ilp32") or re.match(r'mips64.*32', d.getVar('DEFAULTTUNE'))):
+        expected_bits = 64
+
     # Check the architecture and endiannes of the binary
-    is_32 = (("virtual/kernel" in provides) or bb.data.inherits_class("module", d)) and \
-            (host_os == "linux-gnux32" or host_os == "linux-muslx32" or \
-            host_os == "linux-gnu_ilp32" or re.match(r'mips64.*32', d.getVar('DEFAULTTUNE')))
-    is_bpf = (oe.qa.elf_machine_to_string(elf.machine()) == "BPF")
-    if not ((machine == elf.machine()) or is_32 or is_bpf):
+    if expected_machine != actual_machine:
         oe.qa.handle_error("arch", "Architecture did not match (%s, expected %s) in %s" % \
-                 (oe.qa.elf_machine_to_string(elf.machine()), oe.qa.elf_machine_to_string(machine), package_qa_clean_path(path, d, name)), d)
-    elif not ((bits == elf.abiSize()) or is_32 or is_bpf):
+                 (oe.qa.elf_machine_to_string(actual_machine), oe.qa.elf_machine_to_string(expected_machine), package_qa_clean_path(path, d, name)), d)
+
+    if expected_bits != actual_bits:
         oe.qa.handle_error("arch", "Bit size did not match (%d, expected %d) in %s" % \
-                 (elf.abiSize(), bits, package_qa_clean_path(path, d, name)), d)
-    elif not ((littleendian == elf.isLittleEndian()) or is_bpf):
+                 (actual_bits, expected_bits, package_qa_clean_path(path, d, name)), d)
+
+    if expected_littleendian != actual_littleendian:
         oe.qa.handle_error("arch", "Endiannes did not match (%d, expected %d) in %s" % \
-                 (elf.isLittleEndian(), littleendian, package_qa_clean_path(path, d, name)), d)
+                 (actual_littleendian, expected_littleendian, package_qa_clean_path(path, d, name)), d)
 package_qa_check_arch[vardepsexclude] = "DEFAULTTUNE"
 
 QAPATHTEST[desktop] = "package_qa_check_desktop"