rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
95.32k stars 12.28k forks source link

rustc offline build #124967

Open deepa2015 opened 2 months ago

deepa2015 commented 2 months ago

Hello, I'm new to RUST and the build process. Going through the documents and scripts. It is required for us to build "rustc" offline. Following are the steps followed

Can "cargo vendor" be added in build script which executes post build of each project? If it is feasible to do then can you please highlight spots in build scripts where changes can be added ? Are there any other issues that may arise ?

Thanks

core-build.log core-cargo-vendor.log core-carg-vendored-build.log

ehuss commented 2 months ago

It looks like you are using cargo build and cargo vendor manually. The rust project is not intended to be used that way. The ./x script is the intended mechanism for both building the vendored set (./x vendor) and building (./x build rust-analyzer).

cuviper commented 2 months ago

You could also build from the dist-src tarball, which already has all submodules and vendored crates included:

e.g. https://static.rust-lang.org/dist/2024-05-10/rustc-nightly-src.tar.xz

Also set [build] vendor = true in your root config.toml. (the one for ./x, not .cargo/config.toml)

deepa2015 commented 2 months ago

It looks like you are using cargo build and cargo vendor manually. The rust project is not intended to be used that way. The ./x script is the intended mechanism for both building the vendored set (./x vendor) and building (./x build rust-analyzer).

Thanks for the inputs. It did work with "master" branch. For 1.78.0 branch, I do not see "vendor" option with x.py ./x vendor Building bootstrap Finished dev [unoptimized] target(s) in 0.02s error: 'x.py' requires a subcommand but one was not provided [subcommands: build, b, check, c, clippy, fix, fmt, doc, d, test, t, bench, clean, dist, install, run, r, setup, suggest]

Usage: x.py [options] [...]

For more information, try '--help'. Build completed unsuccessfully in 0:00:00

How to vendor sources for 1.77 , 1.78 ?

You could also build from the dist-src tarball, which already has all submodules and vendored crates included:

e.g. https://static.rust-lang.org/dist/2024-05-10/rustc-nightly-src.tar.xz

Also set [build] vendor = true in your root config.toml. (the one for ./x, not .cargo/config.toml)

The link has only the nightly src tar . Can you please share dist-src tarballs for 1.77, 1.78 ?

Thanks!

onur-ozkan commented 2 months ago

For 1.78.0 branch, I do not see "vendor" option with x.py

x vendor was implemented recently (https://github.com/rust-lang/rust/pull/123942), that's why it doesn't exist in the 1.78.0 source.

cuviper commented 2 months ago

Can you please share dist-src tarballs for 1.77, 1.78 ?

Those are available directly in the dist/ path, like: https://static.rust-lang.org/dist/rustc-1.78.0-src.tar.xz