diff mbox series

rust: conditionally copy tools like rustfmt

Message ID 20220820022910.173452-1-Randy.MacLeod@windriver.com
State New
Headers show
Series rust: conditionally copy tools like rustfmt | expand

Commit Message

Randy MacLeod Aug. 20, 2022, 2:29 a.m. UTC
For qemuppc/mips, rustfmt isn't being built so check
that it and related tools exist before copying them.
qemuppc/mips are not well-supported in the Rust world
but will work to get the build to fixed later.

Signed-off-by: Randy MacLeod <Randy.MacLeod@windriver.com>
---
 meta/recipes-devtools/rust/rust_1.63.0.bb | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Richard Purdie Aug. 25, 2022, 9:46 a.m. UTC | #1
On Fri, 2022-08-19 at 19:29 -0700, Randy MacLeod wrote:
> For qemuppc/mips, rustfmt isn't being built so check
> that it and related tools exist before copying them.
> qemuppc/mips are not well-supported in the Rust world
> but will work to get the build to fixed later.
> 
> Signed-off-by: Randy MacLeod <Randy.MacLeod@windriver.com>
> ---
>  meta/recipes-devtools/rust/rust_1.63.0.bb | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/meta/recipes-devtools/rust/rust_1.63.0.bb b/meta/recipes-devtools/rust/rust_1.63.0.bb
> index 3081cd5ef3..050f398794 100644
> --- a/meta/recipes-devtools/rust/rust_1.63.0.bb
> +++ b/meta/recipes-devtools/rust/rust_1.63.0.bb
> @@ -43,8 +43,10 @@ rust_do_install:class-nativesdk() {
>  
>      install -d ${D}${bindir}
>      for i in cargo-clippy clippy-driver rustfmt; do
> -        cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir}
> -        chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
> +        if [ -e build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ]; then
> +            cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir}
> +            chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
> +        fi
>      done
>  
>      chown root:root ${D}/ -R
> @@ -60,8 +62,10 @@ rust_do_install:class-target() {
>  
>      install -d ${D}${bindir}
>      for i in cargo-clippy clippy-driver rustfmt; do
> -        cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir}
> -        chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
> +        if [ -e build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ]; then
> +            cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir}
> +            chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
> +        fi
>      done
>  
>      chown root:root ${D}/ -R


I did look into this a bit. The compile logs for ppc are full of
horrible warnings and I have patches to clean that up. Once that is
done, it comes down to crossbeam-utils trying to use AtomicI64 which
doesn't exist on mips or powerpc 32 bit.

https://github.com/tikv/rust-prometheus/issues/315

has some interesting info.

error[E0412]: cannot find type `AtomicU64` in module `core::sync::atomic`
  --> /usr/src/debug/rust/1.63.0-r0/rustc-1.63.0-src/vendor/crossbeam-utils/src/atomic/consume.rs:78:14
   |
78 |   impl_atomic!(AtomicU64, u64);
   |                ^^^^^^^^^ help: a struct with a similar name exists: `AtomicU16`

error[E0412]: cannot find type `AtomicI64` in module `core::sync::atomic`

Digging further crossbeam-utils has a no_atomics.rs file listing all
the triplets that can't use atomic or have limited 64 bit ones.

Sadly those triplets don't match the ones were using as we have
TARGET_VENDOR in ours, for reasons. That will be why it breaks.

I'm trying a patch which changes TARGET_VENDOR -> "-unknown" but I've
never written rust code and it takes an age to cycle through so we'll
see...

Cheers,

Richard
Alexander Kanavin Aug. 25, 2022, 10:07 a.m. UTC | #2
On Thu, 25 Aug 2022 at 11:46, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> Digging further crossbeam-utils has a no_atomics.rs file listing all
> the triplets that can't use atomic or have limited 64 bit ones.
>
> Sadly those triplets don't match the ones were using as we have
> TARGET_VENDOR in ours, for reasons. That will be why it breaks.

Not sure if this helps, but librsvg deals with it thusly:

RUSTFLAGS:append:mips = " --cfg crossbeam_no_atomic_64"
RUSTFLAGS:append:mipsel = " --cfg crossbeam_no_atomic_64"
RUSTFLAGS:append:powerpc = " --cfg crossbeam_no_atomic_64"
RUSTFLAGS:append:riscv32 = " --cfg crossbeam_no_atomic_64"

(it's perhaps worth investigating how this flag is used there)

Alex
diff mbox series

Patch

diff --git a/meta/recipes-devtools/rust/rust_1.63.0.bb b/meta/recipes-devtools/rust/rust_1.63.0.bb
index 3081cd5ef3..050f398794 100644
--- a/meta/recipes-devtools/rust/rust_1.63.0.bb
+++ b/meta/recipes-devtools/rust/rust_1.63.0.bb
@@ -43,8 +43,10 @@  rust_do_install:class-nativesdk() {
 
     install -d ${D}${bindir}
     for i in cargo-clippy clippy-driver rustfmt; do
-        cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir}
-        chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
+        if [ -e build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ]; then
+            cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir}
+            chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
+        fi
     done
 
     chown root:root ${D}/ -R
@@ -60,8 +62,10 @@  rust_do_install:class-target() {
 
     install -d ${D}${bindir}
     for i in cargo-clippy clippy-driver rustfmt; do
-        cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir}
-        chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
+        if [ -e build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ]; then
+            cp build/${RUST_BUILD_SYS}/stage2-tools/${RUST_HOST_SYS}/release/$i ${D}${bindir}
+            chrpath -r "\$ORIGIN/../lib" ${D}${bindir}/$i
+        fi
     done
 
     chown root:root ${D}/ -R