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

Move download-ci-llvm out of bootstrap.py #95170

Merged
merged 3 commits into from
Apr 27, 2022
Merged

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Mar 21, 2022

This is ready for review. It has been tested on Windows, Linux, and NixOS.

The second commit ports the changes from #95234 to Rust; I can remove it if desired.

Helps with #94829.

As a follow-up, this makes it possible to avoid downloading llvm until it's needed for building rustc_llvm; it would be nice to do that, but it shouldn't go in the first draft. It might also be possible to avoid requiring python until tests run (currently there's a check in sanity.rs), but I haven't looked too much into that.

@rustbot label +A-rustbuild

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 21, 2022
@jyn514
Copy link
Member Author

jyn514 commented Mar 21, 2022

@rustbot label: -S-waiting-on-review +S-waiting-on-author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 21, 2022
@rust-log-analyzer

This comment has been minimized.

src/bootstrap/native.rs Outdated Show resolved Hide resolved
@ChrisDenton
Copy link
Member

FYI curl exists on newer versions of Windows (circa 2018). So you maybe could try it first then fallback to powershell.

@jyn514
Copy link
Member Author

jyn514 commented Mar 21, 2022

@ChrisDenton I'd prefer to keep this as close to the python version as possible to start. We can always change it to do feature detection later once this code isn't changing so much.

Copy link
Member Author

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this should be ready for review :) if anyone on NixOS or Windows (either mingw/WSL or MSVC) could test this out, that would be extremely helpful ❤️ I've already tested on Ubuntu and it worked fine - NixOS failed because of invalid SSL certs, but I don't know if that's because my install is cursed or it's actually a real issue for other people.

You can test this by:

  1. checking out the branch: git fetch origin pull/95170/head && git checkout FETCH_HEAD
  2. clearing your download cache: rm -r build/cache build/$(rustc --version --verbose | grep host | cut -d' ' -f2)/ci-llvm. This won't delete your build cache, just libLLVM.so.
  3. downloading using the new code: x.py check with [llvm] download-ci-llvm = true in config.toml.

UPDATE: this has been tested on Windows and Mac, it could still use testing on NixOS though.

src/bootstrap/native.rs Show resolved Hide resolved
src/bootstrap/bootstrap.py Show resolved Hide resolved
src/bootstrap/native.rs Outdated Show resolved Hide resolved
src/bootstrap/native.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 changed the title [wip] move download-ci-llvm out of bootstrap.py Move download-ci-llvm out of bootstrap.py Mar 22, 2022
@jyn514 jyn514 marked this pull request as ready for review March 22, 2022 03:58
@rust-log-analyzer

This comment has been minimized.

@Walther
Copy link

Walther commented Mar 22, 2022

macOS Monterey 12.3

cargo +beta build --bins && cargo +beta run check
    Finished dev [unoptimized] target(s) in 0.09s
    Finished dev [unoptimized] target(s) in 0.07s
     Running `target/debug/bootstrap check`
thread 'main' panicked at '

couldn't find required command: "python"

', src/bootstrap/sanity.rs:59:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

due to macOS Monterey 12.3 release notes include:

Python

Deprecations

  • Python 2.7 was removed from macOS in this update. Developers should use Python 3 or an alternative language instead. (39795874)

by default, there is no python available in path anymore - only python3. Even if you install some python3 versions from homebrew, by default only python3 will be in path - no alias for bare python.


see also #71818 (comment)

@Walther
Copy link

Walther commented Mar 22, 2022

On WSL2 Ubuntu 20.04.4 LTS (running on Windows 11 host, although that doesn't matter), for some reason cargo +beta build --bins && cargo +beta run check seems to work - even though it should suffer from the same problem: python does not exist in path, only python3 does - unless you manually install the optional package python-is-python3 that sets up the necessary symlinks.

I wonder where the difference is between the above macOS monterey 12.3 and WSL2 Ubuntu 20.04 as they should exhibit the same error as python does not exist on either 🤔

@jyn514
Copy link
Member Author

jyn514 commented Mar 22, 2022

@Walther this doesn't yet remove the python requirement - it shouldn't be too hard to do, since afaik python is only used for building llvm and a few rustdoc tests, but it's not going to be in the first draft. Can you set python = "python3" in config.toml and try again so I can make sure the downloading works?

@Walther
Copy link

Walther commented Mar 22, 2022

On Windows 11 natively, in a PowerShell session, with rust installed with rustup-init.exe, with Python 3.10 installed from Microsoft Store (as offered when running python3 in the terminal)

cargo +beta build --bins
   Compiling bootstrap v0.0.0 (C:\Users\Walther\git\rust\src\bootstrap)
   Compiling same-file v1.0.6
   Compiling lzma-sys v0.1.16
   Compiling tar v0.4.37
   Compiling serde_derive v1.0.125
   Compiling globset v0.4.5
   Compiling tempfile v3.2.0
error: failed to run custom build command for `bootstrap v0.0.0 (C:\Users\Walther\git\rust\src\bootstrap)`

Caused by:
  process didn't exit successfully: `C:\Users\Walther\git\rust\target\debug\build\bootstrap-7757a4777dec0f86\build-script-build` (exit code: 101)
  --- stdout
  cargo:rerun-if-changed=build.rs
  cargo:rerun-if-env-changed=RUSTC
  cargo:rustc-env=BUILD_TRIPLE=x86_64-pc-windows-msvc
  cargo:rerun-if-env-changed=PATH

  --- stderr
  thread 'main' panicked at 'assertion failed: rustc.is_absolute()', src\bootstrap\build.rs:22:5
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed

@Walther
Copy link

Walther commented Mar 22, 2022

@Walther this doesn't yet remove the python requirement - it shouldn't be too hard to do, since afaik python is only used for building llvm and a few rustdoc tests, but it's not going to be in the first draft. Can you set python = "python3" in config.toml and try again so I can make sure the downloading works?

Yeah - mostly curious as to where the difference is coming from, as it appears something is working around the name/path issue on one platform but not the other.

Again on the macOS Monterey 12.3 on my M1 mac mini (2020):

Adding a section to config.toml

[build]
python = "python3"

fails with a new error:

cargo +beta build --bins && cargo +beta run check
    Finished dev [unoptimized] target(s) in 0.14s
    Finished dev [unoptimized] target(s) in 0.07s
     Running `target/debug/bootstrap check`
downloading https://ci-artifacts.rust-lang.org/rustc-builds/282778aee26166754315815552bae454fc968960/rust-dev-nightly-aarch64-apple-darwin.tar.xz
######################################################################################################################################################################################################################################################### 100.0%
extracting /Users/walther/git/rust/build/cache/llvm-282778aee26166754315815552bae454fc968960-false/rust-dev-nightly-aarch64-apple-darwin.tar.xz to /Users/walther/git/rust/build/aarch64-apple-darwin/ci-llvm
Checking stage0 std artifacts (aarch64-apple-darwin -> aarch64-apple-darwin)
    Finished release [optimized] target(s) in 0.07s
Checking stage0 std test/bench/example targets (aarch64-apple-darwin -> aarch64-apple-darwin)
    Finished release [optimized] target(s) in 0.07s
Checking stage0 compiler artifacts (aarch64-apple-darwin -> aarch64-apple-darwin)
   Compiling rustc_llvm v0.0.0 (/Users/walther/git/rust/compiler/rustc_llvm)
    Checking rustc_infer v0.0.0 (/Users/walther/git/rust/compiler/rustc_infer)
    Checking rustc_mir_dataflow v0.0.0 (/Users/walther/git/rust/compiler/rustc_mir_dataflow)
    Checking rustc_symbol_mangling v0.0.0 (/Users/walther/git/rust/compiler/rustc_symbol_mangling)
    Checking rustc_incremental v0.0.0 (/Users/walther/git/rust/compiler/rustc_incremental)
    Checking rustc_monomorphize v0.0.0 (/Users/walther/git/rust/compiler/rustc_monomorphize)
    Checking rustc_passes v0.0.0 (/Users/walther/git/rust/compiler/rustc_passes)
    Checking rustc_query_impl v0.0.0 (/Users/walther/git/rust/compiler/rustc_query_impl)
    Checking rustc_save_analysis v0.0.0 (/Users/walther/git/rust/compiler/rustc_save_analysis)
    Checking rustc_middle v0.0.0 (/Users/walther/git/rust/compiler/rustc_middle)
    Checking rustc_metadata v0.0.0 (/Users/walther/git/rust/compiler/rustc_metadata)
    Checking rustc_trait_selection v0.0.0 (/Users/walther/git/rust/compiler/rustc_trait_selection)
    Checking rustc_codegen_ssa v0.0.0 (/Users/walther/git/rust/compiler/rustc_codegen_ssa)
    Checking rustc_resolve v0.0.0 (/Users/walther/git/rust/compiler/rustc_resolve)
    Checking rustc_lint v0.0.0 (/Users/walther/git/rust/compiler/rustc_lint)
    Checking rustc_ty_utils v0.0.0 (/Users/walther/git/rust/compiler/rustc_ty_utils)
    Checking rustc_const_eval v0.0.0 (/Users/walther/git/rust/compiler/rustc_const_eval)
    Checking rustc_traits v0.0.0 (/Users/walther/git/rust/compiler/rustc_traits)
    Checking rustc_mir_build v0.0.0 (/Users/walther/git/rust/compiler/rustc_mir_build)
    Checking rustc_typeck v0.0.0 (/Users/walther/git/rust/compiler/rustc_typeck)
    Checking rustc_plugin_impl v0.0.0 (/Users/walther/git/rust/compiler/rustc_plugin_impl)
    Checking rustc_mir_transform v0.0.0 (/Users/walther/git/rust/compiler/rustc_mir_transform)
    Checking rustc_borrowck v0.0.0 (/Users/walther/git/rust/compiler/rustc_borrowck)
error: failed to run custom build command for `rustc_llvm v0.0.0 (/Users/walther/git/rust/compiler/rustc_llvm)`

Caused by:
  process didn't exit successfully: `/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/release/build/rustc_llvm-a87a5ba16107693a/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=RUST_CHECK
  cargo:rerun-if-env-changed=REAL_LIBRARY_PATH_VAR
  cargo:rerun-if-env-changed=REAL_LIBRARY_PATH
  cargo:rerun-if-env-changed=LLVM_CONFIG
  cargo:rerun-if-changed=/Users/walther/git/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-config
  cargo:rustc-cfg=llvm_component="aarch64"
  cargo:rustc-cfg=llvm_component="arm"
  cargo:rustc-cfg=llvm_component="asmparser"
  cargo:rustc-cfg=llvm_component="avr"
  cargo:rustc-cfg=llvm_component="bitreader"
  cargo:rustc-cfg=llvm_component="bitwriter"
  cargo:rustc-cfg=llvm_component="bpf"
  cargo:rustc-cfg=llvm_component="coverage"
  cargo:rustc-cfg=llvm_component="hexagon"
  cargo:rustc-cfg=llvm_component="instrumentation"
  cargo:rustc-cfg=llvm_component="ipo"
  cargo:rustc-cfg=llvm_component="linker"
  cargo:rustc-cfg=llvm_component="lto"
  cargo:rustc-cfg=llvm_component="m68k"
  cargo:rustc-cfg=llvm_component="mips"
  cargo:rustc-cfg=llvm_component="msp430"
  cargo:rustc-cfg=llvm_component="nvptx"
  cargo:rustc-cfg=llvm_component="powerpc"
  cargo:rustc-cfg=llvm_component="riscv"
  cargo:rustc-cfg=llvm_component="sparc"
  cargo:rustc-cfg=llvm_component="systemz"
  cargo:rustc-cfg=llvm_component="webassembly"
  cargo:rustc-cfg=llvm_component="x86"
  cargo:rerun-if-env-changed=LLVM_RUSTLLVM
  cargo:rerun-if-env-changed=LLVM_NDEBUG
  cargo:rerun-if-changed=llvm-wrapper/CoverageMappingWrapper.cpp
  cargo:rerun-if-changed=llvm-wrapper/ArchiveWrapper.cpp
  cargo:rerun-if-changed=llvm-wrapper/PassWrapper.cpp
  cargo:rerun-if-changed=llvm-wrapper/.editorconfig
  cargo:rerun-if-changed=llvm-wrapper/README
  cargo:rerun-if-changed=llvm-wrapper/RustWrapper.cpp
  cargo:rerun-if-changed=llvm-wrapper/Linker.cpp
  cargo:rerun-if-changed=llvm-wrapper/LLVMWrapper.h
  TARGET = Some("aarch64-apple-darwin")
  OPT_LEVEL = Some("3")
  HOST = Some("aarch64-apple-darwin")
  CXX_aarch64-apple-darwin = Some("c++")
  CXXFLAGS_aarch64-apple-darwin = Some("-ffunction-sections -fdata-sections -fPIC -arch arm64 -stdlib=libc++")
  CRATE_CC_NO_DEFAULTS = None
  CARGO_CFG_TARGET_FEATURE = Some("aes,crc,dit,dotprod,dpb,dpb2,fcma,fhm,flagm,fp,fp16,frintts,jsconv,llvm14-builtins-abi,lor,lse,neon,paca,pacg,pan,pmuv3,ras,rcpc,rcpc2,rdm,sb,sha2,sha3,ssbs,v8.1a,v8.2a,v8.3a,v8.4a,vh")
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-stdlib=libc++" "-I/Users/walther/git/rust/build/aarch64-apple-darwin/ci-llvm/include" "-std=c++14" "-stdlib=libc++" "-fno-exceptions" "-fno-rtti" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-DLLVM_COMPONENT_AARCH64" "-DLLVM_COMPONENT_ARM" "-DLLVM_COMPONENT_ASMPARSER" "-DLLVM_COMPONENT_AVR" "-DLLVM_COMPONENT_BITREADER" "-DLLVM_COMPONENT_BITWRITER" "-DLLVM_COMPONENT_BPF" "-DLLVM_COMPONENT_COVERAGE" "-DLLVM_COMPONENT_HEXAGON" "-DLLVM_COMPONENT_INSTRUMENTATION" "-DLLVM_COMPONENT_IPO" "-DLLVM_COMPONENT_LINKER" "-DLLVM_COMPONENT_LTO" "-DLLVM_COMPONENT_M68K" "-DLLVM_COMPONENT_MIPS" "-DLLVM_COMPONENT_MSP430" "-DLLVM_COMPONENT_NVPTX" "-DLLVM_COMPONENT_POWERPC" "-DLLVM_COMPONENT_RISCV" "-DLLVM_COMPONENT_SPARC" "-DLLVM_COMPONENT_SYSTEMZ" "-DLLVM_COMPONENT_WEBASSEMBLY" "-DLLVM_COMPONENT_X86" "-DLLVM_RUSTLLVM" "-DNDEBUG" "-o" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/llvm-wrapper/PassWrapper.o" "-c" "llvm-wrapper/PassWrapper.cpp"
  exit status: 0
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-stdlib=libc++" "-I/Users/walther/git/rust/build/aarch64-apple-darwin/ci-llvm/include" "-std=c++14" "-stdlib=libc++" "-fno-exceptions" "-fno-rtti" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-DLLVM_COMPONENT_AARCH64" "-DLLVM_COMPONENT_ARM" "-DLLVM_COMPONENT_ASMPARSER" "-DLLVM_COMPONENT_AVR" "-DLLVM_COMPONENT_BITREADER" "-DLLVM_COMPONENT_BITWRITER" "-DLLVM_COMPONENT_BPF" "-DLLVM_COMPONENT_COVERAGE" "-DLLVM_COMPONENT_HEXAGON" "-DLLVM_COMPONENT_INSTRUMENTATION" "-DLLVM_COMPONENT_IPO" "-DLLVM_COMPONENT_LINKER" "-DLLVM_COMPONENT_LTO" "-DLLVM_COMPONENT_M68K" "-DLLVM_COMPONENT_MIPS" "-DLLVM_COMPONENT_MSP430" "-DLLVM_COMPONENT_NVPTX" "-DLLVM_COMPONENT_POWERPC" "-DLLVM_COMPONENT_RISCV" "-DLLVM_COMPONENT_SPARC" "-DLLVM_COMPONENT_SYSTEMZ" "-DLLVM_COMPONENT_WEBASSEMBLY" "-DLLVM_COMPONENT_X86" "-DLLVM_RUSTLLVM" "-DNDEBUG" "-o" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/llvm-wrapper/RustWrapper.o" "-c" "llvm-wrapper/RustWrapper.cpp"
  exit status: 0
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-stdlib=libc++" "-I/Users/walther/git/rust/build/aarch64-apple-darwin/ci-llvm/include" "-std=c++14" "-stdlib=libc++" "-fno-exceptions" "-fno-rtti" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-DLLVM_COMPONENT_AARCH64" "-DLLVM_COMPONENT_ARM" "-DLLVM_COMPONENT_ASMPARSER" "-DLLVM_COMPONENT_AVR" "-DLLVM_COMPONENT_BITREADER" "-DLLVM_COMPONENT_BITWRITER" "-DLLVM_COMPONENT_BPF" "-DLLVM_COMPONENT_COVERAGE" "-DLLVM_COMPONENT_HEXAGON" "-DLLVM_COMPONENT_INSTRUMENTATION" "-DLLVM_COMPONENT_IPO" "-DLLVM_COMPONENT_LINKER" "-DLLVM_COMPONENT_LTO" "-DLLVM_COMPONENT_M68K" "-DLLVM_COMPONENT_MIPS" "-DLLVM_COMPONENT_MSP430" "-DLLVM_COMPONENT_NVPTX" "-DLLVM_COMPONENT_POWERPC" "-DLLVM_COMPONENT_RISCV" "-DLLVM_COMPONENT_SPARC" "-DLLVM_COMPONENT_SYSTEMZ" "-DLLVM_COMPONENT_WEBASSEMBLY" "-DLLVM_COMPONENT_X86" "-DLLVM_RUSTLLVM" "-DNDEBUG" "-o" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/llvm-wrapper/ArchiveWrapper.o" "-c" "llvm-wrapper/ArchiveWrapper.cpp"
  exit status: 0
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-stdlib=libc++" "-I/Users/walther/git/rust/build/aarch64-apple-darwin/ci-llvm/include" "-std=c++14" "-stdlib=libc++" "-fno-exceptions" "-fno-rtti" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-DLLVM_COMPONENT_AARCH64" "-DLLVM_COMPONENT_ARM" "-DLLVM_COMPONENT_ASMPARSER" "-DLLVM_COMPONENT_AVR" "-DLLVM_COMPONENT_BITREADER" "-DLLVM_COMPONENT_BITWRITER" "-DLLVM_COMPONENT_BPF" "-DLLVM_COMPONENT_COVERAGE" "-DLLVM_COMPONENT_HEXAGON" "-DLLVM_COMPONENT_INSTRUMENTATION" "-DLLVM_COMPONENT_IPO" "-DLLVM_COMPONENT_LINKER" "-DLLVM_COMPONENT_LTO" "-DLLVM_COMPONENT_M68K" "-DLLVM_COMPONENT_MIPS" "-DLLVM_COMPONENT_MSP430" "-DLLVM_COMPONENT_NVPTX" "-DLLVM_COMPONENT_POWERPC" "-DLLVM_COMPONENT_RISCV" "-DLLVM_COMPONENT_SPARC" "-DLLVM_COMPONENT_SYSTEMZ" "-DLLVM_COMPONENT_WEBASSEMBLY" "-DLLVM_COMPONENT_X86" "-DLLVM_RUSTLLVM" "-DNDEBUG" "-o" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/llvm-wrapper/CoverageMappingWrapper.o" "-c" "llvm-wrapper/CoverageMappingWrapper.cpp"
  exit status: 0
  running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-ffunction-sections" "-fdata-sections" "-fPIC" "-arch" "arm64" "-stdlib=libc++" "-I/Users/walther/git/rust/build/aarch64-apple-darwin/ci-llvm/include" "-std=c++14" "-stdlib=libc++" "-fno-exceptions" "-fno-rtti" "-D__STDC_CONSTANT_MACROS" "-D__STDC_FORMAT_MACROS" "-D__STDC_LIMIT_MACROS" "-DLLVM_COMPONENT_AARCH64" "-DLLVM_COMPONENT_ARM" "-DLLVM_COMPONENT_ASMPARSER" "-DLLVM_COMPONENT_AVR" "-DLLVM_COMPONENT_BITREADER" "-DLLVM_COMPONENT_BITWRITER" "-DLLVM_COMPONENT_BPF" "-DLLVM_COMPONENT_COVERAGE" "-DLLVM_COMPONENT_HEXAGON" "-DLLVM_COMPONENT_INSTRUMENTATION" "-DLLVM_COMPONENT_IPO" "-DLLVM_COMPONENT_LINKER" "-DLLVM_COMPONENT_LTO" "-DLLVM_COMPONENT_M68K" "-DLLVM_COMPONENT_MIPS" "-DLLVM_COMPONENT_MSP430" "-DLLVM_COMPONENT_NVPTX" "-DLLVM_COMPONENT_POWERPC" "-DLLVM_COMPONENT_RISCV" "-DLLVM_COMPONENT_SPARC" "-DLLVM_COMPONENT_SYSTEMZ" "-DLLVM_COMPONENT_WEBASSEMBLY" "-DLLVM_COMPONENT_X86" "-DLLVM_RUSTLLVM" "-DNDEBUG" "-o" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/llvm-wrapper/Linker.o" "-c" "llvm-wrapper/Linker.cpp"
  exit status: 0
  AR_aarch64-apple-darwin = Some("ar")
  running: "ar" "cq" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/libllvm-wrapper.a" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/llvm-wrapper/PassWrapper.o" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/llvm-wrapper/RustWrapper.o" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/llvm-wrapper/ArchiveWrapper.o" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/llvm-wrapper/CoverageMappingWrapper.o" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/llvm-wrapper/Linker.o"
  exit status: 0
  running: "ar" "s" "/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out/libllvm-wrapper.a"
  exit status: 0
  cargo:rustc-link-lib=static=llvm-wrapper
  cargo:rustc-link-search=native=/Users/walther/git/rust/build/aarch64-apple-darwin/stage0-rustc/aarch64-apple-darwin/release/build/rustc_llvm-d53b94a11110e0f0/out
  cargo:rerun-if-env-changed=LLVM_LINK_SHARED

  --- stderr
  llvm-config: error: libLLVM-14-rust-1.61.0-nightly.dylib is missing
  thread 'main' panicked at 'command did not execute successfully: "/Users/walther/git/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-config" "--link-shared" "--libs" "--system-libs" "aarch64" "arm" "asmparser" "avr" "bitreader" "bitwriter" "bpf" "coverage" "hexagon" "instrumentation" "ipo" "linker" "lto" "m68k" "mips" "msp430" "nvptx" "powerpc" "riscv" "sparc" "systemz" "webassembly" "x86"
  expected success, got: exit status: 1', compiler/rustc_llvm/build.rs:252:16
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
cargo +beta run check  100.36s user 6.56s system 473% cpu 22.602 total

@jyn514
Copy link
Member Author

jyn514 commented Mar 22, 2022

  thread 'main' panicked at 'assertion failed: rustc.is_absolute()', src\bootstrap\build.rs:22:5

Oh uh good point, I should have suggested x.py and not cargo run so we only see regressions from this PR and not from my other changes 😅 I updated the instructions in #95170 (review), could you test again with python3 ./x.py check?

src/bootstrap/native.rs Outdated Show resolved Hide resolved
@jyn514
Copy link
Member Author

jyn514 commented Mar 22, 2022

@Walther helpfully tested this on both Mac and Windows and since the fix in 2abdca8 it works for him :)

@rust-log-analyzer

This comment has been minimized.

@ben0x539
Copy link
Contributor

Ok, this should be ready for review :) if anyone on NixOS or Windows (either mingw/WSL or MSVC) could test this out, that would be extremely helpful heart I've already tested on Ubuntu and it worked fine - NixOS failed because of invalid SSL certs, but I don't know if that's because my install is cursed or it's actually a real issue for other people.

You can test this by:

1. checking out the branch: `git fetch origin pull/95170/head && git checkout FETCH_HEAD`

2. clearing your download cache: `rm -r build/cache build/$(rustc --version --verbose | grep host | cut -d' ' -f2)/ci-llvm`. This won't delete your build cache, just libLLVM.so.

3. downloading using the new code: `x.py check` with `[llvm] download-ci-llvm = true` in config.toml.

UPDATE: this has been tested on Windows and Mac, it could still use testing on NixOS though.

I unsuccessfully tried to test this on NixOS together with #95234.

$ nix-shell -p 

[nix-shell:~/git/rust]$ rm -R build

[nix-shell:~/git/rust]$ cat config.toml
# Includes one of the default files in src/bootstrap/defaults
profile = "library"
changelog-seen = 2
[llvm]
download-ci-llvm = true

[nix-shell:~/git/rust]$ git log --pretty=oneline master..@
116f574643dbc38a7fdb21dba2a8a98b6a31648a (HEAD -> ci-llvm) bootstrap.py: nixos check in /etc/os-release with quotes
faa7ed79625928e6b7b08827fe6712f4f85c37f4 Fix bootstrap tests
2abdca8665dcf0e6feffa349dface8ee26fd81b1 fix caching bug on Mac and Windows
608973f1f33414db1f66e6088c75f914948b63f4 Move download-ci-llvm to rustbuild

[nix-shell:~/git/rust]$ ./x.py check
Updating only changed submodules
  Submodules updated in 0.01 seconds
downloading https://static.rust-lang.org/dist/2022-02-22/rust-std-beta-x86_64-unknown-linux-gnu.tar.xz
############################################################################################################ 100.0%
extracting /home/vh/git/rust/build/cache/2022-02-22/rust-std-beta-x86_64-unknown-linux-gnu.tar.xz
downloading https://static.rust-lang.org/dist/2022-02-22/rustc-beta-x86_64-unknown-linux-gnu.tar.xz
############################################################################################################ 100.0%
extracting /home/vh/git/rust/build/cache/2022-02-22/rustc-beta-x86_64-unknown-linux-gnu.tar.xz
downloading https://static.rust-lang.org/dist/2022-02-22/cargo-beta-x86_64-unknown-linux-gnu.tar.xz
############################################################################################################ 100.0%
extracting /home/vh/git/rust/build/cache/2022-02-22/cargo-beta-x86_64-unknown-linux-gnu.tar.xz
info: you seem to be using Nix. Attempting to patch /home/vh/git/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo
info: you seem to be using Nix. Attempting to patch /home/vh/git/rust/build/x86_64-unknown-linux-gnu/stage0/bin/rustc
info: you seem to be using Nix. Attempting to patch /home/vh/git/rust/build/x86_64-unknown-linux-gnu/stage0/bin/rustdoc
info: you seem to be using Nix. Attempting to patch /home/vh/git/rust/build/x86_64-unknown-linux-gnu/stage0/lib/libtest-d9ecd5377b7dfa2f.so
info: you seem to be using Nix. Attempting to patch /home/vh/git/rust/build/x86_64-unknown-linux-gnu/stage0/lib/libLLVM-14-rust-1.60.0-beta.so
info: you seem to be using Nix. Attempting to patch /home/vh/git/rust/build/x86_64-unknown-linux-gnu/stage0/lib/librustc_driver-c6cd2e91ce71a7d4.so
info: you seem to be using Nix. Attempting to patch /home/vh/git/rust/build/x86_64-unknown-linux-gnu/stage0/lib/libstd-ff9290e971253a38.so
downloading https://static.rust-lang.org/dist/2022-02-23/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz
############################################################################################################ 100.0%
extracting /home/vh/git/rust/build/cache/2022-02-23/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz
info: you seem to be using Nix. Attempting to patch /home/vh/git/rust/build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt
info: you seem to be using Nix. Attempting to patch /home/vh/git/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo-fmt
Building rustbuild
   Compiling libc v0.2.116
   Compiling proc-macro2 v1.0.30
   Compiling memchr v2.4.1
   Compiling unicode-xid v0.2.2
   Compiling cfg-if v1.0.0
   Compiling getrandom v0.2.0
   Compiling syn v1.0.80
   Compiling lazy_static v1.4.0
   Compiling serde_derive v1.0.125
   Compiling cfg-if v0.1.10
   Compiling cc v1.0.69
   Compiling serde v1.0.125
   Compiling regex-automata v0.1.10
   Compiling pkg-config v0.3.18
   Compiling log v0.4.14
   Compiling ppv-lite86 v0.2.8
   Compiling ryu v1.0.5
   Compiling regex-syntax v0.6.25
   Compiling crossbeam-utils v0.8.6
   Compiling serde_json v1.0.59
   Compiling once_cell v1.7.2
   Compiling fnv v1.0.7
   Compiling same-file v1.0.6
   Compiling unicode-width v0.1.8
   Compiling remove_dir_all v0.5.3
   Compiling itoa v0.4.6
   Compiling bootstrap v0.0.0 (/home/vh/git/rust/src/bootstrap)
   Compiling cmake v0.1.44
   Compiling thread_local v1.1.4
   Compiling getopts v0.2.21
   Compiling walkdir v2.3.1
   Compiling aho-corasick v0.7.18
   Compiling bstr v0.2.13
   Compiling quote v1.0.7
   Compiling lzma-sys v0.1.16
   Compiling filetime v0.2.14
   Compiling xattr v0.2.2
   Compiling rand_core v0.6.2
   Compiling tar v0.4.37
   Compiling rand_chacha v0.3.0
   Compiling opener v0.5.0
   Compiling rand v0.8.4
   Compiling regex v1.5.4
   Compiling tempfile v3.2.0
   Compiling globset v0.4.5
   Compiling ignore v0.4.17
   Compiling xz2 v0.1.6
   Compiling toml v0.5.7
    Finished dev [unoptimized] target(s) in 18.35s
downloading https://ci-artifacts.rust-lang.org/rustc-builds/282778aee26166754315815552bae454fc968960/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
############################################################################################################ 100.0%
thread 'main' panicked at 'fs::rename(temppath, dest_path) failed with Invalid cross-device link (os error 18)', src/bootstrap/native.rs:296:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:01:11
$ ./x.py check -v
detected default triple x86_64-unknown-linux-gnu from pre-installed rustc
Updating only changed submodules
  Submodules updated in 0.01 seconds
Building rustbuild
running: /home/vh/git/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /home/vh/git/rust/src/bootstrap/Cargo.toml --verbose
[...]
    Finished dev [unoptimized] target(s) in 0.08s
running: /home/vh/git/rust/build/bootstrap/debug/bootstrap check -v
finding compilers
CC_x86_64-unknown-linux-gnu = "gcc"
CFLAGS_x86_64-unknown-linux-gnu = ["-ffunction-sections", "-fdata-sections", "-fPIC", "-m64"]
CXX_x86_64-unknown-linux-gnu = "g++"
CXXFLAGS_x86_64-unknown-linux-gnu = ["-ffunction-sections", "-fdata-sections", "-fPIC", "-m64"]
AR_x86_64-unknown-linux-gnu = "ar"
running sanity check
learning about cargo
downloading https://ci-artifacts.rust-lang.org/rustc-builds/282778aee26166754315815552bae454fc968960/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
running: "curl" "-#" "-y" "30" "-Y" "10" "--connect-timeout" "30" "--retry" "3" "-Sf" "-o" "/run/user/1000/.tmpuU8ncP" "https://ci-artifacts.rust-lang.org/rustc-builds/282778aee26166754315815552bae454fc968960/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz"
############################################################################################################ 100.0%
moving /run/user/1000/.tmpuU8ncP to /home/vh/git/rust/build/cache/llvm-282778aee26166754315815552bae454fc968960-false/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
thread 'main' panicked at 'fs::rename(temppath, dest_path) failed with Invalid cross-device link (os error 18)', src/bootstrap/native.rs:296:5
[...]

$ mount | grep /run/user/1000
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=6564484k,nr_inodes=1641121,mode=700,uid=1000,gid=100)

@jyn514
Copy link
Member Author

jyn514 commented Mar 23, 2022

@ben0x539 thanks! I pushed a fix for the rename I think should work :) I tried it out on my own nixOS install and got an error I don't quite understand - does it look familiar?

error: creating a garbage collector root (/nix/store/cl4qhnp02xg2mq8x8v8ms70v4x9rmp8p-rust-stage0-dependencies) in the Nix store is forbidden (are you running nix-build inside the store?)

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 24, 2022
@bors
Copy link
Contributor

bors commented Apr 24, 2022

⌛ Testing commit 92f5052b91c11c1d125e5d9196b00d7c9d5d4f2a with merge f601fa6c7ef581b3298fe167d6aea661b2154d63...

@bors
Copy link
Contributor

bors commented Apr 24, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 24, 2022
@rust-log-analyzer

This comment has been minimized.

jyn514 and others added 3 commits April 24, 2022 19:40
This attempts to keep the logic as close to the original python as possible.
`probably_large` has been removed, since it was always `True`, and UTF-8 paths are no longer supported when patching files for NixOS.
I can readd UTF-8 support if desired.

Note that this required making `llvm_link_shared` computed on-demand,
since we don't know whether it will be static or dynamic until we download LLVM from CI.
@jyn514
Copy link
Member Author

jyn514 commented Apr 25, 2022

I forgot dynamic linking isn't supported on all platforms - it broke during --dry-run, which defaults to dynamic linking to avoid downloading things. I changed it to default to static linking instead, which should fix the Windows builders.

@Mark-Simulacrum
Copy link
Member

Hm, previously we only assumed dynamic linking when downloading from CI -- I guess linux has dynamic and windows has static linking for those artifacts (we support CI-built LLVM on windows, right? I seem to recall PRs to that effect).

In any case, I think this should be OK.

@bors r+

@bors
Copy link
Contributor

bors commented Apr 27, 2022

📌 Commit 7885ade has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 27, 2022
@bors
Copy link
Contributor

bors commented Apr 27, 2022

⌛ Testing commit 7885ade with merge ff18038...

@jyn514
Copy link
Member Author

jyn514 commented Apr 27, 2022

Hm, previously we only assumed dynamic linking when downloading from CI -- I guess linux has dynamic and windows has static linking for those artifacts (we support CI-built LLVM on windows, right? I seem to recall PRs to that effect).

We support it on Windows, yes, that was the same PR adding support for static linking: #80932

@bors
Copy link
Contributor

bors commented Apr 27, 2022

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing ff18038 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 27, 2022
@bors bors merged commit ff18038 into rust-lang:master Apr 27, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 27, 2022
@jyn514 jyn514 deleted the ci-llvm branch April 27, 2022 16:17
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ff18038): comparison url.

Summary:

  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: no relevant changes found
Regressions 😿
(primary)
Regressions 😿
(secondary)
Improvements 🎉
(primary)
Improvements 🎉
(secondary)
All 😿 🎉
(primary)
count1 0 0 1 0 1
mean2 N/A N/A -0.3% N/A -0.3%
max N/A N/A -0.3% N/A -0.3%

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. number of relevant changes

  2. the arithmetic mean of the percent change

let llvm_lib = llvm_root.join("lib");
for entry in t!(fs::read_dir(&llvm_lib)) {
let lib = t!(entry).path();
if lib.ends_with(".so") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot use this to check for an extension, only whole file names - the docs say "Only considers whole path components to match." - I have no idea how this ever passed NixOS, it just can't ever work AFAICT.

Copy link
Member

@eddyb eddyb May 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entries
};
patchelf.args(&[OsString::from("--set-rpath"), rpath_entries]);
if !fname.ends_with(".so") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, this cannot check for an extension (it's equivalent to fname.file_name() == ".so" basically).

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 15, 2022
…k-Simulacrum

Fix `download-ci-llvm` NixOS patching for `.so`s.

See rust-lang#95170 (comment) - in short, `Path::ends_with` doesn't do the same thing as `str::ends_with`, and can only be used to check for whole file names, not extensions.

With this PR, I get the full suite of:
```
extracting /home/eddy/Projects/rust-A/build/cache/llvm-ebb80ec4e90f8622440f3e33562db0d6e6c66555-true/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz to /home/eddy/Projects/rust-A/build/x86_64-unknown-linux-gnu/ci-llvm
info: you seem to be using Nix. Attempting to patch /home/eddy/Projects/rust-A/build/x86_64-unknown-linux-gnu/ci-llvm/bin/llvm-config
/nix/store/r4bzq2xilvv8fmqjg626hzwi22ah3hf4-rust-stage0-dependencies
info: you seem to be using Nix. Attempting to patch /home/eddy/Projects/rust-A/build/x86_64-unknown-linux-gnu/ci-llvm/bin/FileCheck
info: you seem to be using Nix. Attempting to patch /home/eddy/Projects/rust-A/build/x86_64-unknown-linux-gnu/ci-llvm/lib/libLLVM-14-rust-1.62.0-nightly.so
```
(that `libLLVM-14-rust-1.62.0-nightly.so` at the end having been missing before)

r? `@Mark-Simulacrum` cc `@jyn514`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.