All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
@ 2022-02-04 20:40 Alexander Kanavin
  2022-02-04 21:17 ` [OE-core] " Christopher Larson
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Alexander Kanavin @ 2022-02-04 20:40 UTC (permalink / raw)
  To: openembedded-core; +Cc: Alexander Kanavin

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>
---
 meta/classes/qemuboot.bbclass | 2 +-
 scripts/runqemu               | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
index cc1cbce69d..229bd88527 100644
--- a/meta/classes/qemuboot.bbclass
+++ b/meta/classes/qemuboot.bbclass
@@ -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))}"
diff --git a/scripts/runqemu b/scripts/runqemu
index 4e05c1bb15..7d1f85f357 100755
--- a/scripts/runqemu
+++ b/scripts/runqemu
@@ -460,6 +460,10 @@ class BaseConfig(object):
         except subprocess.CalledProcessError as e:
             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()
+        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
+        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
+        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"):
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
  2022-02-04 20:40 [PATCH] runqemu: preload uninative libraries when host gl drivers are in use Alexander Kanavin
@ 2022-02-04 21:17 ` Christopher Larson
  2022-02-04 21:30   ` Alexander Kanavin
  2022-02-05 12:20 ` Richard Purdie
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Christopher Larson @ 2022-02-04 21:17 UTC (permalink / raw)
  To: Alexander Kanavin
  Cc: Patches and discussions about the oe-core layer, Alexander Kanavin

[-- Attachment #1: Type: text/plain, Size: 2869 bytes --]

What will this do if uninative isn't enabled?

On Fri, Feb 4, 2022 at 1:40 PM Alexander Kanavin <alex.kanavin@gmail.com>
wrote:

> 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>
> ---
>  meta/classes/qemuboot.bbclass | 2 +-
>  scripts/runqemu               | 4 ++++
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
> index cc1cbce69d..229bd88527 100644
> --- a/meta/classes/qemuboot.bbclass
> +++ b/meta/classes/qemuboot.bbclass
> @@ -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))}"
> diff --git a/scripts/runqemu b/scripts/runqemu
> index 4e05c1bb15..7d1f85f357 100755
> --- a/scripts/runqemu
> +++ b/scripts/runqemu
> @@ -460,6 +460,10 @@ class BaseConfig(object):
>          except subprocess.CalledProcessError as e:
>              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()
> +        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
> +        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
> +        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"):
> --
> 2.20.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#161382):
> https://lists.openembedded.org/g/openembedded-core/message/161382
> Mute This Topic: https://lists.openembedded.org/mt/88916306/3617123
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> kergoth@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>

-- 
Christopher Larson
kergoth at gmail dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Senior Software Engineer, Mentor Graphics

[-- Attachment #2: Type: text/html, Size: 4290 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
  2022-02-04 21:17 ` [OE-core] " Christopher Larson
@ 2022-02-04 21:30   ` Alexander Kanavin
  0 siblings, 0 replies; 14+ messages in thread
From: Alexander Kanavin @ 2022-02-04 21:30 UTC (permalink / raw)
  To: Christopher Larson
  Cc: Patches and discussions about the oe-core layer, Alexander Kanavin

[-- Attachment #1: Type: text/plain, Size: 3142 bytes --]

The dynamic loader will print an error about missing libraries, but will
execute the binary regardless.

Alex

On Fri, 4 Feb 2022 at 22:17, Christopher Larson <kergoth@gmail.com> wrote:

> What will this do if uninative isn't enabled?
>
> On Fri, Feb 4, 2022 at 1:40 PM Alexander Kanavin <alex.kanavin@gmail.com>
> wrote:
>
>> 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>
>> ---
>>  meta/classes/qemuboot.bbclass | 2 +-
>>  scripts/runqemu               | 4 ++++
>>  2 files changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
>> index cc1cbce69d..229bd88527 100644
>> --- a/meta/classes/qemuboot.bbclass
>> +++ b/meta/classes/qemuboot.bbclass
>> @@ -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))}"
>> diff --git a/scripts/runqemu b/scripts/runqemu
>> index 4e05c1bb15..7d1f85f357 100755
>> --- a/scripts/runqemu
>> +++ b/scripts/runqemu
>> @@ -460,6 +460,10 @@ class BaseConfig(object):
>>          except subprocess.CalledProcessError as e:
>>              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()
>> +        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
>> +        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
>> +        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"):
>> --
>> 2.20.1
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#161382):
>> https://lists.openembedded.org/g/openembedded-core/message/161382
>> Mute This Topic: https://lists.openembedded.org/mt/88916306/3617123
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
>> kergoth@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
>>
>
> --
> Christopher Larson
> kergoth at gmail dot com
> Founder - BitBake, OpenEmbedded, OpenZaurus
> Senior Software Engineer, Mentor Graphics
>

[-- Attachment #2: Type: text/html, Size: 4785 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
  2022-02-04 20:40 [PATCH] runqemu: preload uninative libraries when host gl drivers are in use Alexander Kanavin
  2022-02-04 21:17 ` [OE-core] " Christopher Larson
@ 2022-02-05 12:20 ` Richard Purdie
       [not found] ` <16D0E3273582D58F.23031@lists.openembedded.org>
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Richard Purdie @ 2022-02-05 12:20 UTC (permalink / raw)
  To: Alexander Kanavin, openembedded-core; +Cc: Alexander Kanavin

On Fri, 2022-02-04 at 21:40 +0100, Alexander Kanavin wrote:
> 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>
> ---
>  meta/classes/qemuboot.bbclass | 2 +-
>  scripts/runqemu               | 4 ++++
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
> index cc1cbce69d..229bd88527 100644
> --- a/meta/classes/qemuboot.bbclass
> +++ b/meta/classes/qemuboot.bbclass
> @@ -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))}"
> diff --git a/scripts/runqemu b/scripts/runqemu
> index 4e05c1bb15..7d1f85f357 100755
> --- a/scripts/runqemu
> +++ b/scripts/runqemu
> @@ -460,6 +460,10 @@ class BaseConfig(object):
>          except subprocess.CalledProcessError as e:
>              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()
> +        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
> +        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
> +        preload_paths = [os.path.join(uninative_path, i) for i in preload_items]
> +        os.environ['LD_PRELOAD'] = " ".join(preload_paths)
>  

This looks like a good way to work around this corner case and I don't see any
other alternative. Can I ask that:

a) we put some comment into the code so we can understand this in a couple of
years time as it is a rather weird corner case

b) we put some "if os.path.exists()" in there, maybe even just on the uninnative
loader direction so that in the non-uninative case we don't throw warnings?

Cheers,

Richard





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
       [not found] ` <16D0E3273582D58F.23031@lists.openembedded.org>
@ 2022-02-06  9:51   ` Richard Purdie
       [not found]   ` <16D1299F302D38AC.20549@lists.openembedded.org>
  1 sibling, 0 replies; 14+ messages in thread
From: Richard Purdie @ 2022-02-06  9:51 UTC (permalink / raw)
  To: Alexander Kanavin, openembedded-core; +Cc: Alexander Kanavin

On Sat, 2022-02-05 at 12:20 +0000, Richard Purdie via lists.openembedded.org
wrote:
> On Fri, 2022-02-04 at 21:40 +0100, Alexander Kanavin wrote:
> > 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>
> > ---
> >  meta/classes/qemuboot.bbclass | 2 +-
> >  scripts/runqemu               | 4 ++++
> >  2 files changed, 5 insertions(+), 1 deletion(-)
> > 
> > diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
> > index cc1cbce69d..229bd88527 100644
> > --- a/meta/classes/qemuboot.bbclass
> > +++ b/meta/classes/qemuboot.bbclass
> > @@ -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))}"
> > diff --git a/scripts/runqemu b/scripts/runqemu
> > index 4e05c1bb15..7d1f85f357 100755
> > --- a/scripts/runqemu
> > +++ b/scripts/runqemu
> > @@ -460,6 +460,10 @@ class BaseConfig(object):
> >          except subprocess.CalledProcessError as e:
> >              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()
> > +        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
> > +        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
> > +        preload_paths = [os.path.join(uninative_path, i) for i in preload_items]
> > +        os.environ['LD_PRELOAD'] = " ".join(preload_paths)
> >  
> 
> This looks like a good way to work around this corner case and I don't see any
> other alternative. Can I ask that:
> 
> a) we put some comment into the code so we can understand this in a couple of
> years time as it is a rather weird corner case
> 
> b) we put some "if os.path.exists()" in there, maybe even just on the uninnative
> loader direction so that in the non-uninative case we don't throw warnings?

I've added a tweak doing this into master-next.

Cheers,

Richard



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
       [not found]   ` <16D1299F302D38AC.20549@lists.openembedded.org>
@ 2022-02-06  9:57     ` Richard Purdie
  2022-02-06 10:13       ` Alexander Kanavin
  0 siblings, 1 reply; 14+ messages in thread
From: Richard Purdie @ 2022-02-06  9:57 UTC (permalink / raw)
  To: Alexander Kanavin, openembedded-core; +Cc: Alexander Kanavin

On Sun, 2022-02-06 at 09:51 +0000, Richard Purdie via lists.openembedded.org
wrote:
> On Sat, 2022-02-05 at 12:20 +0000, Richard Purdie via lists.openembedded.org
> wrote:
> > On Fri, 2022-02-04 at 21:40 +0100, Alexander Kanavin wrote:
> > > 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>
> > > ---
> > >  meta/classes/qemuboot.bbclass | 2 +-
> > >  scripts/runqemu               | 4 ++++
> > >  2 files changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
> > > index cc1cbce69d..229bd88527 100644
> > > --- a/meta/classes/qemuboot.bbclass
> > > +++ b/meta/classes/qemuboot.bbclass
> > > @@ -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))}"
> > > diff --git a/scripts/runqemu b/scripts/runqemu
> > > index 4e05c1bb15..7d1f85f357 100755
> > > --- a/scripts/runqemu
> > > +++ b/scripts/runqemu
> > > @@ -460,6 +460,10 @@ class BaseConfig(object):
> > >          except subprocess.CalledProcessError as e:
> > >              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()
> > > +        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
> > > +        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
> > > +        preload_paths = [os.path.join(uninative_path, i) for i in preload_items]
> > > +        os.environ['LD_PRELOAD'] = " ".join(preload_paths)
> > >  
> > 
> > This looks like a good way to work around this corner case and I don't see any
> > other alternative. Can I ask that:
> > 
> > a) we put some comment into the code so we can understand this in a couple of
> > years time as it is a rather weird corner case
> > 
> > b) we put some "if os.path.exists()" in there, maybe even just on the uninnative
> > loader direction so that in the non-uninative case we don't throw warnings?
> 
> I've added a tweak doing this into master-next.

Although I see one in your branch too, should have checked that first :/

Cheers,

Richard



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
  2022-02-06  9:57     ` Richard Purdie
@ 2022-02-06 10:13       ` Alexander Kanavin
  0 siblings, 0 replies; 14+ messages in thread
From: Alexander Kanavin @ 2022-02-06 10:13 UTC (permalink / raw)
  To: Richard Purdie; +Cc: OE-core, Alexander Kanavin

[-- Attachment #1: Type: text/plain, Size: 3463 bytes --]

There's also an issue with the wrapper script run by host bash for
qemu-system that breaks with uninative, so just hold it off until I get it
all confirmed as working :)

Alex

On Sun, 6 Feb 2022 at 10:57, Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> On Sun, 2022-02-06 at 09:51 +0000, Richard Purdie via
> lists.openembedded.org
> wrote:
> > On Sat, 2022-02-05 at 12:20 +0000, Richard Purdie via
> lists.openembedded.org
> > wrote:
> > > On Fri, 2022-02-04 at 21:40 +0100, Alexander Kanavin wrote:
> > > > 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>
> > > > ---
> > > >  meta/classes/qemuboot.bbclass | 2 +-
> > > >  scripts/runqemu               | 4 ++++
> > > >  2 files changed, 5 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/meta/classes/qemuboot.bbclass
> b/meta/classes/qemuboot.bbclass
> > > > index cc1cbce69d..229bd88527 100644
> > > > --- a/meta/classes/qemuboot.bbclass
> > > > +++ b/meta/classes/qemuboot.bbclass
> > > > @@ -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))}"
> > > > diff --git a/scripts/runqemu b/scripts/runqemu
> > > > index 4e05c1bb15..7d1f85f357 100755
> > > > --- a/scripts/runqemu
> > > > +++ b/scripts/runqemu
> > > > @@ -460,6 +460,10 @@ class BaseConfig(object):
> > > >          except subprocess.CalledProcessError as e:
> > > >              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()
> > > > +        uninative_path =
> os.path.dirname(self.get("UNINATIVE_LOADER"))
> > > > +        preload_items = ['libdl.so.2', 'librt.so.1',
> 'libpthread.so.0']
> > > > +        preload_paths = [os.path.join(uninative_path, i) for i in
> preload_items]
> > > > +        os.environ['LD_PRELOAD'] = " ".join(preload_paths)
> > > >
> > >
> > > This looks like a good way to work around this corner case and I don't
> see any
> > > other alternative. Can I ask that:
> > >
> > > a) we put some comment into the code so we can understand this in a
> couple of
> > > years time as it is a rather weird corner case
> > >
> > > b) we put some "if os.path.exists()" in there, maybe even just on the
> uninnative
> > > loader direction so that in the non-uninative case we don't throw
> warnings?
> >
> > I've added a tweak doing this into master-next.
>
> Although I see one in your branch too, should have checked that first :/
>
> Cheers,
>
> Richard
>
>

[-- Attachment #2: Type: text/html, Size: 4924 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
  2022-02-04 20:40 [PATCH] runqemu: preload uninative libraries when host gl drivers are in use Alexander Kanavin
                   ` (2 preceding siblings ...)
       [not found] ` <16D0E3273582D58F.23031@lists.openembedded.org>
@ 2022-02-12 13:18 ` Enrico Scholz
  2022-02-12 13:22   ` Alexander Kanavin
  2022-10-21 15:27 ` Joshua Watt
  4 siblings, 1 reply; 14+ messages in thread
From: Enrico Scholz @ 2022-02-12 13:18 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: openembedded-core, Alexander Kanavin

"Alexander Kanavin" <alex.kanavin@gmail.com> writes:

> --- a/meta/classes/qemuboot.bbclass
> +++ b/meta/classes/qemuboot.bbclass
> @@ -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_')]

Build without uninative fails now with

| File: '.../meta/classes/qemuboot.bbclass', lineno: 141, function: do_write_qemuboot_conf
|      0137:        else:
|      0138:            val = d.getVar(k)
|      0139:        # we only want to write out relative paths so that we can relocate images
|      0140:        # and still run them
|  *** 0141:        if val.startswith(topdir):
|      0142:            val = os.path.relpath(val, finalpath)
|      0143:        cf.set('config_bsp', k, '%s' % val)
|      0144:
|      0145:    # QB_DEFAULT_KERNEL's value of KERNEL_IMAGETYPE is the name of a symlink
| Exception: AttributeError: 'NoneType' object has no attribute 'startswith'



Enrico


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
  2022-02-12 13:18 ` Enrico Scholz
@ 2022-02-12 13:22   ` Alexander Kanavin
  0 siblings, 0 replies; 14+ messages in thread
From: Alexander Kanavin @ 2022-02-12 13:22 UTC (permalink / raw)
  To: Enrico Scholz; +Cc: OE-core, Alexander Kanavin

On Sat, 12 Feb 2022 at 14:18, Enrico Scholz
<enrico.scholz@sigma-chemnitz.de> wrote:
> | File: '.../meta/classes/qemuboot.bbclass', lineno: 141, function: do_write_qemuboot_conf
> |      0137:        else:
> |      0138:            val = d.getVar(k)
> |      0139:        # we only want to write out relative paths so that we can relocate images
> |      0140:        # and still run them
> |  *** 0141:        if val.startswith(topdir):
> |      0142:            val = os.path.relpath(val, finalpath)
> |      0143:        cf.set('config_bsp', k, '%s' % val)
> |      0144:
> |      0145:    # QB_DEFAULT_KERNEL's value of KERNEL_IMAGETYPE is the name of a symlink
> | Exception: AttributeError: 'NoneType' object has no attribute 'startswith'

Fix is in master-next.

Alex


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
  2022-02-04 20:40 [PATCH] runqemu: preload uninative libraries when host gl drivers are in use Alexander Kanavin
                   ` (3 preceding siblings ...)
  2022-02-12 13:18 ` Enrico Scholz
@ 2022-10-21 15:27 ` Joshua Watt
  2022-10-21 15:43   ` Alexander Kanavin
  4 siblings, 1 reply; 14+ messages in thread
From: Joshua Watt @ 2022-10-21 15:27 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: openembedded-core, Alexander Kanavin

This patch broke runqemu for me when I moved to kirkstone. I get this error:

 /bin/sh: symbol lookup error:
/grmn/prj/mrn/alchemy/build/tmp/eng/kirkstone/tetra/sysroots-uninative/x86_64-linux/lib/librt.so.1:
undefined symbol: __libc_unwind_link_get, version GLIBC_PRIVATE

And I'm not sure how to fix it. Reverting this change does resolve the problem.

My host is Ubuntu 20.04



On Fri, Feb 4, 2022 at 2:40 PM Alexander Kanavin <alex.kanavin@gmail.com> wrote:
>
> 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>
> ---
>  meta/classes/qemuboot.bbclass | 2 +-
>  scripts/runqemu               | 4 ++++
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
> index cc1cbce69d..229bd88527 100644
> --- a/meta/classes/qemuboot.bbclass
> +++ b/meta/classes/qemuboot.bbclass
> @@ -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))}"
> diff --git a/scripts/runqemu b/scripts/runqemu
> index 4e05c1bb15..7d1f85f357 100755
> --- a/scripts/runqemu
> +++ b/scripts/runqemu
> @@ -460,6 +460,10 @@ class BaseConfig(object):
>          except subprocess.CalledProcessError as e:
>              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()
> +        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
> +        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
> +        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"):
> --
> 2.20.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#161382): https://lists.openembedded.org/g/openembedded-core/message/161382
> Mute This Topic: https://lists.openembedded.org/mt/88916306/3616693
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [JPEWhacker@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
  2022-10-21 15:27 ` Joshua Watt
@ 2022-10-21 15:43   ` Alexander Kanavin
  2022-10-21 15:48     ` Joshua Watt
  0 siblings, 1 reply; 14+ messages in thread
From: Alexander Kanavin @ 2022-10-21 15:43 UTC (permalink / raw)
  To: Joshua Watt; +Cc: openembedded-core, Alexander Kanavin

This is the first time I hear about this - can you find out what is
expecting the symbol, and where it's supposed to come from?

Alex

On Fri, 21 Oct 2022 at 17:27, Joshua Watt <jpewhacker@gmail.com> wrote:
>
> This patch broke runqemu for me when I moved to kirkstone. I get this error:
>
>  /bin/sh: symbol lookup error:
> /grmn/prj/mrn/alchemy/build/tmp/eng/kirkstone/tetra/sysroots-uninative/x86_64-linux/lib/librt.so.1:
> undefined symbol: __libc_unwind_link_get, version GLIBC_PRIVATE
>
> And I'm not sure how to fix it. Reverting this change does resolve the problem.
>
> My host is Ubuntu 20.04
>
>
>
> On Fri, Feb 4, 2022 at 2:40 PM Alexander Kanavin <alex.kanavin@gmail.com> wrote:
> >
> > 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>
> > ---
> >  meta/classes/qemuboot.bbclass | 2 +-
> >  scripts/runqemu               | 4 ++++
> >  2 files changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
> > index cc1cbce69d..229bd88527 100644
> > --- a/meta/classes/qemuboot.bbclass
> > +++ b/meta/classes/qemuboot.bbclass
> > @@ -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))}"
> > diff --git a/scripts/runqemu b/scripts/runqemu
> > index 4e05c1bb15..7d1f85f357 100755
> > --- a/scripts/runqemu
> > +++ b/scripts/runqemu
> > @@ -460,6 +460,10 @@ class BaseConfig(object):
> >          except subprocess.CalledProcessError as e:
> >              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()
> > +        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
> > +        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
> > +        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"):
> > --
> > 2.20.1
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#161382): https://lists.openembedded.org/g/openembedded-core/message/161382
> > Mute This Topic: https://lists.openembedded.org/mt/88916306/3616693
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [JPEWhacker@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
  2022-10-21 15:43   ` Alexander Kanavin
@ 2022-10-21 15:48     ` Joshua Watt
  2022-10-21 15:54       ` Alexander Kanavin
  0 siblings, 1 reply; 14+ messages in thread
From: Joshua Watt @ 2022-10-21 15:48 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: openembedded-core, Alexander Kanavin

Ya I've tracked it down to when qemu invokes the qemu-oe-bridge-helper 
to setup network bridging. This is a shell script that uses /bin/sh, and 
as the log indicates, /bin/sh can't find the required symbols to start 
up (and qemu fails).

I also see it when runqemu attempt so to invoke the stty program to 
cleanup the console after qemu runs for the same reason. This one is a 
little easier to fix; I have a prototype patch that only passes the 
munged environment that sets LD_PRELOAD when runqemu actually invokes 
qemu by passing env= to subprocess. The other process invocations with 
subprcess are not passed this environment, so they don't see the 
LD_PRELOAD. This doesn't fix the bridge problem however because in that 
case, qemu is invoking the script so the script inherits qemu's environment.

On 10/21/22 10:43, Alexander Kanavin wrote:
> This is the first time I hear about this - can you find out what is
> expecting the symbol, and where it's supposed to come from?
>
> Alex
>
> On Fri, 21 Oct 2022 at 17:27, Joshua Watt <jpewhacker@gmail.com> wrote:
>> This patch broke runqemu for me when I moved to kirkstone. I get this error:
>>
>>   /bin/sh: symbol lookup error:
>> /grmn/prj/mrn/alchemy/build/tmp/eng/kirkstone/tetra/sysroots-uninative/x86_64-linux/lib/librt.so.1:
>> undefined symbol: __libc_unwind_link_get, version GLIBC_PRIVATE
>>
>> And I'm not sure how to fix it. Reverting this change does resolve the problem.
>>
>> My host is Ubuntu 20.04
>>
>>
>>
>> On Fri, Feb 4, 2022 at 2:40 PM Alexander Kanavin <alex.kanavin@gmail.com> wrote:
>>> 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>
>>> ---
>>>   meta/classes/qemuboot.bbclass | 2 +-
>>>   scripts/runqemu               | 4 ++++
>>>   2 files changed, 5 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
>>> index cc1cbce69d..229bd88527 100644
>>> --- a/meta/classes/qemuboot.bbclass
>>> +++ b/meta/classes/qemuboot.bbclass
>>> @@ -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))}"
>>> diff --git a/scripts/runqemu b/scripts/runqemu
>>> index 4e05c1bb15..7d1f85f357 100755
>>> --- a/scripts/runqemu
>>> +++ b/scripts/runqemu
>>> @@ -460,6 +460,10 @@ class BaseConfig(object):
>>>           except subprocess.CalledProcessError as e:
>>>               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()
>>> +        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
>>> +        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
>>> +        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"):
>>> --
>>> 2.20.1
>>>
>>>
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>> Links: You receive all messages sent to this group.
>>> View/Reply Online (#161382): https://lists.openembedded.org/g/openembedded-core/message/161382
>>> Mute This Topic: https://lists.openembedded.org/mt/88916306/3616693
>>> Group Owner: openembedded-core+owner@lists.openembedded.org
>>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [JPEWhacker@gmail.com]
>>> -=-=-=-=-=-=-=-=-=-=-=-
>>>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
  2022-10-21 15:48     ` Joshua Watt
@ 2022-10-21 15:54       ` Alexander Kanavin
  2022-10-21 16:21         ` Joshua Watt
  0 siblings, 1 reply; 14+ messages in thread
From: Alexander Kanavin @ 2022-10-21 15:54 UTC (permalink / raw)
  To: Joshua Watt; +Cc: openembedded-core, Alexander Kanavin

I think we had a similar problem in rust, and I ended up rewriting the
shell script in python and running it with nativepython3 :-)

Alex

On Fri, 21 Oct 2022 at 17:48, Joshua Watt <jpewhacker@gmail.com> wrote:
>
> Ya I've tracked it down to when qemu invokes the qemu-oe-bridge-helper
> to setup network bridging. This is a shell script that uses /bin/sh, and
> as the log indicates, /bin/sh can't find the required symbols to start
> up (and qemu fails).
>
> I also see it when runqemu attempt so to invoke the stty program to
> cleanup the console after qemu runs for the same reason. This one is a
> little easier to fix; I have a prototype patch that only passes the
> munged environment that sets LD_PRELOAD when runqemu actually invokes
> qemu by passing env= to subprocess. The other process invocations with
> subprcess are not passed this environment, so they don't see the
> LD_PRELOAD. This doesn't fix the bridge problem however because in that
> case, qemu is invoking the script so the script inherits qemu's environment.
>
> On 10/21/22 10:43, Alexander Kanavin wrote:
> > This is the first time I hear about this - can you find out what is
> > expecting the symbol, and where it's supposed to come from?
> >
> > Alex
> >
> > On Fri, 21 Oct 2022 at 17:27, Joshua Watt <jpewhacker@gmail.com> wrote:
> >> This patch broke runqemu for me when I moved to kirkstone. I get this error:
> >>
> >>   /bin/sh: symbol lookup error:
> >> /grmn/prj/mrn/alchemy/build/tmp/eng/kirkstone/tetra/sysroots-uninative/x86_64-linux/lib/librt.so.1:
> >> undefined symbol: __libc_unwind_link_get, version GLIBC_PRIVATE
> >>
> >> And I'm not sure how to fix it. Reverting this change does resolve the problem.
> >>
> >> My host is Ubuntu 20.04
> >>
> >>
> >>
> >> On Fri, Feb 4, 2022 at 2:40 PM Alexander Kanavin <alex.kanavin@gmail.com> wrote:
> >>> 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>
> >>> ---
> >>>   meta/classes/qemuboot.bbclass | 2 +-
> >>>   scripts/runqemu               | 4 ++++
> >>>   2 files changed, 5 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
> >>> index cc1cbce69d..229bd88527 100644
> >>> --- a/meta/classes/qemuboot.bbclass
> >>> +++ b/meta/classes/qemuboot.bbclass
> >>> @@ -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))}"
> >>> diff --git a/scripts/runqemu b/scripts/runqemu
> >>> index 4e05c1bb15..7d1f85f357 100755
> >>> --- a/scripts/runqemu
> >>> +++ b/scripts/runqemu
> >>> @@ -460,6 +460,10 @@ class BaseConfig(object):
> >>>           except subprocess.CalledProcessError as e:
> >>>               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()
> >>> +        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
> >>> +        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
> >>> +        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"):
> >>> --
> >>> 2.20.1
> >>>
> >>>
> >>> -=-=-=-=-=-=-=-=-=-=-=-
> >>> Links: You receive all messages sent to this group.
> >>> View/Reply Online (#161382): https://lists.openembedded.org/g/openembedded-core/message/161382
> >>> Mute This Topic: https://lists.openembedded.org/mt/88916306/3616693
> >>> Group Owner: openembedded-core+owner@lists.openembedded.org
> >>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [JPEWhacker@gmail.com]
> >>> -=-=-=-=-=-=-=-=-=-=-=-
> >>>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [OE-core] [PATCH] runqemu: preload uninative libraries when host gl drivers are in use
  2022-10-21 15:54       ` Alexander Kanavin
@ 2022-10-21 16:21         ` Joshua Watt
  0 siblings, 0 replies; 14+ messages in thread
From: Joshua Watt @ 2022-10-21 16:21 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: openembedded-core, Alexander Kanavin

On Fri, Oct 21, 2022 at 10:54 AM Alexander Kanavin
<alex.kanavin@gmail.com> wrote:
>
> I think we had a similar problem in rust, and I ended up rewriting the
> shell script in python and running it with nativepython3 :-)

I had to re-write the script to be a C program because there wasn't
any way to make qemu find and invoke nativepython3, but that appears
to work. I'll send a patch

>
> Alex
>
> On Fri, 21 Oct 2022 at 17:48, Joshua Watt <jpewhacker@gmail.com> wrote:
> >
> > Ya I've tracked it down to when qemu invokes the qemu-oe-bridge-helper
> > to setup network bridging. This is a shell script that uses /bin/sh, and
> > as the log indicates, /bin/sh can't find the required symbols to start
> > up (and qemu fails).
> >
> > I also see it when runqemu attempt so to invoke the stty program to
> > cleanup the console after qemu runs for the same reason. This one is a
> > little easier to fix; I have a prototype patch that only passes the
> > munged environment that sets LD_PRELOAD when runqemu actually invokes
> > qemu by passing env= to subprocess. The other process invocations with
> > subprcess are not passed this environment, so they don't see the
> > LD_PRELOAD. This doesn't fix the bridge problem however because in that
> > case, qemu is invoking the script so the script inherits qemu's environment.
> >
> > On 10/21/22 10:43, Alexander Kanavin wrote:
> > > This is the first time I hear about this - can you find out what is
> > > expecting the symbol, and where it's supposed to come from?
> > >
> > > Alex
> > >
> > > On Fri, 21 Oct 2022 at 17:27, Joshua Watt <jpewhacker@gmail.com> wrote:
> > >> This patch broke runqemu for me when I moved to kirkstone. I get this error:
> > >>
> > >>   /bin/sh: symbol lookup error:
> > >> /grmn/prj/mrn/alchemy/build/tmp/eng/kirkstone/tetra/sysroots-uninative/x86_64-linux/lib/librt.so.1:
> > >> undefined symbol: __libc_unwind_link_get, version GLIBC_PRIVATE
> > >>
> > >> And I'm not sure how to fix it. Reverting this change does resolve the problem.
> > >>
> > >> My host is Ubuntu 20.04
> > >>
> > >>
> > >>
> > >> On Fri, Feb 4, 2022 at 2:40 PM Alexander Kanavin <alex.kanavin@gmail.com> wrote:
> > >>> 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>
> > >>> ---
> > >>>   meta/classes/qemuboot.bbclass | 2 +-
> > >>>   scripts/runqemu               | 4 ++++
> > >>>   2 files changed, 5 insertions(+), 1 deletion(-)
> > >>>
> > >>> diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
> > >>> index cc1cbce69d..229bd88527 100644
> > >>> --- a/meta/classes/qemuboot.bbclass
> > >>> +++ b/meta/classes/qemuboot.bbclass
> > >>> @@ -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))}"
> > >>> diff --git a/scripts/runqemu b/scripts/runqemu
> > >>> index 4e05c1bb15..7d1f85f357 100755
> > >>> --- a/scripts/runqemu
> > >>> +++ b/scripts/runqemu
> > >>> @@ -460,6 +460,10 @@ class BaseConfig(object):
> > >>>           except subprocess.CalledProcessError as e:
> > >>>               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()
> > >>> +        uninative_path = os.path.dirname(self.get("UNINATIVE_LOADER"))
> > >>> +        preload_items = ['libdl.so.2', 'librt.so.1', 'libpthread.so.0']
> > >>> +        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"):
> > >>> --
> > >>> 2.20.1
> > >>>
> > >>>
> > >>> -=-=-=-=-=-=-=-=-=-=-=-
> > >>> Links: You receive all messages sent to this group.
> > >>> View/Reply Online (#161382): https://lists.openembedded.org/g/openembedded-core/message/161382
> > >>> Mute This Topic: https://lists.openembedded.org/mt/88916306/3616693
> > >>> Group Owner: openembedded-core+owner@lists.openembedded.org
> > >>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [JPEWhacker@gmail.com]
> > >>> -=-=-=-=-=-=-=-=-=-=-=-
> > >>>


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-10-21 16:21 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-04 20:40 [PATCH] runqemu: preload uninative libraries when host gl drivers are in use Alexander Kanavin
2022-02-04 21:17 ` [OE-core] " Christopher Larson
2022-02-04 21:30   ` Alexander Kanavin
2022-02-05 12:20 ` Richard Purdie
     [not found] ` <16D0E3273582D58F.23031@lists.openembedded.org>
2022-02-06  9:51   ` Richard Purdie
     [not found]   ` <16D1299F302D38AC.20549@lists.openembedded.org>
2022-02-06  9:57     ` Richard Purdie
2022-02-06 10:13       ` Alexander Kanavin
2022-02-12 13:18 ` Enrico Scholz
2022-02-12 13:22   ` Alexander Kanavin
2022-10-21 15:27 ` Joshua Watt
2022-10-21 15:43   ` Alexander Kanavin
2022-10-21 15:48     ` Joshua Watt
2022-10-21 15:54       ` Alexander Kanavin
2022-10-21 16:21         ` Joshua Watt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.