Recently, we attempted to use Rust to refactor some code in a C/C++ project running on aarch64_be-unknown-linux-gnu, which is currently in tier 3.
We use continuous integration (CI) to build our versions, with each build environment allocated from a resource pool. The environments consist of low-version Linux systems located without internet access and are initialized after each use. Fortunately, the Rust binary from https://static.rust-lang.org/dist/rust-1.72.0-x86_64-unknown-linux-gnu.tar.gz can be used by us. We can simply place the Rust binary where the CI node can access it to solve the Rust running issue. However, it cannot build crates for the target aarch64_be-unknown-linux-gnu. It was found that Rustc can compile tier3 targets but not std to use, so the issue was transformed into building a std for the tier3 target.
- The first way I found is to use
cargo build -Zbuild-std --target aarch64_be-unknown-linux-gnu. * However, it's not suitable for us. For some reason, we intention to use a stable version and this method requires network access to build std in the first place, but the building environment is initialized without any internet access.
- The second way I found is to build a new Rust from source code in a network environment and move it to a place that the CI node can access. We can use
./x setupand then modify config.toml as follows, finally use
./x distto build a new Rust toolchain.
In this way, it will generate some gz in rust/build/dist. We can push
[build] target = ["aarch64_be-unknown-linux-gnu"]
rust-std-aarch64_be-unknown-linux-gnu.tar.gzto a Git repository and then pull it and run
So, this method can temporarily solve our issue, but it needs to build the entire Rust, which costs a lot of time. Are there some elegant ways to solve our problem by distributing only the target std? I know we can build only the std by using
./x build --stage 0 library, which means we should configure environment variables to set Rust search paths. However,
./x dist --stage 0 library is not working.