]> code.ossystems Code Review - openembedded-core.git/commitdiff
runqemu: preload uninative libraries when host gl drivers are in use
authorAlexander Kanavin <alex@linutronix.de>
Fri, 4 Feb 2022 19:59:43 +0000 (20:59 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 7 Feb 2022 10:08:52 +0000 (10:08 +0000)
Some of the host distributions build the drivers in a way (RPATH/RUNPATH)
that tricks uninative loader into loading pieces of the host libc, if
the same pieces haven't been previously loaded by native binaries. Mixing
the two libc versions leads to failures.

This change ensures that the correct (uninative) versions are always in use.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/qemuboot.bbclass
scripts/runqemu

index cc1cbce69d14fff538e2b28aa5e3c3d91b723a4f..229bd88527f206640067310959fda365b4411f52 100644 (file)
@@ -109,7 +109,7 @@ def qemuboot_vars(d):
     build_vars = ['MACHINE', 'TUNE_ARCH', 'DEPLOY_DIR_IMAGE',
                 'KERNEL_IMAGETYPE', 'IMAGE_NAME', 'IMAGE_LINK_NAME',
                 'STAGING_DIR_NATIVE', 'STAGING_BINDIR_NATIVE',
-                'STAGING_DIR_HOST', 'SERIAL_CONSOLES']
+                'STAGING_DIR_HOST', 'SERIAL_CONSOLES', 'UNINATIVE_LOADER']
     return build_vars + [k for k in d.keys() if k.startswith('QB_')]
 
 do_write_qemuboot_conf[vardeps] += "${@' '.join(qemuboot_vars(d))}"
index 07429372ea7c0f53f2ff90ac8ef3826fcb64f27f..5c108ec23aeb871040a1cc9d9d3ae23bc0f4c954 100755 (executable)
@@ -461,6 +461,14 @@ class BaseConfig(object):
             raise RunQemuError("Could not determine the path to dri drivers on the host via pkg-config.\nPlease install Mesa development files (particularly, dri.pc) on the host machine.")
         os.environ['LIBGL_DRIVERS_PATH'] = dripath.decode('utf-8').strip()
 
+        # This preloads uninative libc pieces and therefore ensures that RPATH/RUNPATH
+        # in host mesa drivers doesn't trick uninative into loading host libc.
+        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
+        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
+        if os.path.exists(uninative_path):
+            preload_paths = [os.path.join(uninative_path, i) for i in preload_items]
+            os.environ['LD_PRELOAD'] = " ".join(preload_paths)
+
     def check_args(self):
         for debug in ("-d", "--debug"):
             if debug in sys.argv: