diff mbox series

mesa: fix runpath with native llvm-config in target sysroot

Message ID 20221109030444.2414546-1-maxime.roussinbelanger@gmail.com
State New
Headers show
Series mesa: fix runpath with native llvm-config in target sysroot | expand

Commit Message

Maxime Roussin-Bélanger Nov. 9, 2022, 3:04 a.m. UTC
From: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>

llvm-config is copied from native to target sysroot, it shouldn't be
allowed to use target shared libraries when it loads.

Remove all runpath so it uses shared library from host system since
native llvm-config is compiled with hosttools compiler.

Signed-off-by: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>
---
 meta/recipes-graphics/mesa/mesa.inc | 1 +
 1 file changed, 1 insertion(+)

Comments

Alexandre Belloni Nov. 9, 2022, 8:48 p.m. UTC | #1
Hello,

On 08/11/2022 22:04:44-0500, Maxime Roussin-B�langer wrote:
> From: Maxime Roussin-B�langer <maxime.roussinbelanger@gmail.com>
> 
> llvm-config is copied from native to target sysroot, it shouldn't be
> allowed to use target shared libraries when it loads.
> 
> Remove all runpath so it uses shared library from host system since
> native llvm-config is compiled with hosttools compiler.
> 

I believe this is the cause of:
https://autobuilder.yoctoproject.org/typhoon/#/builders/72/builds/6139/steps/32/logs/stdio

I'm currently checking

> Signed-off-by: Maxime Roussin-B�langer <maxime.roussinbelanger@gmail.com>
> ---
>  meta/recipes-graphics/mesa/mesa.inc | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
> index 67cfb4f6c1..abc2c3f4c4 100644
> --- a/meta/recipes-graphics/mesa/mesa.inc
> +++ b/meta/recipes-graphics/mesa/mesa.inc
> @@ -61,6 +61,7 @@ do_configure:prepend () {
>  	if [ -e ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE} ]; then
>  		cp ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE} ${STAGING_BINDIR}
>  		cp ${STAGING_BINDIR_NATIVE}/llvm-config ${STAGING_BINDIR}
> +		chrpath -d ${STAGING_BINDIR}/llvm-config
>  	fi
>  }
>  
> -- 
> 2.36.0
> 

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#173009): https://lists.openembedded.org/g/openembedded-core/message/173009
> Mute This Topic: https://lists.openembedded.org/mt/94906155/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Maxime Roussin-Bélanger Nov. 9, 2022, 9:04 p.m. UTC | #2
Hi, (sorry for 2nd message Alex, forgot to cc the list)

On Wed, Nov 9, 2022 at 3:48 PM Alexandre Belloni <
alexandre.belloni@bootlin.com> wrote:

> Hello,
>
> On 08/11/2022 22:04:44-0500, Maxime Roussin-Bélanger wrote:
> > From: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>
> >
> > llvm-config is copied from native to target sysroot, it shouldn't be
> > allowed to use target shared libraries when it loads.
> >
> > Remove all runpath so it uses shared library from host system since
> > native llvm-config is compiled with hosttools compiler.
> >
>
> I believe this is the cause of:
>
> https://autobuilder.yoctoproject.org/typhoon/#/builders/72/builds/6139/steps/32/logs/stdio


The patch does fix that problem on my end.


>
>
> I'm currently checking
>
> > Signed-off-by: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com
> >
> > ---
> >  meta/recipes-graphics/mesa/mesa.inc | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/meta/recipes-graphics/mesa/mesa.inc
> b/meta/recipes-graphics/mesa/mesa.inc
> > index 67cfb4f6c1..abc2c3f4c4 100644
> > --- a/meta/recipes-graphics/mesa/mesa.inc
> > +++ b/meta/recipes-graphics/mesa/mesa.inc
> > @@ -61,6 +61,7 @@ do_configure:prepend () {
> >       if [ -e ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE}
> ]; then
> >               cp
> ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE} ${STAGING_BINDIR}
> >               cp ${STAGING_BINDIR_NATIVE}/llvm-config ${STAGING_BINDIR}
> > +             chrpath -d ${STAGING_BINDIR}/llvm-config
> >       fi
> >  }
> >
> > --
> > 2.36.0
> >
>
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#173009):
> https://lists.openembedded.org/g/openembedded-core/message/173009
> > Mute This Topic: https://lists.openembedded.org/mt/94906155/3617179
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> alexandre.belloni@bootlin.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>
>
> --
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
Alexandre Belloni Nov. 9, 2022, 9:23 p.m. UTC | #3
On 09/11/2022 16:04:11-0500, Maxime Roussin-B�langer wrote:
> Hi, (sorry for 2nd message Alex, forgot to cc the list)
> 
> On Wed, Nov 9, 2022 at 3:48 PM Alexandre Belloni <
> alexandre.belloni@bootlin.com> wrote:
> 
> > Hello,
> >
> > On 08/11/2022 22:04:44-0500, Maxime Roussin-B�langer wrote:
> > > From: Maxime Roussin-B�langer <maxime.roussinbelanger@gmail.com>
> > >
> > > llvm-config is copied from native to target sysroot, it shouldn't be
> > > allowed to use target shared libraries when it loads.
> > >
> > > Remove all runpath so it uses shared library from host system since
> > > native llvm-config is compiled with hosttools compiler.
> > >
> >
> > I believe this is the cause of:
> >
> > https://autobuilder.yoctoproject.org/typhoon/#/builders/72/builds/6139/steps/32/logs/stdio
> 
> 
> The patch does fix that problem on my end.
> 

Well, it doesn't seem to be the cause but it doesn't fix it either...
I'm going to run it again using the same worker.

> 
> >
> >
> > I'm currently checking
> >
> > > Signed-off-by: Maxime Roussin-B�langer <maxime.roussinbelanger@gmail.com
> > >
> > > ---
> > >  meta/recipes-graphics/mesa/mesa.inc | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/meta/recipes-graphics/mesa/mesa.inc
> > b/meta/recipes-graphics/mesa/mesa.inc
> > > index 67cfb4f6c1..abc2c3f4c4 100644
> > > --- a/meta/recipes-graphics/mesa/mesa.inc
> > > +++ b/meta/recipes-graphics/mesa/mesa.inc
> > > @@ -61,6 +61,7 @@ do_configure:prepend () {
> > >       if [ -e ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE}
> > ]; then
> > >               cp
> > ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE} ${STAGING_BINDIR}
> > >               cp ${STAGING_BINDIR_NATIVE}/llvm-config ${STAGING_BINDIR}
> > > +             chrpath -d ${STAGING_BINDIR}/llvm-config
> > >       fi
> > >  }
> > >
> > > --
> > > 2.36.0
> > >
> >
> > >
> > > 
> > >
> >
> >
> > --
> > Alexandre Belloni, co-owner and COO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com
> >

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#173058): https://lists.openembedded.org/g/openembedded-core/message/173058
> Mute This Topic: https://lists.openembedded.org/mt/94906155/3617179
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Maxime Roussin-Bélanger Nov. 9, 2022, 9:42 p.m. UTC | #4
On Wed, Nov 9, 2022 at 4:23 PM Alexandre Belloni <
alexandre.belloni@bootlin.com> wrote:

> On 09/11/2022 16:04:11-0500, Maxime Roussin-Bélanger wrote:
> > Hi, (sorry for 2nd message Alex, forgot to cc the list)
> >
> > On Wed, Nov 9, 2022 at 3:48 PM Alexandre Belloni <
> > alexandre.belloni@bootlin.com> wrote:
> >
> > > Hello,
> > >
> > > On 08/11/2022 22:04:44-0500, Maxime Roussin-Bélanger wrote:
> > > > From: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>
> > > >
> > > > llvm-config is copied from native to target sysroot, it shouldn't be
> > > > allowed to use target shared libraries when it loads.
> > > >
> > > > Remove all runpath so it uses shared library from host system since
> > > > native llvm-config is compiled with hosttools compiler.
> > > >
> > >
> > > I believe this is the cause of:
> > >
> > >
> https://autobuilder.yoctoproject.org/typhoon/#/builders/72/builds/6139/steps/32/logs/stdio
> >
> >
> > The patch does fix that problem on my end.
> >
>
> Well, it doesn't seem to be the cause but it doesn't fix it either...
> I'm going to run it again using the same worker.
>

From what I gathered when debugging this, llvm-config was loading shared
libraries of the target sysroot because
of runpath. When mesa is configuring with gallium it invokes llvm-config
which can fail for illegal instructions because
of shared libraries of the target sysroot.

By removing runpath from the binary it should load libraries from thost
where native llvm-config is built from.

Max.


>
> >
> > >
> > >
> > > I'm currently checking
> > >
> > > > Signed-off-by: Maxime Roussin-Bélanger <
> maxime.roussinbelanger@gmail.com
> > > >
> > > > ---
> > > >  meta/recipes-graphics/mesa/mesa.inc | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > >
> > > > diff --git a/meta/recipes-graphics/mesa/mesa.inc
> > > b/meta/recipes-graphics/mesa/mesa.inc
> > > > index 67cfb4f6c1..abc2c3f4c4 100644
> > > > --- a/meta/recipes-graphics/mesa/mesa.inc
> > > > +++ b/meta/recipes-graphics/mesa/mesa.inc
> > > > @@ -61,6 +61,7 @@ do_configure:prepend () {
> > > >       if [ -e
> ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE}
> > > ]; then
> > > >               cp
> > > ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE}
> ${STAGING_BINDIR}
> > > >               cp ${STAGING_BINDIR_NATIVE}/llvm-config
> ${STAGING_BINDIR}
> > > > +             chrpath -d ${STAGING_BINDIR}/llvm-config
> > > >       fi
> > > >  }
> > > >
> > > > --
> > > > 2.36.0
> > > >
> > >
> > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Alexandre Belloni, co-owner and COO, Bootlin
> > > Embedded Linux and Kernel engineering
> > > https://bootlin.com
> > >
>
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#173058):
> https://lists.openembedded.org/g/openembedded-core/message/173058
> > Mute This Topic: https://lists.openembedded.org/mt/94906155/3617179
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> alexandre.belloni@bootlin.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>
>
> --
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
Vincent Davis Jr Nov. 10, 2022, 4:50 a.m. UTC | #5
Haven't tested, but seems as above might fix the other gallium-llvm mesa issue I ran into when build for an x86_64 MACHINE.

# meson configure fails when the llvm-config --shared-mode command fails to find libs in ${STAGING_LIBDIR}
# Temp solution copy files from recipe-sysroot/usr/lib64 to recipe-sysroot/usr/lib where llvm-config
# command can find libraries.
do_configure:prepend() {
install -d "${STAGING_LIBDIR}/../lib"
cp -ra ${STAGING_LIBDIR}/* ${STAGING_LIBDIR}/../lib
}
diff mbox series

Patch

diff --git a/meta/recipes-graphics/mesa/mesa.inc b/meta/recipes-graphics/mesa/mesa.inc
index 67cfb4f6c1..abc2c3f4c4 100644
--- a/meta/recipes-graphics/mesa/mesa.inc
+++ b/meta/recipes-graphics/mesa/mesa.inc
@@ -61,6 +61,7 @@  do_configure:prepend () {
 	if [ -e ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE} ]; then
 		cp ${STAGING_BINDIR_NATIVE}/llvm-config${MESA_LLVM_RELEASE} ${STAGING_BINDIR}
 		cp ${STAGING_BINDIR_NATIVE}/llvm-config ${STAGING_BINDIR}
+		chrpath -d ${STAGING_BINDIR}/llvm-config
 	fi
 }