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.
11 # An explanation of how the build is structured:
13 # There are multiple build stages (0-3) needed to verify that the
14 # compiler is properly self-hosting. Each stage is divided between
15 # 'host' artifacts and 'target' artifacts, where the stageN host
16 # compiler builds artifacts for 1 or more stageN target architectures.
17 # Once the stageN target compiler has been built for the host
18 # architecture it is promoted (copied) to a stageN+1 host artifact.
20 # The stage3 host compiler is a compiler that successfully builds
21 # itself and should (in theory) be bitwise identical to the stage2
22 # host compiler. The process is bootstrapped using a stage0 host
23 # compiler downloaded from a previous snapshot.
25 # At no time should stageN artifacts be interacting with artifacts
26 # from other stages. For consistency, we use the 'promotion' logic
27 # for all artifacts, even those that don't make sense on non-host
30 # The directory layout for a stage is intended to match the layout
31 # of the installed compiler, and looks like the following:
33 # stageN - this is the system root, corresponding to, e.g. /usr
34 # bin - binaries compiled for the host
35 # lib - libraries used by the host compiler
36 # rustc - rustc's own place to organize libraries
37 # $(target) - target-specific artifacts
38 # bin - binaries for target architectures
39 # lib - libraries for target architectures
41 # A note about host libraries:
43 # The only libraries that get promoted to stageN/lib are those needed
44 # by rustc. In general, rust programs, even those compiled for the
45 # host architecture will use libraries from the target
46 # directories. This gives rust some freedom to experiment with how
47 # libraries are managed and versioned without polluting the common
48 # areas of the filesystem.
50 # General rust binaries may stil live in the host bin directory; they
51 # will just link against the libraries in the target lib directory.
53 # Admittedly this is a little convoluted.
57 ######################################################################
58 # Residual auto-configuration
59 ######################################################################
61 # Recursive wildcard function
62 # http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
63 rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
64 $(filter $(subst *,%,$2),$d))
68 # We track all of the object files we might build so that we can find
69 # and include all of the .d files in one fell swoop.
72 MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*)
73 NON_BUILD_HOST_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_HOST_TRIPLES))
74 NON_BUILD_TARGET_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_TARGET_TRIPLES))
76 ifneq ($(MAKE_RESTARTS),)
77 CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
80 CFG_INFO := $(info cfg: build triple $(CFG_BUILD_TRIPLE))
81 CFG_INFO := $(info cfg: host triples $(CFG_HOST_TRIPLES))
82 CFG_INFO := $(info cfg: target triples $(CFG_TARGET_TRIPLES))
84 ifneq ($(wildcard $(NON_BUILD_HOST_TRIPLES)),)
85 CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST_TRIPLES))
87 ifneq ($(wildcard $(NON_BUILD_TARGET_TRIPLES)),)
88 CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET_TRIPLES))
91 CFG_RUSTC_FLAGS := $(RUSTFLAGS)
93 CFG_GCCISH_LINK_FLAGS :=
95 ifdef CFG_DISABLE_OPTIMIZE
96 $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
99 # The rtopt cfg turns off runtime sanity checks
100 CFG_RUSTC_FLAGS += -O --cfg rtopt
103 ifdef CFG_DISABLE_DEBUG
104 CFG_RUSTC_FLAGS += --cfg ndebug
105 CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
107 $(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
108 CFG_RUSTC_FLAGS += --cfg debug
109 CFG_GCCISH_CFLAGS += -DRUST_DEBUG
113 CFG_RUSTC_FLAGS += --save-temps
116 CFG_RUSTC_FLAGS += -Z asm-comments
119 CFG_RUSTC_FLAGS += -Z time-passes
121 ifdef TIME_LLVM_PASSES
122 CFG_RUSTC_FLAGS += -Z time-llvm-passes
125 CFG_RUSTC_FLAGS += -Z trace
128 RUSTFLAGS_STAGE1 += -Z no-debug-borrows
129 RUSTFLAGS_STAGE2 += -Z no-debug-borrows
132 # platform-specific auto-configuration
133 include $(CFG_SRC_DIR)mk/platform.mk
135 # Run the stage1/2 compilers under valgrind
136 ifdef VALGRIND_COMPILE
137 CFG_VALGRIND_COMPILE :=$(CFG_VALGRIND)
139 CFG_VALGRIND_COMPILE :=
142 # version-string calculation
143 CFG_GIT_DIR := $(CFG_SRC_DIR).git
144 CFG_RELEASE = 0.9-pre
145 CFG_VERSION = $(CFG_RELEASE)
146 # windows exe's need numeric versions - don't use anything but
147 # numbers and dots here
148 CFG_VERSION_WIN = 0.9
150 # since $(CFG_GIT) may contain spaces (especially on Windows),
151 # we need to escape them. (" " to r"\ ")
152 # Note that $(subst ...) ignores space after `subst`,
153 # so we use a hack: define $(SPACE) which contains space character.
156 ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT))),)
157 ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT_DIR))),)
158 CFG_VERSION += $(shell git --git-dir='$(CFG_GIT_DIR)' log -1 \
159 --pretty=format:'(%h %ci)')
160 CFG_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse HEAD)
164 ifdef CFG_ENABLE_VALGRIND
165 $(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND))
169 ifdef CFG_BAD_VALGRIND
170 $(info cfg: disabling valgrind due to its unreliability on this platform)
175 ######################################################################
176 # Target-and-rule "utility variables"
177 ######################################################################
190 X_$(1) := $(CFG_EXE_SUFFIX_$(1))
192 $(foreach target,$(CFG_TARGET_TRIPLES),\
193 $(eval $(call DEF_X,$(target))))
195 # Look in doc and src dirs.
196 VPATH := $(S)doc $(S)src
198 # "Source" files we generate in builddir along the way.
201 # Delete the built-in rules.
210 ######################################################################
212 ######################################################################
216 CFG_RUNTIME_$(1) :=$(call CFG_LIB_NAME_$(1),rustrt)
217 CFG_RUSTLLVM_$(1) :=$(call CFG_LIB_NAME_$(1),rustllvm)
218 CFG_STDLIB_$(1) :=$(call CFG_LIB_NAME_$(1),std)
219 CFG_EXTRALIB_$(1) :=$(call CFG_LIB_NAME_$(1),extra)
220 CFG_LIBRUSTC_$(1) :=$(call CFG_LIB_NAME_$(1),rustc)
221 CFG_LIBSYNTAX_$(1) :=$(call CFG_LIB_NAME_$(1),syntax)
222 CFG_LIBRUSTPKG_$(1) :=$(call CFG_LIB_NAME_$(1),rustpkg)
223 CFG_LIBRUSTDOC_$(1) :=$(call CFG_LIB_NAME_$(1),rustdoc)
225 EXTRALIB_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),extra)
226 STDLIB_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),std)
227 LIBRUSTC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustc)
228 LIBSYNTAX_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),syntax)
229 LIBRUSTPKG_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustpkg)
230 LIBRUSTDOC_GLOB_$(1) :=$(call CFG_LIB_GLOB_$(1),rustdoc)
231 EXTRALIB_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),extra)
232 STDLIB_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),std)
233 LIBRUSTC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustc)
234 LIBSYNTAX_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),syntax)
235 LIBRUSTPKG_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustpkg)
236 LIBRUSTDOC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustdoc)
240 # $(1) is the path for directory to match against
241 # $(2) is the glob to use in the match
242 # $(3) is filename (usually the target being created) to filter out from match
243 # (i.e. filename is not out-of-date artifact from prior Rust version/build)
245 # Note that a common bug is to accidentally construct the glob denoted
246 # by $(2) with a space character prefix, which invalidates the
247 # construction $(1)$(2).
248 define CHECK_FOR_OLD_GLOB_MATCHES_EXCEPT
249 $(Q)MATCHES="$(filter-out %$(3),$(wildcard $(1)/$(2)))"; if [ -n "$$MATCHES" ] ; then echo "Warning: there are previous" \'$(2)\' "libraries:" $$MATCHES; fi
252 # Same interface as above, but deletes rather than just listing the files.
253 define REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT
254 $(Q)MATCHES="$(filter-out %$(3),$(wildcard $(1)/$(2)))"; if [ -n "$$MATCHES" ] ; then echo "Warning: removing previous" \'$(2)\' "libraries:" $$MATCHES; rm $$MATCHES ; fi
257 # We use a different strategy for LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
258 # than in the macros above because it needs the result of running the
259 # `ls` command after other rules in the command list have run; the
260 # macro-expander for $(wildcard ...) would deliver its results too
261 # soon. (This is in contrast to the macros above, which are meant to
262 # be run at the outset of a command list in a rule.)
264 define LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
265 @echo "Info: now are following matches for" '$(2)' "libraries:"
266 @( cd $(1) && ( ls $(2) 2>/dev/null || true ) | grep -v $(3) || true )
269 define LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
273 $(foreach target,$(CFG_TARGET_TRIPLES),\
274 $(eval $(call DEF_LIBS,$(target))))
276 ######################################################################
277 # Standard library variables
278 ######################################################################
280 STDLIB_CRATE := $(S)src/libstd/std.rs
281 STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/libstd/, \
282 *.rs */*.rs */*/*rs */*/*/*rs))
284 ######################################################################
285 # Extra library variables
286 ######################################################################
288 EXTRALIB_CRATE := $(S)src/libextra/extra.rs
289 EXTRALIB_INPUTS := $(wildcard $(addprefix $(S)src/libextra/, \
292 ######################################################################
293 # rustc crate variables
294 ######################################################################
296 COMPILER_CRATE := $(S)src/librustc/rustc.rs
297 COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/librustc/, \
298 *.rs */*.rs */*/*.rs */*/*/*.rs))
300 LIBSYNTAX_CRATE := $(S)src/libsyntax/syntax.rs
301 LIBSYNTAX_INPUTS := $(wildcard $(addprefix $(S)src/libsyntax/, \
302 *.rs */*.rs */*/*.rs */*/*/*.rs))
304 DRIVER_CRATE := $(S)src/driver/driver.rs
306 ######################################################################
308 ######################################################################
311 LLVM_COMPONENTS=x86 arm mips ipo bitreader bitwriter linker asmparser jit mcjit \
312 interpreter instrumentation
315 # The configure script defines these variables with the target triples
316 # separated by Z. This defines new ones with the expected format.
317 CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1)))
318 CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1)))
320 # Any rules that depend on LLVM should depend on LLVM_CONFIG
321 LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X_$(1))
322 LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X_$(1))
323 LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
324 LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
325 LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
326 LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
327 LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs $$(LLVM_COMPONENTS))
328 LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
329 # On FreeBSD, it may search wrong headers (that are for pre-installed LLVM),
330 # so we replace -I with -iquote to ensure that it searches bundled LLVM first.
331 LLVM_CXXFLAGS_$(1)=$$(subst -I, -iquote , $$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags))
332 LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target)
334 LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
335 LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))
339 $(foreach host,$(CFG_HOST_TRIPLES), \
340 $(eval $(call DEF_LLVM_VARS,$(host))))
342 ######################################################################
343 # Exports for sub-utilities
344 ######################################################################
346 # Note that any variable that re-configure should pick up needs to be
352 export CFG_VERSION_WIN
353 export CFG_BUILD_TRIPLE
355 export CFG_ENABLE_MINGW_CROSS
359 ######################################################################
361 ######################################################################
363 ######################################################################
364 # Per-stage targets and runner
365 ######################################################################
368 # $(1) is the stage number
369 # $(2) is the target triple
370 # $(3) is the host triple
372 # Destinations of artifacts for the host compiler
373 HROOT$(1)_H_$(3) = $(3)/stage$(1)
374 HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
375 HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR)
377 # Destinations of artifacts for target architectures
378 TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustc/$(2)
379 TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
380 TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR)
382 # The name of the standard and extra libraries used by rustc
383 ifdef CFG_DISABLE_SHAREDSTD
384 HSTDLIB_DEFAULT$(1)_H_$(3) = \
385 $$(HLIB$(1)_H_$(3))/libstd.rlib
386 TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
387 $$(TLIB$(1)_T_$(2)_H_$(3))/libstd.rlib
389 HEXTRALIB_DEFAULT$(1)_H_$(3) = \
390 $$(HLIB$(1)_H_$(3))/libextra.rlib
391 TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
392 $$(TLIB$(1)_T_$(2)_H_$(3))/libextra.rlib
394 HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
395 $$(HLIB$(1)_H_$(3))/librustc.rlib
396 TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
397 $$(TLIB$(1)_T_$(2)_H_$(3))/librustc.rlib
399 HSTDLIB_DEFAULT$(1)_H_$(3) = \
400 $$(HLIB$(1)_H_$(3))/$(CFG_STDLIB_$(3))
401 TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
402 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2))
404 HEXTRALIB_DEFAULT$(1)_H_$(3) = \
405 $$(HLIB$(1)_H_$(3))/$(CFG_EXTRALIB_$(3))
406 TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
407 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2))
409 HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
410 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTC_$(3))
411 TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
412 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2))
415 # Preqrequisites for using the stageN compiler
417 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
418 $$(HLIB$(1)_H_$(3))/$(CFG_RUNTIME_$(3)) \
419 $$(HLIB$(1)_H_$(3))/$(CFG_RUSTLLVM_$(3)) \
420 $$(HSTDLIB_DEFAULT$(1)_H_$(3)) \
421 $$(HEXTRALIB_DEFAULT$(1)_H_$(3)) \
422 $$(HLIBSYNTAX_DEFAULT$(1)_H_$(3)) \
423 $$(HLIBRUSTC_DEFAULT$(1)_H_$(3)) \
426 # Prerequisites for using the stageN compiler to build target artifacts
427 TSREQ$(1)_T_$(2)_H_$(3) = \
428 $$(HSREQ$(1)_H_$(3)) \
429 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUNTIME_$(2)) \
430 $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a
432 # Prerequisites for a working stageN compiler and libraries, for a specific target
433 SREQ$(1)_T_$(2)_H_$(3) = \
434 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
435 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
436 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2))
438 # Prerequisites for a working stageN compiler and libraries, for a specific target
439 CSREQ$(1)_T_$(2)_H_$(3) = \
440 $$(TSREQ$(1)_T_$(2)_H_$(3)) \
441 $$(HBIN$(1)_H_$(3))/rustpkg$$(X_$(3)) \
442 $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
443 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTPKG_$(3)) \
444 $$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTDOC_$(3)) \
445 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)) \
446 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)) \
447 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(2)) \
448 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2)) \
449 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTPKG_$(2)) \
450 $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTDOC_$(2))
453 # Don't run the the stage0 compiler under valgrind - that ship has sailed
454 CFG_VALGRIND_COMPILE$(1) =
456 CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE)
459 # Add RUSTFLAGS_STAGEN values to the build command
460 EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1))
462 CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
464 # Pass --cfg stage0 only for the build->host part of stage0;
465 # if you're building a cross config, the host->* parts are
466 # effectively stage1, since it uses the just-built stage0.
468 ifneq ($(strip $(CFG_BUILD_TRIPLE)),$(strip $(3)))
469 CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
473 STAGE$(1)_T_$(2)_H_$(3) := \
474 $$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \
475 $$(CFG_VALGRIND_COMPILE$(1)) \
476 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
477 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
478 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
481 PERF_STAGE$(1)_T_$(2)_H_$(3) := \
482 $$(Q)$$(call CFG_RUN_TARG_$(3),$(1), \
484 $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
485 --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \
486 $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \
491 $(foreach build,$(CFG_HOST_TRIPLES), \
492 $(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
493 $(eval $(foreach stage,$(STAGES), \
494 $(eval $(call SREQ,$(stage),$(target),$(build))))))))
496 ######################################################################
499 # Builds a functional Rustc for the given host.
500 ######################################################################
502 define DEF_RUSTC_STAGE_TARGET
503 # $(1) == architecture
506 rustc-stage$(2)-H-$(1): \
507 $$(foreach target,$$(CFG_TARGET_TRIPLES), \
508 $$(SREQ$(2)_T_$$(target)_H_$(1)))
512 $(foreach host,$(CFG_HOST_TRIPLES), \
513 $(eval $(foreach stage,1 2 3, \
514 $(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage))))))
516 rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE)
517 rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE)
518 rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE)
520 define DEF_RUSTC_TARGET
521 # $(1) == architecture
523 rustc-H-$(1): rustc-stage2-H-$(1)
526 $(foreach host,$(CFG_TARGET_TRIPLES), \
527 $(eval $(call DEF_RUSTC_TARGET,$(host))))
529 rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE)
530 rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE)
531 rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE)
532 rustc: rustc-H-$(CFG_BUILD_TRIPLE)
534 rustc-H-all: $(foreach host,$(CFG_HOST_TRIPLES),rustc-H-$(host))
536 ######################################################################
538 ######################################################################
542 ifneq ($(CFG_IN_TRANSITION),)
544 CFG_INFO := $(info cfg:)
545 CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***)
546 CFG_INFO := $(info cfg: *** stage2 and later will not be built ***)
547 CFG_INFO := $(info cfg:)
549 #XXX This is surely busted
550 all: $(SREQ1$(CFG_BUILD_TRIPLE)) $(GENERATED) docs
555 ifneq ($$(findstring $(1),$$(CFG_HOST_TRIPLES)),)
557 all-target-$(1)-host-$(2): $$(CSREQ2_T_$(1)_H_$(2))
559 # This is a target only
560 all-target-$(1)-host-$(2): $$(SREQ2_T_$(1)_H_$(2))
564 $(foreach target,$(CFG_TARGET_TRIPLES), \
565 $(foreach host,$(CFG_HOST_TRIPLES), \
566 $(eval $(call ALL_TARGET_N,$(target),$(host)))))
568 ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET_TRIPLES), \
569 $(foreach host,$(CFG_HOST_TRIPLES), \
570 all-target-$(target)-host-$(host)))
572 all: $(ALL_TARGET_RULES) $(GENERATED) docs
577 ######################################################################
579 ######################################################################
581 ifndef CFG_DISABLE_MANAGE_SUBMODULES
582 # This is a pretty expensive operation but I don't see any way to avoid it
583 NEED_GIT_RECONFIG=$(shell cd "$(CFG_SRC_DIR)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)')
588 ifeq ($(NEED_GIT_RECONFIG),0)
590 # If the submodules have changed then always execute config.mk
594 Makefile config.mk: config.stamp
596 config.stamp: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
597 @$(call E, cfg: reconfiguring)
598 $(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
601 ######################################################################
602 # Primary-target makefiles
603 ######################################################################
605 # Issue #9531: If you change the order of any of the following (or add
606 # new definitions), make sure definitions always precede their uses,
607 # especially for the dependency lists of recipes.
609 include $(CFG_SRC_DIR)mk/target.mk
610 include $(CFG_SRC_DIR)mk/host.mk
611 include $(CFG_SRC_DIR)mk/stage0.mk
612 include $(CFG_SRC_DIR)mk/rt.mk
613 include $(CFG_SRC_DIR)mk/rustllvm.mk
614 include $(CFG_SRC_DIR)mk/tools.mk
615 include $(CFG_SRC_DIR)mk/docs.mk
616 include $(CFG_SRC_DIR)mk/llvm.mk
618 ######################################################################
619 # Secondary makefiles, conditionalized for speed
620 ######################################################################
622 ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
623 $(findstring check,$(MAKECMDGOALS)) \
624 $(findstring test,$(MAKECMDGOALS)) \
625 $(findstring tidy,$(MAKECMDGOALS)) \
626 $(findstring clean,$(MAKECMDGOALS))),)
627 CFG_INFO := $(info cfg: including dist rules)
628 include $(CFG_SRC_DIR)mk/dist.mk
631 ifneq ($(strip $(findstring snap,$(MAKECMDGOALS)) \
632 $(findstring clean,$(MAKECMDGOALS))),)
633 CFG_INFO := $(info cfg: including snap rules)
634 include $(CFG_SRC_DIR)mk/snap.mk
637 ifneq ($(findstring reformat,$(MAKECMDGOALS)),)
638 CFG_INFO := $(info cfg: including reformat rules)
639 include $(CFG_SRC_DIR)mk/pp.mk
642 ifneq ($(strip $(findstring check,$(MAKECMDGOALS)) \
643 $(findstring test,$(MAKECMDGOALS)) \
644 $(findstring perf,$(MAKECMDGOALS)) \
645 $(findstring tidy,$(MAKECMDGOALS))),)
646 CFG_INFO := $(info cfg: including test rules)
647 include $(CFG_SRC_DIR)mk/tests.mk
650 ifneq ($(findstring perf,$(MAKECMDGOALS)),)
651 CFG_INFO := $(info cfg: including perf rules)
652 include $(CFG_SRC_DIR)mk/perf.mk
655 ifneq ($(findstring clean,$(MAKECMDGOALS)),)
656 CFG_INFO := $(info cfg: including clean rules)
657 include $(CFG_SRC_DIR)mk/clean.mk
660 ifneq ($(findstring install,$(MAKECMDGOALS)),)
662 CFG_INFO := $(info cfg: setting CFG_PREFIX via DESTDIR, $(DESTDIR)/$(CFG_PREFIX))
663 CFG_PREFIX:=$(DESTDIR)/$(CFG_PREFIX)
667 CFG_INFO := $(info cfg: including install rules)
668 include $(CFG_SRC_DIR)mk/install.mk
671 ifneq ($(strip $(findstring TAGS.emacs,$(MAKECMDGOALS)) \
672 $(findstring TAGS.vi,$(MAKECMDGOALS))),)
673 CFG_INFO := $(info cfg: including ctags rules)
674 include $(CFG_SRC_DIR)mk/ctags.mk
677 # Find all of the .d files and include them to add information about
678 # header file dependencies.
679 ALL_DEP_FILES := $(ALL_OBJ_FILES:%.o=%.d)
680 -include $(ALL_DEP_FILES)