Skip to content

Commit 3bedec0

Browse files
committed
Auto merge of #34007 - flo-l:improve-hacking-docs, r=alexcrichton
add documentation on howto build just rustc without libstd to the build system I searched for days until I found this, maybe this helps other poor souls 😂 for reference #33990
2 parents 763f923 + 4e87986 commit 3bedec0

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CONTRIBUTING.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ root.
108108
There are large number of options accepted by this script to alter the
109109
configuration used later in the build process. Some options to note:
110110

111-
- `--enable-debug` - Build a debug version of the compiler (disables optimizations)
111+
- `--enable-debug` - Build a debug version of the compiler (disables optimizations,
112+
which speeds up compilation of stage1 rustc)
112113
- `--enable-optimize` - Enable optimizations (can be used with `--enable-debug`
113114
to make a debug build with optimizations)
114115
- `--disable-valgrind-rpass` - Don't run tests with valgrind
@@ -128,6 +129,12 @@ Some common make targets are:
128129
cases we don't need to build the stage2 compiler, so we can save time by not
129130
building it. The stage1 compiler is a fully functioning compiler and
130131
(probably) will be enough to determine if your change works as expected.
132+
- `make $host/stage1/bin/rustc` - Where $host is a target triple like x86_64-unknown-linux-gnu.
133+
This will build just rustc, without libstd. This is the fastest way to recompile after
134+
you changed only rustc source code. Note however that the resulting rustc binary
135+
won't have a stdlib to link against by default. You can build libstd once with
136+
`make rustc-stage1`, rustc will pick it up afterwards. libstd is only guaranteed to
137+
work if recompiled, so if there are any issues recompile it.
131138
- `make check` - build the full compiler & run all tests (takes a while). This
132139
is what gets run by the continuous integration system against your pull
133140
request. You should run this before submitting to make sure your tests pass

Makefile.in

+11
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262
# * tidy - Basic style check, show highest rustc error code and
6363
# the status of language and lib features
6464
# * rustc-stage$(stage) - Only build up to a specific stage
65+
# * $host/stage1/bin/rustc - Only build stage1 rustc, not libstd. For further
66+
# information see "Rust recipes for build system success" below.
6567
#
6668
# Then mix in some of these environment variables to harness the
6769
# ultimate power of The Rust Build System.
@@ -93,6 +95,15 @@
9395
# // Modifying libstd? Use this command to run unit tests just on your change
9496
# make check-stage1-std NO_REBUILD=1 NO_BENCH=1
9597
#
98+
# // Modifying just rustc?
99+
# // Compile rustc+libstd once
100+
# make rustc-stage1
101+
# // From now on use this command to rebuild just rustc and reuse the previously built libstd
102+
# // $host is a target triple, eg. x86_64-unknown-linux-gnu
103+
# // The resulting binary is located at $host/stage1/bin/rustc.
104+
# // If there are any issues with libstd recompile it with the command above.
105+
# make $host/stage1/bin/rustc
106+
#
96107
# // Added a run-pass test? Use this to test running your test
97108
# make check-stage1-rpass TESTNAME=my-shiny-new-test
98109
#

0 commit comments

Comments
 (0)