@@ -6,6 +6,7 @@ links to the major sections:
6
6
7
7
* [ Feature Requests] ( #feature-requests )
8
8
* [ Bug Reports] ( #bug-reports )
9
+ * [ The Build System] ( #the-build-system )
9
10
* [ Pull Requests] ( #pull-requests )
10
11
* [ Writing Documentation] ( #writing-documentation )
11
12
* [ Issue Triage] ( #issue-triage )
@@ -77,6 +78,66 @@ to do this is to invoke `rustc` like this:
77
78
$ RUST_BACKTRACE=1 rustc ...
78
79
```
79
80
81
+ ## The Build System
82
+
83
+ Rust's build system allows you to bootstrap the compiler, run tests &
84
+ benchmarks, generate documentation, install a fresh build of Rust, and more.
85
+ It's your best friend when working on Rust, allowing you to compile & test
86
+ your contributions before submission.
87
+
88
+ All the configuration for the build system lives in [ the ` mk ` directory] [ mkdir ]
89
+ in the project root. It can be hard to follow in places, as it uses some
90
+ advanced Make features which make for some challenging reading. If you have
91
+ questions on the build system internals, try asking in
92
+ [ ` #rust-internals ` ] [ pound-rust-internals ] .
93
+
94
+ [ mkdir ] : https://github.com/rust-lang/rust/tree/master/mk/
95
+
96
+ ### Configuration
97
+
98
+ Before you can start building the compiler you need to configure the build for
99
+ your system. In most cases, that will just mean using the defaults provided
100
+ for Rust. Configuring involves invoking the ` configure ` script in the project
101
+ root.
102
+
103
+ ```
104
+ ./configure
105
+ ```
106
+
107
+ There are large number of options accepted by this script to alter the
108
+ configuration used later in the build process. Some options to note:
109
+
110
+ - ` --enable-debug ` - Build a debug version of the compiler (disables optimizations)
111
+ - ` --enable-optimize ` - Enable optimizations (can be used with ` --enable-debug `
112
+ to make a debug build with optimizations)
113
+ - ` --disable-valgrind-rpass ` - Don't run tests with valgrind
114
+ - ` --enable-clang ` - Prefer clang to gcc for building dependencies (e.g., LLVM)
115
+ - ` --enable-ccache ` - Invoke clang/gcc with ccache to re-use object files between builds
116
+ - ` --enable-compiler-docs ` - Build compiler documentation
117
+
118
+ To see a full list of options, run ` ./configure --help ` .
119
+
120
+ ### Useful Targets
121
+
122
+ Some common make targets are:
123
+
124
+ - ` make rustc-stage1 ` - build up to (and including) the first stage. For most
125
+ cases we don't need to build the stage2 compiler, so we can save time by not
126
+ building it. The stage1 compiler is a fully functioning compiler and
127
+ (probably) will be enough to determine if your change works as expected.
128
+ - ` make check ` - build the full compiler & run all tests (takes a while). This
129
+ is what gets run by the continuous integration system against your pull
130
+ request. You should run this before submitting to make sure your tests pass
131
+ & everything builds in the correct manner.
132
+ - ` make check-stage1-std NO_REBUILD=1 ` - test the standard library without
133
+ rebuilding the entire compiler
134
+ - ` make check TESTNAME=<path-to-test-file>.rs ` - Run a single test file
135
+ - ` make check-stage1-rpass TESTNAME=<path-to-test-file>.rs ` - Run a single
136
+ rpass test with the stage1 compiler (this will be quicker than running the
137
+ command above as we only build the stage1 compiler, not the entire thing).
138
+ You can also leave off the ` -rpass ` to run all stage1 test types.
139
+ - ` make check-stage1-coretest ` - Run stage1 tests in ` libcore ` .
140
+
80
141
## Pull Requests
81
142
82
143
Pull requests are the primary mechanism we use to change Rust. GitHub itself
0 commit comments