Skip to contentSkip to conversation

rust: Merge all rustc-source patches into rust-source.inc

PATCH In review Alex Kiernan 3 participants 11 messages Jan 7, 2023 – Jan 18, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rust: Merge all rustc-source patches into rust-source.inc

With the dim-sum approach to patching we had the same patch applied in many places, but not all, so that there were no guarantees that we were actually building agaginst the same thing in all recipes.

---
I've no actual evidence, but I wonder if this might help with
https://bugzilla.yoctoproject.org/show_bug.cgi?id=14975 as I tripped over this whilst doing these changes.

Changes in v2:
- Rebased

 meta/recipes-devtools/rust/cargo_1.66.0.bb    |  8 -------
 .../rust/{rust => files}/hardcodepaths.patch  |  0
 .../rust/{rust => files}/zlib-off64_t.patch   |  0
 meta/recipes-devtools/rust/rust-source.inc    | 22 +++++++++----------
 meta/recipes-devtools/rust/rust_1.66.0.bb     |  3 ---
 5 files changed, 10 insertions(+), 23 deletions(-)
 rename meta/recipes-devtools/rust/{rust => files}/hardcodepaths.patch (100%)
 rename meta/recipes-devtools/rust/{rust => files}/zlib-off64_t.patch (100%)
meta/recipes-devtools/rust/cargo_1.66.0.bb +0 -8
index f45f8f1e12d7..2b2394e898b5 100644
@@ -14,14 +14,6 @@ LIC_FILES_CHKSUM = " \
 require rust-source.inc
 require rust-snapshot.inc
 
-SRC_URI:append:class-target = "\
-    file://crossbeam_atomic.patch;patchdir=${RUSTSRC} \
-    file://getrandom-open64.patch;patchdir=${RUSTSRC} \                          
-"
-
-# Used by crossbeam_atomic.patch
-export TARGET_VENDOR
-
 S = "${RUSTSRC}/src/tools/cargo"
 CARGO_VENDORING_DIRECTORY = "${RUSTSRC}/vendor"
 
meta/recipes-devtools/rust/files/hardcodepaths.patch renamed from meta/recipes-devtools/rust/rust/hardcodepaths.patch +0 -0
similarity index 100%
rename from meta/recipes-devtools/rust/rust/hardcodepaths.patch
rename to meta/recipes-devtools/rust/files/hardcodepaths.patch
meta/recipes-devtools/rust/files/zlib-off64_t.patch renamed from meta/recipes-devtools/rust/rust/zlib-off64_t.patch +0 -0
similarity index 100%
rename from meta/recipes-devtools/rust/rust/zlib-off64_t.patch
rename to meta/recipes-devtools/rust/files/zlib-off64_t.patch
meta/recipes-devtools/rust/rust-source.inc +10 -12
index bfb625fb363d..6f1df4561b29 100644
@@ -1,21 +1,19 @@
 RUST_VERSION ?= "${@d.getVar('PV').split('-')[0]}"
-SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;name=rust"
-SRC_URI[rust.sha256sum] = "0dc176e34fae9871f855a6ba4cb30fa19d69c5b4428d29281a07419c4950715c"
 
-SRC_URI:append:class-target:pn-libstd-rs = "\
-    file://0001-Do-not-use-LFS64-on-linux-with-musl.patch;patchdir=../.. \
+SRC_URI += "https://static.rust-lang.org/dist/rustc-${RUST_VERSION}-src.tar.xz;name=rust \
+            file://crossbeam_atomic.patch;patchdir=${RUSTSRC} \
+            file://hardcodepaths.patch;patchdir=${RUSTSRC} \
+            file://getrandom-open64.patch;patchdir=${RUSTSRC} \
+            file://0001-Do-not-use-LFS64-on-linux-with-musl.patch;patchdir=${RUSTSRC} \
+            file://zlib-off64_t.patch;patchdir=${RUSTSRC} \
 "
-
-SRC_URI:append:class-target:pn-rust = " \
-    file://getrandom-open64.patch \
-    file://0001-Do-not-use-LFS64-on-linux-with-musl.patch \
-    file://zlib-off64_t.patch \
-    file://hardcodepaths.patch \
-    file://crossbeam_atomic.patch"
-SRC_URI:append:class-nativesdk:pn-nativesdk-rust = " file://hardcodepaths.patch"
+SRC_URI[rust.sha256sum] = "0dc176e34fae9871f855a6ba4cb30fa19d69c5b4428d29281a07419c4950715c"
 
 RUSTSRC = "${WORKDIR}/rustc-${RUST_VERSION}-src"
 
+# Used by crossbeam_atomic.patch
+export TARGET_VENDOR
+
 UPSTREAM_CHECK_URI = "https://forge.rust-lang.org/infra/other-installation-methods.html"
 UPSTREAM_CHECK_REGEX = "rustc-(?P<pver>\d+(\.\d+)+)-src"
 
meta/recipes-devtools/rust/rust_1.66.0.bb +0 -3
index f1ec769aef48..eba933ddeda4 100644
@@ -218,9 +218,6 @@ FILES:${PN} += "${libdir}/rustlib"
 FILES:${PN} += "${libdir}/*.so"
 FILES:${PN}-dev = ""
 
-# Used by crossbeam_atomic.patch
-export TARGET_VENDOR
-
 do_compile () {
     rust_runx build --stage 2
 }
Signature · 1 line
2.39.0
#1 lore raw

Hello Alex,

This patch fixed the https://bugzilla.yoctoproject.org/show_bug.cgi?id=14975 ( 'bitbake core-image-full-cmdline' built without any issues.)

But, I tried a ' hello world ' program in booted image (bitbake core-image-minimal by adding ' cargo ' to IMAGE_INSTALL:append) and getting below error.

root@qemux86-64:~/# cargo new hello
root@qemux86-64:~/# cd hello
root@qemux86-64:~/hello# cargo run
Compiling hello v0.1.0 (/home/root/hello)
error: linker `x86_64-poky-linux-gcc` not found
|
= note: No such file or directory (os error 2)

error: could not compile hello due to previous error

#2 lore raw

I guess we need to add a target RDEPENDS on gcc as its using that as the linker (possibly interesting upstream commentary
https://github.com/rust-lang/rust/issues/71515). I'm just wondering what happens if you have TOOLCHAIN = "clang"?

Quoted 25 lines · Sundeep

Hello Alex,

This patch fixed the https://bugzilla.yoctoproject.org/show_bug.cgi?id=14975 ('bitbake core-image-full-cmdline' built without any issues.)

But, I tried a 'hello world' program in booted image (bitbake core-image-minimal by adding 'cargo' to IMAGE_INSTALL:append) and getting below error.

root@qemux86-64:~/# cargo new hello
root@qemux86-64:~/# cd hello
root@qemux86-64:~/hello# cargo run
   Compiling hello v0.1.0 (/home/root/hello)
error: linker `x86_64-poky-linux-gcc` not found
  |
  = note: No such file or directory (os error 2)

error: could not compile hello due to previous error

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#175960): https://lists.openembedded.org/g/openembedded-core/message/175960
Mute This Topic: https://lists.openembedded.org/mt/96110740/3618097
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 1 line
Alex Kiernan
#3 lore raw

Adding 'IMAGE_INSTALL:append = " packagegroup-core-buildessential" ' fixed this linker issue.

#4 lore raw
Quoted 1 line · Sundeep via lists.openembedded.org

Adding 'IMAGE_INSTALL:append = " packagegroup-core-buildessential" '

Please make the target build of rust (cargo?) depend on just the parts need packagegroup-core-buildessential, i.e. you don't need autoconf, make, pkgconfig and likely more from the packagegroup shown below.

I'd assume that it's rust that need the linker rather than cargo, right?

../Randy

cat fd packagegroup-core-buildessential
#
# Copyright (C) 2007 OpenedHand Ltd.
# Copyright (C) 2012 Red Hat, Inc.
#

SUMMARY = "Essential build dependencies"

# libstdc++ gets debian renamed
PACKAGE_ARCH = "${TUNE_PKGARCH}"

inherit packagegroup

RDEPENDS:packagegroup-core-buildessential = "\
    autoconf \
    automake \
    binutils \
    binutils-symlinks \
    cpp \
    cpp-symlinks \
    gcc \
    gcc-symlinks \
    g++ \
    g++-symlinks \
    gettext \
    make \
    libstdc++ \
    libstdc++-dev \
    libtool \
    pkgconfig \
    "
Quoted 11 lines

fixed this linker issue.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#175980): https://lists.openembedded.org/g/openembedded-core/message/175980
Mute This Topic: https://lists.openembedded.org/mt/96110740/3616765
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 2 lines
# Randy MacLeod
# Wind River Linux
#5 lore raw

Yes, linker is needed by 'rust' and we checked that linker issue is solved by adding minimal required pkgs 'gcc g++ & binutils' instead of complete pkgs provided by ' packagegroup-core-buildessential'.

#6 lore raw
Quoted 2 lines · Sundeep

Yes, linker is needed by 'rust' and we checked that linker issue is solved by adding minimal required pkgs 'gcc g++ & binutils' instead of complete pkgs provided by 'packagegroup-core-buildessential'.

Does it really need g++? If it does, it does, it just seems surprising to me.

Quoted 8 lines

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#176087): https://lists.openembedded.org/g/openembedded-core/message/176087
Mute This Topic: https://lists.openembedded.org/mt/96110740/3618097
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 1 line
Alex Kiernan
#7 lore raw

Removed not required pkgs autoconf, make, pkgconfig... etc and not removed 'g++'. Have to check specifically for this package. Let me check for it and i'll update here.

#8 lore raw
Quoted 2 lines · Sundeep

Removed not required pkgs autoconf, make, pkgconfig... etc and not removed 'g++'. Have to check specifically for this package. Let me check for it and i'll update here.

Thanks!

I'd probably start from the other end - my guess would be you only need gcc (and whatever transitive dependencies it brings).

Signature · 1 line
Alex Kiernan
#9 lore raw

Without 'binutils' the required linker 'x86_64-poky-linux-ld' will not be added to the image (getting error - cannot find 'ld'). And, 'g++' also a required package along with 'gcc'. When removed 'g++' some required libs are missing. See below error.

root@qemux86-64:~/hello# cargo run
Compiling hello v0.1.0 (/home/root/hello)
error: linking with `x86_64-poky-linux-gcc` failed: exit status: 1
|
= note: "x86_64-poky-linux-gcc" "/tmp/rustcZTUudY/symbols.o" "/home/root/hello/target/debug/deps/hello-366ba9a14b055dd9.1rbu6cyq0fbr2z03.rcgu.o" "/home/root/hello/target/debug/deps/hello-366ba9a1"
= note: /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find crti.o: No such file or directory
/usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find crtbeginS.o: No such file or directory
/usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lgcc_s: No such file or directory
/usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lutil: No such file or directory
/usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lrt: No such file or directory
/usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lpthread: No such file or directory
/usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lm: No such file or directory
/usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -ldl: No such file or directory
/usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lc: No such file or directory
/usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find crtendS.o: No such file or directory
/usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status

error: could not compile hello due to previous error

#10 lore raw
Quoted 14 lines · Sundeep

Without 'binutils' the required linker 'x86_64-poky-linux-ld' will not be added to the image (getting error - cannot find 'ld'). And, 'g++' also a required package along with 'gcc'. When removed 'g++' some required libs are missing. See below error.

root@qemux86-64:~/hello# cargo run
   Compiling hello v0.1.0 (/home/root/hello)
error: linking with `x86_64-poky-linux-gcc` failed: exit status: 1
  |
  = note: "x86_64-poky-linux-gcc" "/tmp/rustcZTUudY/symbols.o" "/home/root/hello/target/debug/deps/hello-366ba9a14b055dd9.1rbu6cyq0fbr2z03.rcgu.o" "/home/root/hello/target/debug/deps/hello-366ba9a1"
  = note: /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find Scrt1.o: No such file or directory
          /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find crti.o: No such file or directory
          /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find crtbeginS.o: No such file or directory
          /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lgcc_s: No such file or directory
          /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lutil: No such file or directory
Quoted 9 lines
          /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lrt: No such file or directory
          /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lpthread: No such file or directory
          /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lm: No such file or directory
          /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -ldl: No such file or directory
          /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find -lc: No such file or directory
          /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find crtendS.o: No such file or directory
          /usr/lib/gcc/x86_64-poky-linux/12.2.0/../../../../x86_64-poky-linux/bin/ld: cannot find crtn.o: No such file or directory
          collect2: error: ld returned 1 exit status

Those look like glibc-dev to me - something like add a dependency on ${LIBC_DEPENDENCIES}?

Signature · 1 line
Alex Kiernan