Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc offline build #124967

Closed
deepa2015 opened this issue May 10, 2024 · 6 comments
Closed

rustc offline build #124967

deepa2015 opened this issue May 10, 2024 · 6 comments
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@deepa2015
Copy link

deepa2015 commented May 10, 2024

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

  • Do a rustc build as given in https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html

  • List all Cargo project in "https://github.com/rust-lang/rust.git ". Searched the .toml files

  • In each project, do "cargo vendor". It creates "vendor" folder.

  • Add following to .cargo/config.toml
    [net]
    offline = true
    [source.crates-io]
    replace-with = "vendored-sources"
    [source.vendored-sources]
    directory = "vendor"

  • Rebuild the project (cargo build)

  • For "rust/library/core", it was succesful. Logs are attached.
    - How to identify that the build is done offline using the prebuilt downloads from "vendor" folder?

  • The same steps are followed for rust-analyzer but get build errors. Vendoring succeeded.
    error[E0599]: no variant or associated item named InvalidPrefix found for enum TokenKind in the current scope
    --> crates/parser/src/lexed_str.rs:181:41
    |
    181 | rustc_lexer::TokenKind::InvalidPrefix | rustc_lexer::TokenKind::InvalidIdent => {
    | ^^^^^^^^^^^^^ variant or associated item not found in TokenKind

    Compiling cfg v0.0.0 (/home/deepa/work/rust-build/rust/src/tools/rust-analyzer/crates/cfg)
    For more information about this error, try rustc --explain E0599.
    ..
    rust-analyzer-build-error.log

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

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 10, 2024
@ehuss
Copy link
Contributor

ehuss commented May 10, 2024

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
Copy link
Member

cuviper commented May 10, 2024

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)

@jieyouxu jieyouxu added C-discussion Category: Discussion or questions that doesn't represent real issues. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 13, 2024
@clubby789 clubby789 added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label May 13, 2024
@deepa2015
Copy link
Author

deepa2015 commented May 15, 2024

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
Copy link
Member

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

x vendor was implemented recently (#123942), that's why it doesn't exist in the 1.78.0 source.

@cuviper
Copy link
Member

cuviper commented May 15, 2024

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

@Noratrieb
Copy link
Member

An old discussion, closing. if you have further problems, open a new issue

@Noratrieb Noratrieb closed this as not planned Won't fix, can't repro, duplicate, stale Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

8 participants