From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Khem Raj <raj.khem@gmail.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [PATCH] rust: Use llvm-config from native llvm-rust on rust target builds
Date: Mon, 15 Jan 2024 17:49:48 +0000 [thread overview]
Message-ID: <00252e76cee7b3dfe4ed1abbb200b22e85608df4.camel@linuxfoundation.org> (raw)
In-Reply-To: <CAMKF1sph2E72GXvpy43X9Ow+=PDk01F+465HRJ-Xa1ZxpFaQtw@mail.gmail.com>
On Mon, 2024-01-15 at 08:56 -0800, Khem Raj wrote:
> Hi
>
> On Mon, Jan 15, 2024 at 5:19 AM Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> > On Sat, 2024-01-13 at 21:58 -0800, Khem Raj wrote:
> > > target rust recipe builds ( cross compile ) calls llvm-config
> > > from
> > > target sysroot which works ok as long as C++ runtime it needs is
> > > available on build host e.g. libstdc++ etc. which is commonly the
> > > case, however when using clang and llvm runtime this falters
> > > since
> > > it should be using libc++ from native sysroot and if this does
> > > not
> > > exist on build machine this fails to find libc++ shared object
> > > and
> > > llvm-config fails to run. This ensures that llvm-config version
> > > in
> > > use is correctly relocated and can use shared libraries from
> > > native
> > > sysroot correctly. Adding ORIGIN to sysroot will look for the .so
> > > in
> > > same dir as the binary and there is the libc++.so.1 copied in
> > > place
> > >
> > > Fixes rust build with clang compiler.
> > >
> > > > /mnt/b/yoe/master/build/tmp/work/riscv64-yoe-
> > > > linux/rust/1.74.1/recipe-sysroot/usr/lib/llvm-rust/bin/llvm-
> > > > config: error while loading shared libraries: libc++.so.1:
> > > > cannot open shared object file: No such file or director
> > > y
> > > > thread 'main' panicked at llvm.rs:551:19:
> > > > command did not execute successfully:
> > > > "/mnt/b/yoe/master/build/tmp/work/riscv64-yoe-
> > > > linux/rust/1.74.1/recipe-sysroot/usr/lib/llvm-rust/bin/llvm-
> > > > config" "--version"
> > > > expected success, got: exit status: 127
> > >
> > > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > > ---
> > > meta/recipes-devtools/rust/rust_1.74.1.bb | 8 ++++++--
> > > 1 file changed, 6 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/meta/recipes-devtools/rust/rust_1.74.1.bb
> > > b/meta/recipes-devtools/rust/rust_1.74.1.bb
> > > index 30543ada7db..2dffe009827 100644
> > > --- a/meta/recipes-devtools/rust/rust_1.74.1.bb
> > > +++ b/meta/recipes-devtools/rust/rust_1.74.1.bb
> > > @@ -198,9 +198,13 @@ rust_runx () {
> > > # Copy the natively built llvm-config into the target so we
> > > can run it. Horrible,
> > > # but works!
> > > if [ ${RUST_ALTERNATE_EXE_PATH_NATIVE} !=
> > > ${RUST_ALTERNATE_EXE_PATH} -a ! -f ${RUST_ALTERNATE_EXE_PATH} ];
> > > then
> > > - mkdir -p `dirname ${RUST_ALTERNATE_EXE_PATH}`
> > > + tgtdir=`dirname ${RUST_ALTERNATE_EXE_PATH}`
> > > + mkdir -p ${tgtdir}
> > > cp ${RUST_ALTERNATE_EXE_PATH_NATIVE}
> > > ${RUST_ALTERNATE_EXE_PATH}
> > > - chrpath -d ${RUST_ALTERNATE_EXE_PATH}
> > > + if [ -e ${STAGING_LIBDIR_NATIVE}/libc++.so.1 ]; then
> > > + cp ${STAGING_LIBDIR_NATIVE}/libc++.so.1 ${tgtdir}/
> > > + fi
> > > + chrpath -r \$ORIGIN ${RUST_ALTERNATE_EXE_PATH}
> > > fi
> > >
> > > oe_cargo_fix_env
> >
> > Copying a native library into the target sysroot goes beyond what
> > I'm
> > comfortable with even for this horrible hack with llvm-config.
> >
>
>
> It’s just supporting the original hack to work properly I don’t think
> it’s any worse that the original hack
Putting a non-target library into the target sysroot could cause all
kinds of problems if the target and native are similar enough the
libraries can be seen and confused by the linker. I do see that as a
big and potentially very dangerous difference.
> >
> >
> > Since it seems to be finding it by RPATH, can you not just add an
> > RPATH
> > to the native sysroot in the binary?
> >
>
>
> It does not work and I don’t know why but seems rpath in llvm-config
> affects what paths it spits out
I am reluctant to take this without a better understanding of what is
going on here. We may need to fix the lvm-config issues properly.
Cheers,
Richard
next prev parent reply other threads:[~2024-01-15 17:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-14 5:58 [PATCH] rust: Use llvm-config from native llvm-rust on rust target builds Khem Raj
2024-01-15 13:19 ` [OE-core] " Richard Purdie
2024-01-15 16:56 ` Khem Raj
2024-01-15 17:49 ` Richard Purdie [this message]
2024-01-15 20:52 ` Khem Raj
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=00252e76cee7b3dfe4ed1abbb200b22e85608df4.camel@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=openembedded-core@lists.openembedded.org \
--cc=raj.khem@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.