Skip to content

feat: add rust-lang/rust#13012

Draft
suzuki-shunsuke wants to merge 7 commits into
mainfrom
feat/rust-lang/rust
Draft

feat: add rust-lang/rust#13012
suzuki-shunsuke wants to merge 7 commits into
mainfrom
feat/rust-lang/rust

Conversation

@suzuki-shunsuke

Copy link
Copy Markdown
Member

rust-lang/rust: Empowering everyone to build reliable and efficient software

$ aqua g -i rust-lang/rust

[rust-lang/rust](https://github.com/rust-lang/rust): Empowering everyone to build reliable and efficient software
@suzuki-shunsuke suzuki-shunsuke added the enhancement New feature or request label Jun 13, 2023
@suzuki-shunsuke

Copy link
Copy Markdown
Member Author

This doesn't work well.

$ clippy-driver --help
dyld[80256]: Library not loaded: @rpath/librustc_driver-de83b13cb0dec411.dylib
  Referenced from: <840E3891-3456-3181-8FD5-ED2C4C6EE785> /Users/shunsukesuzuki/.local/share/aquaproj-aqua/pkgs/http/static.rust-lang.org/dist/rust-1.70.0-aarch64-apple-darwin.tar.gz/rust-1.70.0-aarch64-apple-darwin/clippy-preview/bin/clippy-driver
  Reason: tried: '/Users/shunsukesuzuki/.local/share/aquaproj-aqua/pkgs/http/static.rust-lang.org/dist/rust-1.70.0-aarch64-apple-darwin.tar.gz/rust-1.70.0-aarch64-apple-darwin/clippy-preview/bin/../lib/librustc_driver-de83b13cb0dec411.dylib' (no such file), '/Users/shunsukesuzuki/.local/share/aquaproj-aqua/pkgs/http/static.rust-lang.org/dist/rust-1.70.0-aarch64-apple-darwin.tar.gz/rust-1.70.0-aarch64-apple-darwin/clippy-preview/bin/../lib/librustc_driver-de83b13cb0dec411.dylib' (no such file), '/usr/local/lib/librustc_driver-de83b13cb0dec411.dylib' (no such file), '/usr/lib/librustc_driver-de83b13cb0dec411.dylib' (no such file, not in dyld cache)
zsh: abort      clippy-driver --help
$ ls ~/.local/share/aquaproj-aqua/pkgs/http/static.rust-lang.org/dist/rust-1.70.0-aarch64-apple-darwin.tar.gz/rust-1.70.0-aarch64-apple-darwin/rustc/lib/
libchalk_derive-a1e7ef7ca84f041b.dylib         libserde_derive-d8bcd59977639216.dylib
libcstr-72c0ec6bf52a01ed.dylib                 libstd-2ca50e2550a11ed4.dylib
libderive_more-4d829aa1b351128a.dylib          libtest-9a5e4ac0b43184d0.dylib
libdisplaydoc-d12aaeaedbb42264.dylib           libthiserror_impl-efce2bbcf7c10189.dylib
libicu_provider_macros-972dba0234818778.dylib  libtracing_attributes-ffd0bf903aa44903.dylib
libproc_macro_hack-93dced52c3ef57ee.dylib      libunic_langid_macros_impl-a46cb91c681139b2.dylib
librustc-stable_rt.asan.dylib                  libyoke_derive-564c8b2e68c53d71.dylib
librustc-stable_rt.lsan.dylib                  libzerofrom_derive-e24a6de7937f351d.dylib
librustc-stable_rt.tsan.dylib                  libzerovec_derive-0dd66e1a97bf7b02.dylib
librustc_driver-de83b13cb0dec411.dylib         rustlib
librustc_macros-086d6f1037ea6c16.dylib

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

I want to use it from GitHub Actions, so is it possible to merge only for the Linux target?

@suzuki-shunsuke

Copy link
Copy Markdown
Member Author

It didn't work on lima too.

We need to confirm if it works now.

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

Ah... I understand. Thank you.
I'll give it a try.

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

It partially worked on linux/amd64 (Ubuntu 24.04).

The problem was that the following parts were musl:

https://github.com/aquaproj/aqua-registry/pull/13012/files#diff-9b8583124203a14b9702091e64ea341017c0b4a7062a7539a0da656c37a0ca4dR46

The Rust standalone installer has two packages, and both glibc and musl are built with dynamic linking.
Notice /lib/ld-musl-x86_64.so.1 and /lib64/ld-linux-x86-64.so.2 below.

$ ls
rust-1.86.0-x86_64-unknown-linux-gnu  rust-1.86.0-x86_64-unknown-linux-musl
$ file rust-1.86.0-x86_64-unknown-linux-musl/cargo/bin/cargo
rust-1.86.0-x86_64-unknown-linux-musl/cargo/bin/cargo: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, with debug_info, not stripped
$ file rust-1.86.0-x86_64-unknown-linux-gnu/cargo/bin/cargo
rust-1.86.0-x86_64-unknown-linux-gnu/cargo/bin/cargo: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped

My environment is Ubuntu24.04 so I cannot run musl, but I can check the required glibc version with the following command.

$ cmdx con linux amd64
+ bash scripts/connect.sh
[INFO] Connecting to the container aqua-registry (linux/amd64)
root@32b22dad9676:/workspace# cargo -V
cargo 1.86.0 (adf9b6ad1 2025-02-28)
root@32b22dad9676:/workspace# objdump -T ~/.local/share/aquaproj-aqua/pkgs/http/static.rust-lang.org/dist/rust-1.86.0-x86_64-unknown-linux-gnu.tar.gz/rust-1.86.0-x86_64-unknown-linux-gnu/cargo/bin/cargo  | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -Vu
2.2.5
2.3
2.3.2
2.3.4
2.4
2.5
2.6
2.7
2.9
2.10
2.12
2.14
2.15
2.16
2.17

Above we can see that the minimum required glibc version is 2.17.
This is the version released in 2012, and is guaranteed to run on fairly old environments such as RHEL7.

https://sourceware.org/glibc/wiki/Glibc%20Timeline
https://sourceware.org/glibc/wiki/Release

Also, considering that Rust requires glibc version 2.17, it should be able to run on most Linux distributions.

https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements/

The only thing to consider is the Alpine Linux environment, but I think this can be solved by PR of the musl version for those who need it.

For the above reasons, unless there is a special reason, I think that the musl specification in this PR should be changed to the gnu (glibc) specification.

There are still other tasks that need to be done (such as setting LD_LIBRARY_PATH and the search path for the std crate), but for now, the above needs to be resolved before it will work on glibc-based Linux, so I would appreciate your consideration.

@suzuki-shunsuke

suzuki-shunsuke commented May 1, 2025

Copy link
Copy Markdown
Member Author

Thank you for your investigation.

musl or gnu

I'm not familiar with this field, but I thought musl is more portable than gnu.

https://aquaproj.github.io/docs/develop-registry/registry-style-guide/#consideration-about-rust

linux: use the asset for not gnu but musl if both of them are supported
ref: #2153 (comment)

#2153 (comment)

In my understanding, musl is more portable than gnu because musl is built by static link.

#13012 (comment)

But you mentioned Rust musl binary is built with dynamic linking.

The Rust standalone installer has two packages, and both glibc and musl are built with dynamic linking.

So musl is more portable than gnu because musl is built by static link isn't correct in this case.
I saw a similar case before.


I'll replace musl with gnu.

@suzuki-shunsuke

suzuki-shunsuke commented May 1, 2025

Copy link
Copy Markdown
Member Author

clippy-driver doesn't work on GitHub Actions ubuntu-24.04.

runner@fv-az1938-351:~/work/aqua-registry/aqua-registry$ clippy-driver --help
clippy-driver: error while loading shared libraries: librustc_driver-ea2439778c0a32ac.so: cannot open shared object file: No such file or directory
runner@fv-az1938-351:~/work/aqua-registry/aqua-registry$ aqua which clippy-driver
/home/runner/.local/share/aquaproj-aqua/pkgs/http/static.rust-lang.org/dist/rust-1.86.0-x86_64-unknown-linux-gnu.tar.xz/rust-1.86.0-x86_64-unknown-linux-gnu/clippy-preview/bin/clippy-driver

  • cargo
  • rustdoc
  • rustc
  • rust-gdbgui
  • cargo-fmt

Probably work

  • rust-lldb
  • rust-gdb

  • clippy-driver
  • cargo-clippy
  • rustfmt

  • rls

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor
$ cmdx con linux amd64
+ bash scripts/connect.sh
[INFO] Connecting to the container aqua-registry (linux/amd64)
root@0343f71d7284:/workspace# export LD_LIBRARY_PATH="$(dirname "$(dirname "$(aqua which rustc)")")/lib"
root@0343f71d7284:/workspace# clippy-driver -V
clippy 0.1.86 (05f9846f89 2025-03-31)
root@0343f71d7284:/workspace# cargo-clippy -V
clippy 0.1.86 (05f9846f89 2025-03-31)
root@0343f71d7284:/workspace# rustfmt -V
rustfmt 1.8.0-stable (05f9846f89 2025-03-31)

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

It seems to work fine.
I'll try compiling it now.

@suzuki-shunsuke

Copy link
Copy Markdown
Member Author
root@0343f71d7284:/workspace# export LD_LIBRARY_PATH="$(dirname "$(dirname "$(aqua which rustc)")")/lib"

I didn't set LD_LIBRARY_PATH.
I'll try it later.

@suzuki-shunsuke

Copy link
Copy Markdown
Member Author

It worked.

runner@fv-az1988-983:~/work/aqua-registry/aqua-registry$ export LD_LIBRARY_PATH="$(dirname "$(dirname "$(aqua which rustc)")")/lib"
runner@fv-az1988-983:~/work/aqua-registry/aqua-registry$ clippy-driver --help
INFO[0000] download and unarchive the package            aqua_version=2.50.1-3 env=linux/amd64 exe_name=clippy-driver package_name=rust-lang/rust package_version=1.86.0 program=aqua registry=standard
Checks a file to catch common mistakes and improve your Rust code.
Run clippy-driver with the same arguments you use for rustc

Usage:
    clippy-driver [OPTIONS] INPUT

Common options:
    -h, --help               Print this message
    -V, --version            Print version info and exit
    --rustc                  Pass all arguments to rustc

Allowing / Denying lints
You can use tool lints to allow or deny lints from your code, e.g.:

    #[allow(clippy::needless_lifetimes)]

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

Although it's off topic, it might be useful to have an option to write environment variable settings in registry.yaml and have aqua-proxy automatically configure them.

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

I tried compiling it, but I still got an error about the std crate.
This requires a different solution, so I'll look into it.

$ cmdx con linux amd64
+ bash scripts/connect.sh
[INFO] Connecting to the container aqua-registry (linux/amd64)
root@4042502166a2:/workspace# export LD_LIBRARY_PATH="$(dirname "$(dirname "$(aqua which rustc)")")/lib"
root@4042502166a2:/workspace# cargo init neko
    Creating binary (application) package
note: see more `Cargo.toml` keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
root@4042502166a2:/workspace# cd neko/
root@4042502166a2:/workspace/neko# cargo b
   Compiling neko v0.1.0 (/workspace/neko)
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-linux-gnu` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-linux-gnu`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `neko` (bin "neko") due to 1 previous error

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor
root@4042502166a2:/workspace/neko# rustc --print sysroot
/root/.local/share/aquaproj-aqua/pkgs/http/static.rust-lang.org/dist/rust-1.86.0-x86_64-unknown-linux-gnu.tar.xz/rust-1.86.0-x86_64-unknown-linux-gnu/rustc

👀
https://rustc-dev-guide.rust-lang.org/building/bootstrapping/what-bootstrapping-does.html?highlight=sysroot#what-is-a-sysroot

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor
root@4042502166a2:/workspace/neko# ls $(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/
bin

The std crate may be required separately.

@suzuki-shunsuke

suzuki-shunsuke commented May 1, 2025

Copy link
Copy Markdown
Member Author

I tried to set LD_LIBRARY_PATH in macOS, but it didn't solve the problem.

export LD_LIBRARY_PATH="$(dirname "$(dirname "$(aqua which rustc)")")/lib"
$ clippy-driver --help
dyld[51021]: Library not loaded: @rpath/librustc_driver-025e8c5df7c09b7b.dylib
  Referenced from: <1DC3F7BE-EA5D-37B6-ABBD-7F8E4AB30D1A> /Users/shunsukesuzuki/.local/share/aquaproj-aqua/pkgs/http/static.rust-lang.org/dist/rust-1.86.0-aarch64-apple-darwin.tar.xz/rust-1.86.0-aarch64-apple-darwin/clippy-preview/bin/clippy-driver
  Reason: tried: '/Users/shunsukesuzuki/.local/share/aquaproj-aqua/pkgs/http/static.rust-lang.org/dist/rust-1.86.0-aarch64-apple-darwin.tar.xz/rust-1.86.0-aarch64-apple-darwin/clippy-preview/bin/../lib/librustc_driver-025e8c5df7c09b7b.dylib' (no such file), '/Users/shunsukesuzuki/.local/share/aquaproj-aqua/pkgs/http/static.rust-lang.org/dist/rust-1.86.0-aarch64-apple-darwin.tar.xz/rust-1.86.0-aarch64-apple-darwin/clippy-preview/bin/../lib/librustc_driver-025e8c5df7c09b7b.dylib' (no such file)
zsh: abort      clippy-driver --help
$ ls $LD_LIBRARY_PATH 
librustc_driver-025e8c5df7c09b7b.dylib  librustc-stable_rt.asan.dylib  librustc-stable_rt.lsan.dylib  librustc-stable_rt.tsan.dylib  rustlib

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

Okay, I'll give it a try.

@suzuki-shunsuke

Copy link
Copy Markdown
Member Author

Supporting all platforms (linux, macOS, and windows) is ideal, but supporting only linux is also acceptable.

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

I have started macOS.

However, I'm sorry, but I would like to run the equivalent of aqua's cmdx t in a macOS environment without using a container. How can I do this?

@suzuki-shunsuke

Copy link
Copy Markdown
Member Author

How about this?
https://aquaproj.github.io/docs/products/aqua-registry/contributing#how-to-execute-a-package-in-your-machine-during-development

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

I checked, and it seems that all work is done in containers.
(Sorry if I misread it)
Is there a way to run it in a macOS bare metal environment?

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

Sorry, I completely misread it. The information you provided is fine.

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

I'm sorry, but I haven't been maintaining my macOS environment, so a lot of things are going wrong.
It will probably take a while, so I'll report back when I have some progress.

@takumin

takumin commented May 1, 2025

Copy link
Copy Markdown
Contributor

Well, for some reason it worked...

aqua-registry on  feat/rust-lang/rust [!]whence cargo
/Users/takumi/.local/share/aquaproj-aqua/bin/cargo

aqua-registry on  feat/rust-lang/rust [!]aqua which cargo
/Users/takumi/.local/share/aquaproj-aqua/pkgs/http/static.rust-lang.org/dist/rust-1.86.0-aarch64-apple-darwin.tar.xz/rust-1.86.0-aarch64-apple-darwin/cargo/bin/cargo

aqua-registry on  feat/rust-lang/rust [!]cargo -V
cargo 1.86.0 (adf9b6ad1 2025-02-28)

I'll look into it a little more

@takumin

takumin commented May 2, 2025

Copy link
Copy Markdown
Contributor

I decided to change my approach a bit and build CI from a state where "rustup-init is guaranteed to be installed."

The following PR will add rustup-init to aqua.

#35901

That said, it would be more convenient to be able to install Rust as is, so I'll try it again when I have time.

Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants