summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide
diff options
context:
space:
mode:
authorJoshua Nelson <jyn514@gmail.com>2021-04-25 11:24:16 -0400
committerJoshua Nelson <joshua@yottadb.com>2021-04-27 08:52:22 -0400
commitf4253418965d62276ae24e4f1825b055a7beccf0 (patch)
tree491a535f2e597ba9e8f8e3c9719ffef76999556d /src/doc/rustc-dev-guide
parent3da52a13ca36d32e2444f7110eb9f963df12b002 (diff)
downloadrust-f4253418965d62276ae24e4f1825b055a7beccf0.tar.gz
rust-f4253418965d62276ae24e4f1825b055a7beccf0.zip
Add sample nix shell
This also suggests using `x.py setup` instead of copying config.toml.
Diffstat (limited to 'src/doc/rustc-dev-guide')
-rw-r--r--src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md19
-rw-r--r--src/doc/rustc-dev-guide/src/building/suggested.md71
2 files changed, 77 insertions, 13 deletions
diff --git a/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md b/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md
index 77f36cda86c..49c2e8b6649 100644
--- a/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md
+++ b/src/doc/rustc-dev-guide/src/building/how-to-build-and-run.md
@@ -20,16 +20,10 @@ cd rust
 
 ## Create a `config.toml`
 
-To start, copy [`config.toml.example`] to `config.toml`:
+To start, run `x.py setup`. This will create a `config.toml` with reasonable defaults.
 
-[`config.toml.example`]: https://github.com/rust-lang/rust/blob/master/config.toml.example
-
-```bash
-cp config.toml.example config.toml
-```
-
-Then you will want to open up the file and change the following
-settings (and possibly others, such as `llvm.ccache`):
+You may also want to change some of the following settings (and possibly others, such as
+`llvm.ccache`):
 
 ```toml
 [llvm]
@@ -54,10 +48,9 @@ debug-logging = true
 incremental = true
 ```
 
-If you have already built `rustc`, then you may have to execute `rm -rf build` for subsequent
-configuration changes to take effect. Note that `./x.py clean` will not cause a
-rebuild of LLVM, so if your configuration change affects LLVM, you will need to
-manually `rm -rf build/` before rebuilding.
+If you have already built `rustc` and you change settings related to LLVM, then you may have to
+execute `rm -rf build` for subsequent configuration changes to take effect. Note that `./x.py
+clean` will not cause a rebuild of LLVM.
 
 ## What is `x.py`?
 
diff --git a/src/doc/rustc-dev-guide/src/building/suggested.md b/src/doc/rustc-dev-guide/src/building/suggested.md
index ebefd61c136..f27793140d3 100644
--- a/src/doc/rustc-dev-guide/src/building/suggested.md
+++ b/src/doc/rustc-dev-guide/src/building/suggested.md
@@ -203,3 +203,74 @@ git worktree add -b my-feature ../rust2 master
 
 You can then use that rust2 folder as a separate workspace for modifying
 and building `rustc`!
+
+## Using nix-shell
+
+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.toml.example` from
+  # `1bd30ce2aac40c7698aa4a1b9520aa649ff2d1c5`.
+  config = pkgs.writeText "rustc-config" ''
+    profile = "compiler" # you may want to choose a different profile, like `library` or `tools`
+    changelog-seen = 2
+
+    [build]
+    # 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.toml.example
+        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; [
+    gcc9 binutils cmake ninja openssl pkgconfig python39 git curl cacert patchelf nix psutils
+  ];
+  RIPGREP_CONFIG_PATH = ripgrepConfig;
+  RUST_BOOTSTRAP_CONFIG = config;
+}
+```