1 # Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
13 # Greetings, adventurer! The Rust Build System is at your service.
15 # Whether you want a genuine copy of `rustc`, access to the latest and
16 # most authoritative Rust documentation, or even to investigate the
17 # most intimate workings of the compiler itself, you've come to the
18 # right place. Let's see what's on the menu.
20 # First, start with one of these build targets:
22 # * all - The default. Builds a complete, bootstrapped compiler.
23 # `rustc` will be in `${target-triple}/stage2/bin/`. Run it
24 # directly from the build directory if you like. This also
25 # comes with docs in `doc/`.
27 # * check - Run the complete test suite
29 # * install - Install Rust. Note that installation is not necessary
30 # to use the compiler.
32 # * uninstall - Uninstall the binaries
34 # For tips on working with The Rust Build System, just:
46 # # The Rust Build System Tip Line
48 # There are a bazillion different targets you might want to build. Here
51 # * docs - Build gobs of HTML documentation and put it into `doc/`
52 # * check-$(crate) - Test a crate, e.g. `check-std`
53 # * check-ref - Run the language reference tests
54 # * check-docs - Test the documentation examples
55 # * check-stage$(stage)-$(crate) - Test a crate in a specific stage
56 # * check-stage$(stage)-{rpass,rfail,cfail,rmake,...} - Run tests in src/test/
57 # * check-stage1-T-$(target)-H-$(host) - Run cross-compiled-tests
59 # Then mix in some of these environment variables to harness the
60 # ultimate power of The Rust Build System.
62 # * `VERBOSE=1` - Print all commands. Use this to see what's going on.
63 # * `RUSTFLAGS=...` - Add compiler flags to all `rustc` invocations
65 # * `TESTNAME=...` - Specify the name of tests to run
66 # * `CHECK_IGNORED=1` - Run normally-ignored tests
67 # * `NO_BENCH=1` - Don't run crate benchmarks (disable `--bench` flag)
69 # * `CFG_ENABLE_VALGRIND=1` - Run tests under valgrind
70 # * `VALGRIND_COMPILE=1` - Run the compiler itself under valgrind
71 # (may require `CFG_ENABLE_VALGRIND`)
73 # * `NO_REBUILD=1` - Don't rebootstrap when testing std
74 # (and possibly other crates)
75 # * `NO_MKFILE_DEPS=1` - Don't rebuild for modified .mk files
77 # * `SAVE_TEMPS=1` - Use `--save-temps` flag on all `rustc` invocations
78 # * `ASM_COMMENTS=1` - Use `-Z asm-comments`
79 # * `TIME_PASSES=1` - Use `-Z time-passes`
80 # * `TIME_LLVM_PASSES=1` - Use `-Z time-llvm-passes`
81 # * `TRACE=1` - Use `-Z trace`
83 # # Rust recipes for build system success
85 # // Modifying libstd? Use this comment to run unit tests just on your change
86 # make check-stage1-std NO_REBUILD=1 NO_BENCH=1
88 # // Added a run-pass test? Use this to test running your test
89 # make check-stage1-rpass TESTNAME=my-shiny-new-test
91 # // Having trouble figuring out which test is failing? Turn off parallel tests
92 # make check-stage1-std RUST_TEST_TASKS=1
94 # This is hardly all there is to know of The Rust Build System's
95 # mysteries. The tale continues on the wiki[1][2].
97 # [1]: https://github.com/mozilla/rust/wiki/Note-build-system
98 # [2]: https://github.com/mozilla/rust/wiki/Note-testsuite
100 # If you really feel like getting your hands dirty, then:
102 # run `make nitty-gritty`
108 # # The Rust Build System
110 # Gosh I wish there was something useful here (TODO).
112 # # An (old) explanation of how the build is structured:
114 # *Note: Hey, like, this is probably inaccurate, and is definitely
115 # an outdated and insufficient explanation of the remarkable
116 # Rust Build System.*
118 # There are multiple build stages (0-3) needed to verify that the
119 # compiler is properly self-hosting. Each stage is divided between
120 # 'host' artifacts and 'target' artifacts, where the stageN host
121 # compiler builds artifacts for 1 or more stageN target architectures.
122 # Once the stageN target compiler has been built for the host
123 # architecture it is promoted (copied) to a stageN+1 host artifact.
125 # The stage3 host compiler is a compiler that successfully builds
126 # itself and should (in theory) be bitwise identical to the stage2
127 # host compiler. The process is bootstrapped using a stage0 host
128 # compiler downloaded from a previous snapshot.
130 # At no time should stageN artifacts be interacting with artifacts
131 # from other stages. For consistency, we use the 'promotion' logic
132 # for all artifacts, even those that don't make sense on non-host
135 # The directory layout for a stage is intended to match the layout
136 # of the installed compiler, and looks like the following:
138 # stageN - this is the system root, corresponding to, e.g. /usr
139 # bin - binaries compiled for the host
140 # lib - libraries used by the host compiler
141 # rustlib - rustc's own place to organize libraries
142 # $(target) - target-specific artifacts
143 # bin - binaries for target architectures
144 # lib - libraries for target architectures
146 # A note about host libraries:
148 # The only libraries that get promoted to stageN/lib are those needed
149 # by rustc. In general, rust programs, even those compiled for the
150 # host architecture will use libraries from the target
151 # directories. This gives rust some freedom to experiment with how
152 # libraries are managed and versioned without polluting the common
153 # areas of the filesystem.
155 # General rust binaries may stil live in the host bin directory; they
156 # will just link against the libraries in the target lib directory.
158 # Admittedly this is a little convoluted.
163 ######################################################################
165 ######################################################################
167 # Issue #9531: If you change the order of any of the following (or add
168 # new definitions), make sure definitions always precede their uses,
169 # especially for the dependency lists of recipes.
171 # First, load the variables exported by the configure script
174 # Just a few macros used everywhere
175 include $(CFG_SRC_DIR)mk/util.mk
176 # All crates and their dependencies
177 include $(CFG_SRC_DIR)mk/crates.mk
178 # Reconfiguring when the makefiles or submodules change
179 include $(CFG_SRC_DIR)mk/reconfig.mk
180 # Various bits of setup, common macros, and top-level rules
181 include $(CFG_SRC_DIR)mk/main.mk
182 # C and assembly components that are not LLVM
183 include $(CFG_SRC_DIR)mk/rt.mk
184 # Rules for crates in the target directories
185 include $(CFG_SRC_DIR)mk/target.mk
186 # Rules for crates in the host directories
187 include $(CFG_SRC_DIR)mk/host.mk
188 # Special rules for bootstrapping stage0
189 include $(CFG_SRC_DIR)mk/stage0.mk
190 # Rust-specific LLVM extensions
191 include $(CFG_SRC_DIR)mk/rustllvm.mk
193 include $(CFG_SRC_DIR)mk/docs.mk
195 include $(CFG_SRC_DIR)mk/llvm.mk
197 ######################################################################
198 # Secondary makefiles, conditionalized for speed
199 ######################################################################
202 ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \
203 $(findstring clean,$(MAKECMDGOALS))),)
204 CFG_INFO := $(info cfg: including snap rules)
205 include $(CFG_SRC_DIR)mk/snap.mk
209 ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
210 $(findstring test,$(MAKECMDGOALS)) \
211 $(findstring perf,$(MAKECMDGOALS)) \
212 $(findstring tidy,$(MAKECMDGOALS))),)
213 CFG_INFO := $(info cfg: including test rules)
214 include $(CFG_SRC_DIR)mk/tests.mk
217 # Performance and benchmarking
218 ifneq ($(findstring perf,$(MAKECMDGOALS)),)
219 CFG_INFO := $(info cfg: including perf rules)
220 include $(CFG_SRC_DIR)mk/perf.mk
223 # Copy all the distributables to another directory for binary install
224 ifneq ($(strip $(findstring prepare,$(MAKECMDGOALS)) \
225 $(findstring install,$(MAKECMDGOALS))),)
226 CFG_INFO := $(info cfg: including prepare rules)
227 include $(CFG_SRC_DIR)mk/prepare.mk
230 # (Unix) Installation from the build directory
231 ifneq ($(findstring install,$(MAKECMDGOALS)),)
232 CFG_INFO := $(info cfg: including install rules)
233 include $(CFG_SRC_DIR)mk/install.mk
236 # Source and binary distribution artifacts
237 ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
238 $(findstring clean,$(MAKECMDGOALS))),)
239 CFG_INFO := $(info cfg: including dist rules)
240 include $(CFG_SRC_DIR)mk/dist.mk
244 ifneq ($(findstring clean,$(MAKECMDGOALS)),)
245 CFG_INFO := $(info cfg: including clean rules)
246 include $(CFG_SRC_DIR)mk/clean.mk
250 ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \
251 $(findstring TAGS.vi,$(MAKECMDGOALS))),)
252 CFG_INFO := $(info cfg: including ctags rules)
253 include $(CFG_SRC_DIR)mk/ctags.mk
256 # Find all of the .d files and include them to add information about
257 # header file dependencies.
258 ALL_DEP_FILES := $(ALL_OBJ_FILES:%.o=%.d)
259 -include $(ALL_DEP_FILES)