about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide
diff options
context:
space:
mode:
authorNilstrieb <48135649+Nilstrieb@users.noreply.github.com>2024-03-01 21:26:19 +0100
committerGitHub <noreply@github.com>2024-03-01 21:26:19 +0100
commit37d723bd15008012be8994ba6b3e65e8fa4aa7ab (patch)
tree5ada392a963d31bcad60f13e0a336118f7bc0350 /src/doc/rustc-dev-guide
parentbac165df82c024b16d4887b292cdac82ca63d50d (diff)
downloadrust-37d723bd15008012be8994ba6b3e65e8fa4aa7ab.tar.gz
rust-37d723bd15008012be8994ba6b3e65e8fa4aa7ab.zip
make shell.nix better (#1858)
* make shell.nix better

* Mention using RUST_BOOTSTRAP_CONFIG

* Move things to `buildInputs` and add `glibc.out glibc.static`

This fixes the nofile-limit.rs UI test.

* short lines for the short line fans

* Fix pkgs
Diffstat (limited to 'src/doc/rustc-dev-guide')
-rw-r--r--src/doc/rustc-dev-guide/src/building/suggested.md81
1 files changed, 24 insertions, 57 deletions
diff --git a/src/doc/rustc-dev-guide/src/building/suggested.md b/src/doc/rustc-dev-guide/src/building/suggested.md
index d4938cbf835..cb415a198f2 100644
--- a/src/doc/rustc-dev-guide/src/building/suggested.md
+++ b/src/doc/rustc-dev-guide/src/building/suggested.md
@@ -276,67 +276,34 @@ If you're using nix, you can use the following nix-shell to work on Rust:
 
 ```nix
 { pkgs ? import <nixpkgs> {} }:
-
-# 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
+    binutils cmake ninja pkg-config python3 git curl cacert patchelf nix
+  ];
+  buildInputs = with pkgs; [
+    openssl glibc.out glibc.static
   ];
-  RIPGREP_CONFIG_PATH = ripgrepConfig;
+  # Avoid creating text files for ICEs.
+  RUSTC_ICE = "0";
+}
+```
+
+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;
 }
 ```