| Summary: | Installing cargo on target fails | ||
|---|---|---|---|
| Product: | [Build System, Metadata & Runtime] OE-Core | Reporter: | Randy MacLeod <randy.macleod> |
| Component: | devtools / tool chain | Assignee: | Randy MacLeod <randy.macleod> |
| Status: | IN PROGRESS REVIEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | Medium | CC: | cp0613, meta.mr.watcher, meta.watcher, Naveen.Gowda, sundeep.kokkonda, sundeep.kokkonda, Yash.Shinde |
| Version: | 4.2 | ||
| Target Milestone: | 6.1 | ||
| Hardware: | x86 | ||
| OS: | Multiple | ||
| Whiteboard: | |||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | No (bug/feature does not impact docs) | |
|
Description
Randy MacLeod
2022-11-26 01:36:06 UTC
When this is fixed, drop: EXCLUDE_FROM_WORLD = "1" from cargo.inc. This looks like proc-macro2 failed to compiled when compiling cargo.
If IMAGE_INSTALL does not contain cargo, it will not compile, so no error is reported.
The workaround method is to modify 'S = "${RUSTSRC}/library/test"' in libstd-rs_%.bb.
Issue fixed with commit https://git.openembedded.org/openembedded-core/commit/?id=550c273f38d8e6d2d431908023e213c6b018d7ed 'bitbake core-image-full-cmdline' built without any issues. EXCLUDE_FROM_WORLD is only in .bb & .bbclass files (there is no .inc file having this flag). There is no cargo/rust recipe file having this flag. From where this should be removed? Randy to test that we can build cargo /rust for the target without changes to local.conf. Sundeep, I still see a problem if running rust on target: root@qemux86-64:~# rustc -o hw /tmp/hw.rs error: linker `x86_64-poky-linux-gcc` not found | = note: No such file or directory (os error 2) error: aborting due to previous error We can't just ask people to add whatever part of the gcc toolchain that's needed, we need the right dependency in the rust recipe for class-target. Is there another defect to track that? The cargo EXCLUDE_FROM_WORLD was dropped in: commit d2925c9c110e272ed00ab1cd8e83bb0114a254b9 Author: Alex Kiernan <alex.kiernan@gmail.com> Date: Wed Dec 28 15:23:32 2022 +0000 cargo: Drop exclude from world On-target cargo now builds/runs. (From OE-Core rev: eb8b8c5247a32f2bd6b680de6f1a999dc2fcbc5f) rust dependent modules are added to run rust on target. Now, the rust linker issue solved and rust is running on target, verified on arm64 & x86_64 qemu. Below is the patch. https://git.openembedded.org/openembedded-core/commit/?h=master-next&id=bb781f452299cfa6ec7fffd215b0af3149178f32 A fix has been merged to master so I've lowered the importance of the defect but I'd like to keep this issue open for reasons described below. Fix/work-around: https://git.openembedded.org/openembedded-core/commit/?id=bb781f452299cfa6ec7fffd215b0af3149178f32 Sundeep, I suspect that part of what is provided by gcc, g++ is required but not all. Have you looked at what is used in rustup to support cross-compilation? https://rust-lang.github.io/rustup/cross-compilation.html We may have to change the gcc, g++ recipes to make sub-packages so that less of the toolchain is install. What you have works, no doubt, but it's more than the minimum required I suspect. Moved en masse from 4.2 to 4.3 by Randy. Sundeep, any comments about what part of gcc, g++ is really needed? If I run rust-up in an ubuntu container: $ docker run -it ubuntu root@d78c1c2d1ee0:/# cat /etc/os-release | grep PRETTY_NAME PRETTY_NAME="Ubuntu 22.04.2 LTS" root@d78c1c2d1ee0:/# apt update ... root@d78c1c2d1ee0:/# apt install cargo Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: binutils binutils-common binutils-x86-64-linux-gnu ca-certificates cpp cpp-11 fontconfig-config fonts-dejavu-core gcc gcc-11 gcc-11-base libasan6 libatomic1 libbinutils libbrotli1 libbsd0 libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libcurl3-gnutls libdeflate0 libedit2 libexpat1 libfontconfig1 libfreetype6 libgcc-11-dev libgd3 libgomp1 libicu70 libisl23 libitm1 libjbig0 libjpeg-turbo8 libjpeg8 libldap-2.5-0 libldap-common libllvm14 liblsan0 libmd0 libmpc3 libmpfr6 libnghttp2-14 libnsl-dev libpng16-16 libpsl5 libquadmath0 librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libssh-4 libssh2-1 libstd-rust-1.65 libstd-rust-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp7 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxml2 libxpm4 linux-libc-dev manpages manpages-dev openssl publicsuffix rpcsvc-proto rustc ucf Suggested packages: binutils-doc cargo-doc python3 cpp-doc gcc-11-locales gcc-multilib make autoconf automake libtool flex bison gdb gcc-doc gcc-11-multilib gcc-11-doc glibc-doc libgd-tools libsasl2-modules-gssapi-mit | libsasl2-modules-gssapi-heimdal libsasl2-modules-ldap libsasl2-modules-otp libsasl2-modules-sql man-browser llvm-14 lld-14 clang-14 The following NEW packages will be installed: binutils binutils-common binutils-x86-64-linux-gnu ca-certificates cargo cpp cpp-11 fontconfig-config fonts-dejavu-core gcc gcc-11 gcc-11-base libasan6 libatomic1 libbinutils libbrotli1 libbsd0 libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libcurl3-gnutls libdeflate0 libedit2 libexpat1 libfontconfig1 libfreetype6 libgcc-11-dev libgd3 libgomp1 libicu70 libisl23 libitm1 libjbig0 libjpeg-turbo8 libjpeg8 libldap-2.5-0 libldap-common libllvm14 liblsan0 libmd0 libmpc3 libmpfr6 libnghttp2-14 libnsl-dev libpng16-16 libpsl5 libquadmath0 librtmp1 libsasl2-2 libsasl2-modules libsasl2-modules-db libssh-4 libssh2-1 libstd-rust-1.65 libstd-rust-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp7 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxml2 libxpm4 linux-libc-dev manpages manpages-dev openssl publicsuffix rpcsvc-proto rustc ucf 0 upgraded, 79 newly installed, 0 to remove and 4 not upgraded. Need to get 166 MB of archives. After this operation, 629 MB of additional disk space will be used. root@d78c1c2d1ee0:/# cat /tmp/jj | tr ' ' '\n' | egrep 'gcc|g\+\+' gcc gcc-11 gcc-11-base libgcc-11-dev gcc-11-locales gcc-multilib gcc-doc gcc-11-multilib gcc-11-doc gcc gcc-11 gcc-11-base libgcc-11-dev or to be less restrictive: root@d78c1c2d1ee0:/# cat /tmp/jj | tr ' ' '\n' | egrep "^g" gcc gcc-11 gcc-11-base gcc-11-locales gcc-multilib gdb gcc-doc gcc-11-multilib gcc-11-doc glibc-doc gcc gcc-11 gcc-11-base get so do we really need g++? similar ubuntu pkg info for rustc: root@d78c1c2d1ee0:/# apt install rustc Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-11 fontconfig-config fonts-dejavu-core gcc gcc-11 gcc-11-base libasan6 libatomic1 libbinutils libbrotli1 libbsd0 libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libdeflate0 libedit2 libfontconfig1 libfreetype6 libgcc-11-dev libgd3 libgomp1 libicu70 libisl23 libitm1 libjbig0 libjpeg-turbo8 libjpeg8 libllvm14 liblsan0 libmd0 libmpc3 libmpfr6 libnsl-dev libpng16-16 libquadmath0 libstd-rust-1.65 libstd-rust-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp7 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxml2 libxpm4 linux-libc-dev manpages manpages-dev rpcsvc-proto ucf Suggested packages: binutils-doc cpp-doc gcc-11-locales gcc-multilib make autoconf automake libtool flex bison gdb gcc-doc gcc-11-multilib gcc-11-doc glibc-doc libgd-tools man-browser cargo llvm-14 lld-14 clang-14 The following NEW packages will be installed: binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-11 fontconfig-config fonts-dejavu-core gcc gcc-11 gcc-11-base libasan6 libatomic1 libbinutils libbrotli1 libbsd0 libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev libctf-nobfd0 libctf0 libdeflate0 libedit2 libfontconfig1 libfreetype6 libgcc-11-dev libgd3 libgomp1 libicu70 libisl23 libitm1 libjbig0 libjpeg-turbo8 libjpeg8 libllvm14 liblsan0 libmd0 libmpc3 libmpfr6 libnsl-dev libpng16-16 libquadmath0 libstd-rust-1.65 libstd-rust-dev libtiff5 libtirpc-dev libtsan0 libubsan1 libwebp7 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxml2 libxpm4 linux-libc-dev manpages manpages-dev rpcsvc-proto rustc ucf 0 upgraded, 63 newly installed, 0 to remove and 4 not upgraded. Need to get 160 MB of archives. After this operation, 609 MB of additional disk space will be used. Do you want to continue? [Y/n] Hello Randy, Currently, binutils installing the below tools on target machine. x86_64-poky-linux-addr2line x86_64-poky-linux-dwp x86_64-poky-linux-gp-display-html x86_64-poky-linux-gprofng x86_64-poky-linux-nm x86_64-poky-linux-readelf x86_64-poky-linux-ar x86_64-poky-linux-elfedit x86_64-poky-linux-gp-display-src x86_64-poky-linux-ld x86_64-poky-linux-objcopy x86_64-poky-linux-size x86_64-poky-linux-as x86_64-poky-linux-gp-archive x86_64-poky-linux-gp-display-text x86_64-poky-linux-ld.bfd x86_64-poky-linux-objdump x86_64-poky-linux-strings x86_64-poky-linux-c++filt x86_64-poky-linux-gp-collect-app x86_64-poky-linux-gprof x86_64-poky-linux-ld.gold x86_64-poky-linux-ranlib x86_64-poky-linux-strip The tried installing the required tools such as as, ld.. etc but that's not working as binutils is collection of all those tools and currently binutils recipe in Yocto is not enabled to generate these individual module packages. The g++ was analyzed earlier and it is required to run Cargo on target. The detailed analysis is here - https://lists.openembedded.org/g/openembedded-core/message/178207 Sundeep, Thanks for checking on this.
I still don't understand *why* we would need g++ even for cargo.
Running an ubuntu-22.04 docker container, I see the following dependencies, none of which is g++ but cargo does seem to need gcc. It would be good to understand why. 22.04 ships rustc-1.65, fyi.
$ docker run -it ubuntu
root@dd3c5196093b:/# apt update
...
root@dd3c5196093b:/# apt depends rustc
rustc
Depends: libc6 (>= 2.34)
Depends: libgcc-s1 (>= 4.2)
Depends: libstd-rust-dev (= 1.65.0+dfsg0ubuntu1-0ubuntu0.22.04.1)
Depends: gcc
Depends: <libc-dev>
libc6-dev
Depends: binutils (>= 2.26)
Breaks: libstd-rust-dev (<< 1.26.2+dfsg1+llvm-0ubuntu1~~)
Suggests: cargo (>= 0.65.0~~)
Suggests: cargo (<< 0.66.0~~)
Suggests: llvm-14
Suggests: lld-14
Suggests: clang-14
Replaces: libstd-rust-dev (<< 1.26.2+dfsg1+llvm-0ubuntu1~~)
root@dd3c5196093b:/# apt depends cargo
cargo
Depends: libc6 (>= 2.34)
Depends: libcurl3-gnutls (>= 7.28.0)
Depends: libgcc-s1 (>= 4.2)
Depends: libssh2-1 (>= 1.7.0)
Depends: libssl3 (>= 3.0.0~~alpha1)
Depends: zlib1g (>= 1:1.1.4)
Depends: rustc (>= 1.24)
Depends: binutils
|Depends: gcc
|Depends: clang
Depends: <c-compiler>
bcc
clang-11
clang-12
clang-13
clang-14
clang-15
gcc
gcc-10
gcc-11
gcc-12
gcc-9
pcc
tcc
Suggests: cargo-doc
Suggests: python3
Hello Randy, Here g++ is not a direct dependency of cargo/rust. I tried a simple C program to compile and link w/o adding g++ and the linker failed with same errors mentioned earlier (x86_64-poky-linux/bin/ld: cannot find Scrt1.o: No such file or directory ... etc) The missing files are 'C runtime startup code object files'. There is an explanation about these files here - https://stackoverflow.com/questions/16436035/whats-the-usage-of-mcrt1-o-and-scrt1-o With g++ package these files are installing on the image. In Yocto, the gcc RPROVIDES g++, so this dependency is added. I need to spend time on this to understand if we should be changing the gcc/g++ recipe to avoid RDEPENDing on g++ or if my understanding of cargo's requirement is simply not correct. I'm still not convinced that we don't have an opportunity to trim down or sanitize our rust/cargo dependencies since according the the Fedora 40 sRPMs, rust and cargo do not depend on g++: https://www.rpmfind.net/linux/RPM/fedora/40/x86_64/r/rust-1.77.0-1.fc40.x86_64.html https://www.rpmfind.net/linux/RPM/fedora/40/x86_64/c/cargo-1.77.0-1.fc40.x86_64.html Anyway, bumping to the next release since I don't have more time for this now. We should confirm that if we split up the gcc/g++ recipe to separate the linker parts from the compiler parts in 6.1. |