How to build the nightly channel locally? `./x.py b` always pick the `beta` channel

My config.toml is like:

[llvm]
# Whether to use Rust CI built LLVM instead of locally building it.
download-ci-llvm = true     # Download a pre-built LLVM?
assertions = true           # LLVM assertions on?
# ccache = "/path/to/ccache"  # Use ccache when building LLVM?

[rust]
debug-logging = true        # Leave debug! and trace! calls in rustc?
incremental = true          # Build rustc with incremental compilation?
channel = 'nightly'
download-rustc = false

But it does not help to build the nightly channel. After running python3 ./x.py b, the cargo or rustc is saying they are in the beta channel.

I would love to build a local nightly build to test my PR: Update Mac Catalyst support for Clang 13 by imWildCat · Pull Request #96392 · rust-lang/rust · GitHub

I don't remember all config details, but unless you configured them specifically you shouldn't use the global cargo/rustc but the one in the target directory.

1 Like

Use rustup toolchain link … as described here: How to Build and Run the Compiler - Guide to Rustc Development

1 Like

Thanks!

I ran the commands but it is still beta:

➜  rust git:(add-clang13-macabi-support) ✗ rustup toolchain link stage1 build/aarch64-apple-darwin/stage0
➜  rust git:(add-clang13-macabi-support) ✗ rustc +stage1 --version
rustc 1.61.0-beta.1 (0f231250b 2022-04-05)

That's because you linked the stage0 directory. (Make sure the path in the link command says stage1 instead.) The stage0 compiler gets downloaded and is the current beta. stage1 is the first one you build from the repo. And if you do build stage2, too, that's another one built from the same code as stage1, differing by the fact that it was built by "itself" (i. e. by stage1) instead of by the beta (i. e. by stage0).

More info on bootstrapping: Bootstrapping - Guide to Rustc Development

1 Like

Thanks a lot!

Sorry I didn't read these docs carefully.

I also found a good reference just now: rustc-dev-guide/how-to-build-and-run.md at master · rust-lang/rustc-dev-guide · GitHub

FYI, that’s just the source code/repo for the same thing I linked to above.

1 Like

Thanks for pointing this out!

A small follow-up Q here:

If I changed rust/compiler/rustc_target/src/spec/x86_64_apple_ios_macabi.rs, can I test my change using stage 2? Or I need stage 3?
I found rustc_target was built for stage 2 but it does not seem to work:

# project: https://github.com/BLAKE3-team/BLAKE3.git
$ cargo +stage2 build -Z build-std --release --target x86_64-apple-ios-macabi

   Compiling rustc-std-workspace-core v1.99.0 (/Volumes/SharedVol/rust-projects/rust/build/aarch64-apple-darwin/stage2/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling blake3 v1.3.1 (/Volumes/SharedVol/rust-projects/BLAKE3)
The following warnings were emitted during compilation:

warning: The C compiler "clang" does not support -mavx512f and -mavx512vl.
warning: clang-13: error: invalid version number in '--target=x86_64-apple-ios13.0-macabi'

error: failed to run custom build command for `blake3 v1.3.1 (/Volumes/SharedVol/rust-projects/BLAKE3)`

Caused by:
  process didn't exit successfully: `/Volumes/SharedVol/rust-projects/BLAKE3/target/release/build/blake3-ac5c6dee5cd36567/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=CARGO_FEATURE_PURE
  cargo:rerun-if-env-changed=CARGO_FEATURE_NO_NEON
  TARGET = Some("x86_64-apple-ios-macabi")
  HOST = Some("aarch64-apple-darwin")
  CC_x86_64-apple-ios-macabi = None
  CC_x86_64_apple_ios_macabi = None
  TARGET_CC = None
  CC = None
  CFLAGS_x86_64-apple-ios-macabi = None
  CFLAGS_x86_64_apple_ios_macabi = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  Detecting iOS SDK path for macosx
  running: "xcrun" "--show-sdk-path" "--sdk" "macosx"
  exit status: 0
  OPT_LEVEL = Some("3")
  CC_x86_64-apple-ios-macabi = None
  CC_x86_64_apple_ios_macabi = None
  TARGET_CC = None
  CC = None
  CFLAGS_x86_64-apple-ios-macabi = None
  CFLAGS_x86_64_apple_ios_macabi = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  Detecting iOS SDK path for macosx
  running: "xcrun" "--show-sdk-path" "--sdk" "macosx"
  exit status: 0
  cargo:warning=The C compiler "clang" does not support -mavx512f and -mavx512vl.
  cargo:rerun-if-env-changed=BLAKE3_CI
  cargo:rerun-if-env-changed=CARGO_FEATURE_PREFER_INTRINSICS
  cargo:rerun-if-env-changed=CARGO_FEATURE_PURE
  cargo:rustc-cfg=blake3_sse2_ffi
  cargo:rustc-cfg=blake3_sse41_ffi
  cargo:rustc-cfg=blake3_avx2_ffi
  TARGET = Some("x86_64-apple-ios-macabi")
  OPT_LEVEL = Some("3")
  HOST = Some("aarch64-apple-darwin")
  CC_x86_64-apple-ios-macabi = None
  CC_x86_64_apple_ios_macabi = None
  TARGET_CC = None
  CC = None
  CFLAGS_x86_64-apple-ios-macabi = None
  CFLAGS_x86_64_apple_ios_macabi = None
  TARGET_CFLAGS = None
  CFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  Detecting iOS SDK path for macosx
  running: "xcrun" "--show-sdk-path" "--sdk" "macosx"
  exit status: 0
  running: "clang" "-O3" "-fPIC" "--target=x86_64-apple-ios13.0-macabi" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk" "-fembed-bitcode" "-Wall" "-Wextra" "-std=c11" "-o" "/Volumes/SharedVol/rust-projects/BLAKE3/target/x86_64-apple-ios-macabi/release/build/blake3-4be9cc78c36efcbd/out/c/blake3_sse2_x86-64_unix.o" "-c" "c/blake3_sse2_x86-64_unix.S"
  cargo:warning=clang-13: error: invalid version number in '--target=x86_64-apple-ios13.0-macabi'
  exit status: 1

  --- stderr


  error occurred: Command "clang" "-O3" "-fPIC" "--target=x86_64-apple-ios13.0-macabi" "-isysroot" "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk" "-fembed-bitcode" "-Wall" "-Wextra" "-std=c11" "-o" "/Volumes/SharedVol/rust-projects/BLAKE3/target/x86_64-apple-ios-macabi/release/build/blake3-4be9cc78c36efcbd/out/c/blake3_sse2_x86-64_unix.o" "-c" "c/blake3_sse2_x86-64_unix.S" with args "clang" did not execute successfully (status code exit status: 1).

My motivation: To change --target=x86_64-apple-ios13.0-macabi to something like --target=x86_64-apple-ios13.1-macabi or read ios{}.{} from environment variable.

I would’ve thought that stage 3 usually shouldn’t really ever be needed (I’m not 100% on that in case of cross-compiling) – I’m unfamiliar with the things you’re modifying here though; in case nobody else can help you either, note that these kinds of questions are also suitable on rust-lang.zulipchat.com or on internals.rust-lang.org.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.