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

refactor: add rustc-perf submodule to src/tools #125166

Merged
merged 6 commits into from
May 21, 2024

Commits on May 20, 2024

  1. refactor: add rustc-perf submodule to src/tools

    Currently, it's very challenging to perform a sandboxed `opt-dist`
    bootstrap because the tool requires `rustc-perf` to be present, but
    there is no proper management/tracking of it. Instead, a specific commit
    is hardcoded where it is needed, and a non-checksummed zip is fetched
    ad-hoc. This happens in two places:
    
    `src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile`:
    
    ```dockerfile
    ENV PERF_COMMIT 4f313ad
    RUN curl -LS -o perf.zip https://ci-mirrors.rust-lang.org/rustc/rustc-perf-$PERF_COMMIT.zip && \
        unzip perf.zip && \
        mv rustc-perf-$PERF_COMMIT rustc-perf && \
        rm perf.zip
    ```
    
    `src/tools/opt-dist/src/main.rs`
    
    ```rust
    // FIXME: add some mechanism for synchronization of this commit SHA with
    // Linux (which builds rustc-perf in a Dockerfile)
    // rustc-perf version from 2023-10-22
    const PERF_COMMIT: &str = "4f313add609f43e928e98132358e8426ed3969ae";
    
    let url = format!("https://ci-mirrors.rust-lang.org/rustc/rustc-perf-{PERF_COMMIT}.zip");
    let client = reqwest::blocking::Client::builder()
        .timeout(Duration::from_secs(60 * 2))
        .connect_timeout(Duration::from_secs(60 * 2))
        .build()?;
    let response = retry_action(
        || Ok(client.get(&url).send()?.error_for_status()?.bytes()?.to_vec()),
        "Download rustc-perf archive",
        5,
    )?;
    ```
    
    This causes a few issues:
    
    1. Maintainers need to be careful to bump PERF_COMMIT in both places
       every time
    2. In order to run `opt-dist` in a sandbox, you need to provide your own
       `rustc-perf` (rust-lang#125125), but to
       figure out which commit to provide you need to grep the Dockerfile
    3. Even if you manage to provide the correct `rustc-perf`, its
       dependencies are not included in the `vendor/` dir created during
       `dist`, so it will fail to build from the published source tarballs
    4. It is hard to provide any level of automation around updating the
       `rustc-perf` in use, leading to staleness
    
    Fundamentally, this means `rustc-src` tarballs no longer contain
    everything you need to bootstrap Rust, and packagers hoping to leverage
    `opt-dist` need to go out of their way to keep track of this "hidden"
    dependency on `rustc-perf`.
    
    This change adds rustc-perf as a git submodule, pinned to the current
    `PERF_COMMIT` 4f313ad. Subsequent
    commits ensure the submodule is initialized when necessary, and make use
    of it in `opt-dist`.
    lovesegfault committed May 20, 2024
    Configuration menu
    Copy the full SHA
    e287044 View commit details
    Browse the repository at this point in the history
  2. refactor(bootstrap): update rustc-perf submodule when building opt-dist

    This avoids having normal builds pay the cost of initializing that
    submodule, while still ensuring it's available whenever `opt-dist` is
    built.
    
    Note that, at this point, `opt-dist` will not yet use the submodule,
    that will be handled in a subsequent commit.
    lovesegfault committed May 20, 2024
    Configuration menu
    Copy the full SHA
    4c075c6 View commit details
    Browse the repository at this point in the history
  3. refactor(opt-dist): use rustc-perf from rustc checkout

    This replaces the hardcoded rustc-perf commit and ad-hoc downloading and
    unpacking of its zipped source with defaulting to use the new rustc-perf
    submodule.
    
    While it would be nice to make `opt-dist` able to initialize the
    submodule automatically when pointing to a Rust checkout _other_ than
    the one opt-dist was built in, that would require a bigger refactor that
    moved `update_submodule`, from bootstrap, into build_helper.
    
    Regardless, I imagine it must be quite rare to use `opt-dist` with a
    checkout that is neither from a rust-src tarball (which will contain the
    submodule), nor the checkout opt-dist itself was built (bootstrap will
    update the submodule when opt-dist is built).
    lovesegfault committed May 20, 2024
    Configuration menu
    Copy the full SHA
    95c05c3 View commit details
    Browse the repository at this point in the history
  4. refactor(ci/docker/dist-x86_64-linux): remove rustc-perf downloading

    It is now available as a submodule in src/tools/rustc-perf, and is
    initialized when building opt-dist
    lovesegfault committed May 20, 2024
    Configuration menu
    Copy the full SHA
    d9a7868 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    4550fb5 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    e253718 View commit details
    Browse the repository at this point in the history