From 4c859074ddc9ce3282543a827c5346078101cc7f Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sun, 21 Jan 2024 18:33:12 +0100 Subject: [PATCH 1/5] make shell.nix better --- src/building/suggested.md | 61 ++------------------------------------- 1 file changed, 3 insertions(+), 58 deletions(-) diff --git a/src/building/suggested.md b/src/building/suggested.md index 397a2e94b..691afaa55 100644 --- a/src/building/suggested.md +++ b/src/building/suggested.md @@ -270,68 +270,13 @@ If you're using nix, you can use the following nix-shell to work on Rust: ```nix { pkgs ? import {} }: - -# This file contains a development shell for working on rustc. -let - # Build configuration for rust-lang/rust. Based on `config.example.toml` (then called - # `config.toml.example`) from `1bd30ce2aac40c7698aa4a1b9520aa649ff2d1c5` - config = pkgs.writeText "rustc-config" '' - profile = "compiler" # you may want to choose a different profile, like `library` or `tools` - - [build] - patch-binaries-for-nix = true - # The path to (or name of) the GDB executable to use. This is only used for - # executing the debuginfo test suite. - gdb = "${pkgs.gdb}/bin/gdb" - python = "${pkgs.python3Full}/bin/python" - - [rust] - debug = true - incremental = true - deny-warnings = false - - # Indicates whether some LLVM tools, like llvm-objdump, will be made available in the - # sysroot. - llvm-tools = true - - # Print backtrace on internal compiler errors during bootstrap - backtrace-on-ice = true - ''; - - ripgrepConfig = - let - # Files that are ignored by ripgrep when searching. - ignoreFile = pkgs.writeText "rustc-rgignore" '' - configure - config.example.toml - x.py - LICENSE-MIT - LICENSE-APACHE - COPYRIGHT - **/*.txt - **/*.toml - **/*.yml - **/*.nix - *.md - src/ci - src/etc/ - src/llvm-emscripten/ - src/llvm-project/ - src/rtstartup/ - src/rustllvm/ - src/stdsimd/ - src/tools/rls/rls-analysis/test_data/ - ''; - in - pkgs.writeText "rustc-ripgreprc" "--ignore-file=${ignoreFile}"; -in pkgs.mkShell { name = "rustc"; nativeBuildInputs = with pkgs; [ - gcc_multi binutils cmake ninja openssl pkgconfig python39 git curl cacert patchelf nix psutils + gcc_multi binutils cmake ninja openssl pkg-config python39 git curl cacert patchelf nix ]; - RIPGREP_CONFIG_PATH = ripgrepConfig; - RUST_BOOTSTRAP_CONFIG = config; + # Avoid creating text files for ICEs. + RUSTC_ICE = "0"; } ``` From 7ff27e812018c28147ef82368d2ba66436f934ef Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Tue, 13 Feb 2024 19:47:57 +0100 Subject: [PATCH 2/5] Mention using RUST_BOOTSTRAP_CONFIG --- src/building/suggested.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/building/suggested.md b/src/building/suggested.md index 691afaa55..25a4b62e0 100644 --- a/src/building/suggested.md +++ b/src/building/suggested.md @@ -280,6 +280,23 @@ pkgs.mkShell { } ``` +Note that when using nix on a not-NixOS distribution, it may be necessary to set **`patch-binaries-for-nix = true` in `config.toml`**. +Bootstrap tries to detect whether it's running in nix and enable patching automatically, but this detection can have false negatives. + +You can also use your nix shell to manage `config.toml`: + +```nix +let + config = pkgs.writeText "rustc-config" '' + # Your config.toml content goes here + '' +pkgs.mkShell { + /* ... */ + # This environment varaible tells bootstrap where our config.toml is. + RUST_BOOTSTRAP_CONFIG = config; +} +``` + ## Shell Completions If you use Bash, Fish or PowerShell, you can find automatically-generated shell completion scripts for `x.py` in [`src/etc/completions`](https://github.com/rust-lang/rust/tree/master/src/etc/completions). From 85cc9660f9bf8cd69b2535bf67bf6af9536a1118 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Tue, 13 Feb 2024 19:48:13 +0100 Subject: [PATCH 3/5] Move things to `buildInputs` and add `glibc.out glibc.static` This fixes the nofile-limit.rs UI test. --- src/building/suggested.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/building/suggested.md b/src/building/suggested.md index 25a4b62e0..e0156f9b8 100644 --- a/src/building/suggested.md +++ b/src/building/suggested.md @@ -273,7 +273,10 @@ If you're using nix, you can use the following nix-shell to work on Rust: pkgs.mkShell { name = "rustc"; nativeBuildInputs = with pkgs; [ - gcc_multi binutils cmake ninja openssl pkg-config python39 git curl cacert patchelf nix + binutils cmake ninja pkg-config python3 git curl cacert patchelf nix + ]; + buildInputs = [ + openssl glibc.out glibc.static ]; # Avoid creating text files for ICEs. RUSTC_ICE = "0"; From c7829394ec5f90074070bde155b50f9a50e2bcda Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Tue, 13 Feb 2024 20:07:32 +0100 Subject: [PATCH 4/5] short lines for the short line fans --- src/building/suggested.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/building/suggested.md b/src/building/suggested.md index e0156f9b8..4f432aeb8 100644 --- a/src/building/suggested.md +++ b/src/building/suggested.md @@ -283,8 +283,10 @@ pkgs.mkShell { } ``` -Note that when using nix on a not-NixOS distribution, it may be necessary to set **`patch-binaries-for-nix = true` in `config.toml`**. -Bootstrap tries to detect whether it's running in nix and enable patching automatically, but this detection can have false negatives. +Note that when using nix on a not-NixOS distribution, it may be necessary to set +**`patch-binaries-for-nix = true` in `config.toml`**. +Bootstrap tries to detect whether it's running in nix and enable patching automatically, +but this detection can have false negatives. You can also use your nix shell to manage `config.toml`: From 377e8587f1412d07cf09fb0693a5e65fa06094ef Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Sun, 25 Feb 2024 11:32:46 +0100 Subject: [PATCH 5/5] Fix pkgs --- src/building/suggested.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/building/suggested.md b/src/building/suggested.md index 4f432aeb8..b0883b1b6 100644 --- a/src/building/suggested.md +++ b/src/building/suggested.md @@ -275,7 +275,7 @@ pkgs.mkShell { nativeBuildInputs = with pkgs; [ binutils cmake ninja pkg-config python3 git curl cacert patchelf nix ]; - buildInputs = [ + buildInputs = with pkgs; [ openssl glibc.out glibc.static ]; # Avoid creating text files for ICEs.