Skip to content

rust bootstrap in CI failing for 1.68.0 #108959

Closed
@jhheider

Description

@jhheider

Code

Our existing rust build script fails on 1.68.0 with:

   Compiling sha2 v0.10.2
   Compiling toml v0.5.9
    Finished dev [unoptimized] target(s) in 12.03s
fatal: not a git repository (or any of the parent directories): .git
thread 'main' panicked at 'command did not execute successfully: "git" "rev-list" "[email protected]" "-n1" "--first-parent" "HEAD" "--" "/private/var/folders/y3/yr3bxsy95c3gfwwj61ytbp000000gq/T/47aee085/src/llvm-project" "/private/var/folders/y3/yr3bxsy95c3gfwwj61ytbp000000gq/T/47aee085/src/bootstrap/download-ci-llvm-stamp" "/private/var/folders/y3/yr3bxsy95c3gfwwj61ytbp000000gq/T/47aee085/src/version"
expected success, got: exit status: 128', native.rs:154:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:00:23
make: *** [install] Error 1

Looking at native.rs, we see the following:

if CiEnv::is_ci() {
        // We assume we have access to git, so it's okay to unconditionally pass
        // `true` here.
        let llvm_sha = detect_llvm_sha(config, true);
...
/// This retrieves the LLVM sha we *want* to use, according to git history.
pub(crate) fn detect_llvm_sha(config: &Config, is_git: bool) -> String {
    let llvm_sha = if is_git {
        let mut rev_list = config.git();

So, it's passing is_git = true categorically if it thinks it's being built in CI, but it seems like it should only do that if it's working in a git checkout. If it's built from release tarballs in a CI system (which sets CI, such as GitHub Actions) it fails as above.

I believe a minimal fix is likely:

# src/bootstrap/native.rs:237
-    if CiEnv::is_ci() {
+    if CiEnv::is_ci() && config.rust_info.is_managed_git_subrepository() {

Version it worked on

It most recently worked on: Rust 1.67.1

Version with regression

1.68.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)regression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions