]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | # Copyright 2014-2015 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. | |
4 | # | |
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. | |
10 | ||
11 | ###################################################################### | |
12 | # Version numbers and strings | |
13 | ###################################################################### | |
14 | ||
15 | # The version number | |
54a0048b | 16 | CFG_RELEASE_NUM=1.9.0 |
1a4d82fc | 17 | |
85aaf69f SL |
18 | # An optional number to put after the label, e.g. '.2' -> '-beta.2' |
19 | # NB Make sure it starts with a dot to conform to semver pre-release | |
20 | # versions (section 9) | |
54a0048b | 21 | CFG_PRERELEASE_VERSION=.3 |
1a4d82fc | 22 | |
d9579d0f AL |
23 | # Append a version-dependent hash to each library, so we can install different |
24 | # versions in the same place | |
9cc50fc6 | 25 | CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(CFG_HASH_COMMAND)) |
1a4d82fc | 26 | |
54a0048b SL |
27 | # A magic value that allows the compiler to use unstable features during the |
28 | # bootstrap even when doing so would normally be an error because of feature | |
29 | # staging or because the build turns on warnings-as-errors and unstable features | |
30 | # default to warnings. The build has to match this key in an env var. | |
31 | # | |
32 | # This value is keyed off the release to ensure that all compilers for one | |
33 | # particular release have the same bootstrap key. Note that this is | |
34 | # intentionally not "secure" by any definition, this is largely just a deterrent | |
35 | # from users enabling unstable features on the stable compiler. | |
36 | CFG_BOOTSTRAP_KEY=$(CFG_FILENAME_EXTRA) | |
37 | ||
1a4d82fc JJ |
38 | ifeq ($(CFG_RELEASE_CHANNEL),stable) |
39 | # This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly" | |
40 | CFG_RELEASE=$(CFG_RELEASE_NUM) | |
41 | # This is the string used in dist artifact file names, e.g. "0.12.0", "nightly" | |
42 | CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM) | |
43 | CFG_DISABLE_UNSTABLE_FEATURES=1 | |
44 | endif | |
45 | ifeq ($(CFG_RELEASE_CHANNEL),beta) | |
c34b1796 | 46 | CFG_RELEASE=$(CFG_RELEASE_NUM)-beta$(CFG_PRERELEASE_VERSION) |
d9579d0f AL |
47 | # When building beta distributables just reuse the same "beta" name |
48 | # so when we upload we'll always override the previous beta. This | |
49 | # doesn't actually impact the version reported by rustc - it's just | |
50 | # for file naming. | |
51 | CFG_PACKAGE_VERS=beta | |
1a4d82fc JJ |
52 | CFG_DISABLE_UNSTABLE_FEATURES=1 |
53 | endif | |
54 | ifeq ($(CFG_RELEASE_CHANNEL),nightly) | |
55 | CFG_RELEASE=$(CFG_RELEASE_NUM)-nightly | |
56 | # When building nightly distributables just reuse the same "nightly" name | |
57 | # so when we upload we'll always override the previous nighly. This | |
58 | # doesn't actually impact the version reported by rustc - it's just | |
59 | # for file naming. | |
60 | CFG_PACKAGE_VERS=nightly | |
61 | endif | |
62 | ifeq ($(CFG_RELEASE_CHANNEL),dev) | |
63 | CFG_RELEASE=$(CFG_RELEASE_NUM)-dev | |
64 | CFG_PACKAGE_VERS=$(CFG_RELEASE_NUM)-dev | |
65 | endif | |
66 | ||
67 | # The name of the package to use for creating tarballs, installers etc. | |
68 | CFG_PACKAGE_NAME=rustc-$(CFG_PACKAGE_VERS) | |
69 | ||
70 | # The version string plus commit information - this is what rustc reports | |
71 | CFG_VERSION = $(CFG_RELEASE) | |
72 | CFG_GIT_DIR := $(CFG_SRC_DIR).git | |
73 | # since $(CFG_GIT) may contain spaces (especially on Windows), | |
74 | # we need to escape them. (" " to r"\ ") | |
75 | # Note that $(subst ...) ignores space after `subst`, | |
76 | # so we use a hack: define $(SPACE) which contains space character. | |
77 | SPACE := | |
78 | SPACE += | |
79 | ifneq ($(CFG_GIT),) | |
80 | ifneq ($(wildcard $(subst $(SPACE),\$(SPACE),$(CFG_GIT_DIR))),) | |
85aaf69f | 81 | CFG_VER_DATE = $(shell git --git-dir='$(CFG_GIT_DIR)' log -1 --date=short --pretty=format:'%cd') |
1a4d82fc JJ |
82 | CFG_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse HEAD) |
83 | CFG_SHORT_VER_HASH = $(shell git --git-dir='$(CFG_GIT_DIR)' rev-parse --short=9 HEAD) | |
84 | CFG_VERSION += ($(CFG_SHORT_VER_HASH) $(CFG_VER_DATE)) | |
85 | endif | |
86 | endif | |
87 | ||
88 | # Windows exe's need numeric versions - don't use anything but | |
89 | # numbers and dots here | |
90 | CFG_VERSION_WIN = $(CFG_RELEASE_NUM) | |
91 | ||
85aaf69f | 92 | CFG_INFO := $(info cfg: version $(CFG_VERSION)) |
1a4d82fc JJ |
93 | |
94 | ###################################################################### | |
95 | # More configuration | |
96 | ###################################################################### | |
97 | ||
1a4d82fc JJ |
98 | MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*) |
99 | MKFILES_FOR_TARBALL:=$(MKFILE_DEPS) | |
100 | ifneq ($(NO_MKFILE_DEPS),) | |
101 | MKFILE_DEPS := | |
102 | endif | |
103 | NON_BUILD_HOST = $(filter-out $(CFG_BUILD),$(CFG_HOST)) | |
104 | NON_BUILD_TARGET = $(filter-out $(CFG_BUILD),$(CFG_TARGET)) | |
105 | ||
106 | ifneq ($(MAKE_RESTARTS),) | |
107 | CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS)) | |
108 | endif | |
109 | ||
110 | CFG_INFO := $(info cfg: build triple $(CFG_BUILD)) | |
111 | CFG_INFO := $(info cfg: host triples $(CFG_HOST)) | |
112 | CFG_INFO := $(info cfg: target triples $(CFG_TARGET)) | |
113 | ||
114 | ifneq ($(wildcard $(NON_BUILD_HOST)),) | |
115 | CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST)) | |
116 | endif | |
117 | ifneq ($(wildcard $(NON_BUILD_TARGET)),) | |
118 | CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET)) | |
119 | endif | |
120 | ||
121 | CFG_RUSTC_FLAGS := $(RUSTFLAGS) | |
122 | CFG_GCCISH_CFLAGS := | |
123 | CFG_GCCISH_LINK_FLAGS := | |
124 | ||
92a42be0 | 125 | CFG_JEMALLOC_FLAGS := |
1a4d82fc JJ |
126 | |
127 | ifdef CFG_DISABLE_OPTIMIZE | |
128 | $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE)) | |
129 | CFG_RUSTC_FLAGS += | |
130 | CFG_JEMALLOC_FLAGS += --enable-debug | |
131 | else | |
132 | # The rtopt cfg turns off runtime sanity checks | |
133 | CFG_RUSTC_FLAGS += -O --cfg rtopt | |
134 | endif | |
135 | ||
136 | CFG_JEMALLOC_FLAGS += $(JEMALLOC_FLAGS) | |
137 | ||
9346a6ac AL |
138 | ifdef CFG_ENABLE_DEBUG_ASSERTIONS |
139 | $(info cfg: enabling debug assertions (CFG_ENABLE_DEBUG_ASSERTIONS)) | |
62682a34 | 140 | CFG_RUSTC_FLAGS += -C debug-assertions=on |
9346a6ac AL |
141 | endif |
142 | ||
143 | ifdef CFG_ENABLE_DEBUGINFO | |
144 | $(info cfg: enabling debuginfo (CFG_ENABLE_DEBUGINFO)) | |
9cc50fc6 | 145 | CFG_RUSTC_FLAGS += -g |
1a4d82fc JJ |
146 | endif |
147 | ||
54a0048b SL |
148 | ifdef CFG_ENABLE_ORBIT |
149 | $(info cfg: launching MIR (CFG_ENABLE_ORBIT)) | |
150 | CFG_RUSTC_FLAGS += -Z orbit | |
151 | endif | |
152 | ||
1a4d82fc JJ |
153 | ifdef SAVE_TEMPS |
154 | CFG_RUSTC_FLAGS += --save-temps | |
155 | endif | |
156 | ifdef ASM_COMMENTS | |
157 | CFG_RUSTC_FLAGS += -Z asm-comments | |
158 | endif | |
159 | ifdef TIME_PASSES | |
160 | CFG_RUSTC_FLAGS += -Z time-passes | |
161 | endif | |
162 | ifdef TIME_LLVM_PASSES | |
163 | CFG_RUSTC_FLAGS += -Z time-llvm-passes | |
164 | endif | |
165 | ifdef TRACE | |
166 | CFG_RUSTC_FLAGS += -Z trace | |
167 | endif | |
9cc50fc6 | 168 | ifndef CFG_DISABLE_RPATH |
1a4d82fc JJ |
169 | CFG_RUSTC_FLAGS += -C rpath |
170 | endif | |
171 | ||
172 | # The executables crated during this compilation process have no need to include | |
173 | # static copies of libstd and libextra. We also generate dynamic versions of all | |
174 | # libraries, so in the interest of space, prefer dynamic linking throughout the | |
175 | # compilation process. | |
176 | # | |
177 | # Note though that these flags are omitted for the *bins* in stage2+. This means | |
178 | # that the snapshot will be generated with a statically linked rustc so we only | |
179 | # have to worry about the distribution of one file (with its native dynamic | |
180 | # dependencies) | |
e9174d1e | 181 | RUSTFLAGS_STAGE0 += -C prefer-dynamic -C no-stack-check |
1a4d82fc JJ |
182 | RUSTFLAGS_STAGE1 += -C prefer-dynamic |
183 | RUST_LIB_FLAGS_ST2 += -C prefer-dynamic | |
184 | RUST_LIB_FLAGS_ST3 += -C prefer-dynamic | |
185 | ||
186 | # Landing pads require a lot of codegen. We can get through bootstrapping faster | |
187 | # by not emitting them. | |
b039eaaf SL |
188 | |
189 | ifdef CFG_DISABLE_STAGE0_LANDING_PADS | |
190 | RUSTFLAGS_STAGE0 += -Z no-landing-pads | |
191 | endif | |
e9174d1e | 192 | |
1a4d82fc JJ |
193 | # platform-specific auto-configuration |
194 | include $(CFG_SRC_DIR)mk/platform.mk | |
195 | ||
196 | # Run the stage1/2 compilers under valgrind | |
197 | ifdef VALGRIND_COMPILE | |
92a42be0 | 198 | CFG_VALGRIND_COMPILE := $(CFG_VALGRIND) |
1a4d82fc JJ |
199 | else |
200 | CFG_VALGRIND_COMPILE := | |
201 | endif | |
202 | ||
203 | ||
204 | ifndef CFG_DISABLE_VALGRIND_RPASS | |
205 | $(info cfg: enabling valgrind run-pass tests (CFG_ENABLE_VALGRIND_RPASS)) | |
85aaf69f | 206 | $(info cfg: valgrind-rpass command set to $(CFG_VALGRIND)) |
1a4d82fc JJ |
207 | CFG_VALGRIND_RPASS :=$(CFG_VALGRIND) |
208 | else | |
d9579d0f | 209 | $(info cfg: disabling valgrind run-pass tests) |
1a4d82fc JJ |
210 | CFG_VALGRIND_RPASS := |
211 | endif | |
212 | ||
213 | ||
214 | ifdef CFG_ENABLE_VALGRIND | |
215 | $(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND)) | |
92a42be0 | 216 | CFG_JEMALLOC_FLAGS += --enable-valgrind |
1a4d82fc JJ |
217 | else |
218 | CFG_VALGRIND := | |
219 | endif | |
220 | ||
221 | ###################################################################### | |
222 | # Target-and-rule "utility variables" | |
223 | ###################################################################### | |
224 | ||
225 | define DEF_FOR_TARGET | |
226 | X_$(1) := $(CFG_EXE_SUFFIX_$(1)) | |
227 | ifndef CFG_LLVM_TARGET_$(1) | |
228 | CFG_LLVM_TARGET_$(1) := $(1) | |
229 | endif | |
230 | endef | |
231 | $(foreach target,$(CFG_TARGET), \ | |
232 | $(eval $(call DEF_FOR_TARGET,$(target)))) | |
233 | ||
234 | # "Source" files we generate in builddir along the way. | |
235 | GENERATED := | |
236 | ||
237 | # Delete the built-in rules. | |
238 | .SUFFIXES: | |
239 | %:: %,v | |
240 | %:: RCS/%,v | |
241 | %:: RCS/% | |
242 | %:: s.% | |
243 | %:: SCCS/s.% | |
244 | ||
245 | ||
246 | ###################################################################### | |
247 | # Cleaning out old crates | |
248 | ###################################################################### | |
249 | ||
250 | # $(1) is the path for directory to match against | |
251 | # $(2) is the glob to use in the match | |
252 | # | |
253 | # Note that a common bug is to accidentally construct the glob denoted | |
254 | # by $(2) with a space character prefix, which invalidates the | |
255 | # construction $(1)$(2). | |
256 | define CHECK_FOR_OLD_GLOB_MATCHES | |
257 | $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then echo "warning: there are previous" \'$(notdir $(2))\' "libraries:" $$MATCHES; fi | |
258 | endef | |
259 | ||
260 | # Same interface as above, but deletes rather than just listing the files. | |
261 | ifdef VERBOSE | |
262 | define REMOVE_ALL_OLD_GLOB_MATCHES | |
263 | $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then echo "warning: removing previous" \'$(notdir $(1))\' "libraries:" $$MATCHES; rm $$MATCHES ; fi | |
264 | endef | |
265 | else | |
266 | define REMOVE_ALL_OLD_GLOB_MATCHES | |
267 | $(Q)MATCHES="$(wildcard $(1))"; if [ -n "$$MATCHES" ] ; then rm $$MATCHES ; fi | |
268 | endef | |
269 | endif | |
270 | ||
271 | # We use a different strategy for LIST_ALL_OLD_GLOB_MATCHES_EXCEPT | |
272 | # than in the macros above because it needs the result of running the | |
273 | # `ls` command after other rules in the command list have run; the | |
274 | # macro-expander for $(wildcard ...) would deliver its results too | |
275 | # soon. (This is in contrast to the macros above, which are meant to | |
276 | # be run at the outset of a command list in a rule.) | |
277 | ifdef VERBOSE | |
278 | define LIST_ALL_OLD_GLOB_MATCHES | |
279 | @echo "info: now are following matches for" '$(notdir $(1))' "libraries:" | |
280 | @( ls $(1) 2>/dev/null || true ) | |
281 | endef | |
282 | else | |
283 | define LIST_ALL_OLD_GLOB_MATCHES | |
284 | endef | |
285 | endif | |
286 | ||
287 | ###################################################################### | |
288 | # LLVM macros | |
289 | ###################################################################### | |
290 | ||
9cc50fc6 SL |
291 | LLVM_OPTIONAL_COMPONENTS=x86 arm aarch64 mips powerpc pnacl |
292 | LLVM_REQUIRED_COMPONENTS=ipo bitreader bitwriter linker asmparser mcjit \ | |
1a4d82fc JJ |
293 | interpreter instrumentation |
294 | ||
9cc50fc6 SL |
295 | ifneq ($(CFG_LLVM_ROOT),) |
296 | # Ensure we only try to link targets that the installed LLVM actually has: | |
297 | LLVM_COMPONENTS := $(filter $(shell $(CFG_LLVM_ROOT)/bin/llvm-config$(X_$(CFG_BUILD)) --components),\ | |
298 | $(LLVM_OPTIONAL_COMPONENTS)) $(LLVM_REQUIRED_COMPONENTS) | |
299 | else | |
300 | LLVM_COMPONENTS := $(LLVM_OPTIONAL_COMPONENTS) $(LLVM_REQUIRED_COMPONENTS) | |
301 | endif | |
302 | ||
1a4d82fc JJ |
303 | # Only build these LLVM tools |
304 | LLVM_TOOLS=bugpoint llc llvm-ar llvm-as llvm-dis llvm-mc opt llvm-extract | |
305 | ||
306 | define DEF_LLVM_VARS | |
307 | # The configure script defines these variables with the target triples | |
308 | # separated by Z. This defines new ones with the expected format. | |
309 | ifeq ($$(CFG_LLVM_ROOT),) | |
310 | CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1))) | |
311 | CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1))) | |
312 | else | |
313 | CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_ROOT) | |
314 | endif | |
315 | ||
316 | # Any rules that depend on LLVM should depend on LLVM_CONFIG | |
317 | LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config$$(X_$(1)) | |
318 | LLVM_MC_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-mc$$(X_$(1)) | |
62682a34 | 319 | LLVM_AR_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-ar$$(X_$(1)) |
1a4d82fc JJ |
320 | LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version) |
321 | LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir) | |
322 | LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir) | |
323 | LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir) | |
e9174d1e | 324 | LLVM_LIBDIR_RUSTFLAGS_$(1)=-L native="$$(LLVM_LIBDIR_$(1))" |
1a4d82fc | 325 | LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags) |
62682a34 | 326 | ifeq ($$(findstring freebsd,$(1)),freebsd) |
1a4d82fc JJ |
327 | # On FreeBSD, it may search wrong headers (that are for pre-installed LLVM), |
328 | # so we replace -I with -iquote to ensure that it searches bundled LLVM first. | |
329 | LLVM_CXXFLAGS_$(1)=$$(subst -I, -iquote , $$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags)) | |
62682a34 SL |
330 | else |
331 | LLVM_CXXFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags) | |
332 | endif | |
1a4d82fc JJ |
333 | LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target) |
334 | ||
335 | LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1)) | |
336 | LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1)) | |
337 | ||
9cc50fc6 SL |
338 | LLVM_ALL_COMPONENTS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --components) |
339 | ||
1a4d82fc JJ |
340 | endef |
341 | ||
342 | $(foreach host,$(CFG_HOST), \ | |
343 | $(eval $(call DEF_LLVM_VARS,$(host)))) | |
344 | ||
345 | ###################################################################### | |
346 | # Exports for sub-utilities | |
347 | ###################################################################### | |
348 | ||
349 | # Note that any variable that re-configure should pick up needs to be | |
350 | # exported | |
351 | ||
352 | export CFG_SRC_DIR | |
62682a34 | 353 | export CFG_SRC_DIR_RELATIVE |
1a4d82fc JJ |
354 | export CFG_BUILD_DIR |
355 | ifdef CFG_VER_DATE | |
356 | export CFG_VER_DATE | |
357 | endif | |
358 | ifdef CFG_VER_HASH | |
359 | export CFG_VER_HASH | |
360 | endif | |
361 | export CFG_VERSION | |
362 | export CFG_VERSION_WIN | |
363 | export CFG_RELEASE | |
364 | export CFG_PACKAGE_NAME | |
365 | export CFG_BUILD | |
366 | export CFG_RELEASE_CHANNEL | |
367 | export CFG_LLVM_ROOT | |
368 | export CFG_PREFIX | |
369 | export CFG_LIBDIR | |
370 | export CFG_LIBDIR_RELATIVE | |
371 | export CFG_DISABLE_INJECT_STD_VERSION | |
372 | ifdef CFG_DISABLE_UNSTABLE_FEATURES | |
373 | CFG_INFO := $(info cfg: disabling unstable features (CFG_DISABLE_UNSTABLE_FEATURES)) | |
374 | # Turn on feature-staging | |
375 | export CFG_DISABLE_UNSTABLE_FEATURES | |
1a4d82fc | 376 | # Subvert unstable feature lints to do the self-build |
1a4d82fc | 377 | export RUSTC_BOOTSTRAP_KEY:=$(CFG_BOOTSTRAP_KEY) |
85aaf69f SL |
378 | endif |
379 | export CFG_BOOTSTRAP_KEY | |
7453a54e SL |
380 | ifdef CFG_MUSL_ROOT |
381 | export CFG_MUSL_ROOT | |
382 | endif | |
1a4d82fc JJ |
383 | |
384 | ###################################################################### | |
385 | # Per-stage targets and runner | |
386 | ###################################################################### | |
387 | ||
388 | # Valid setting-strings are 'all', 'none', 'gdb', 'lldb' | |
389 | # This 'function' will determine which debugger scripts to copy based on a | |
390 | # target triple. See debuggers.mk for more information. | |
391 | TRIPLE_TO_DEBUGGER_SCRIPT_SETTING=\ | |
392 | $(if $(findstring windows,$(1)),none,$(if $(findstring darwin,$(1)),lldb,gdb)) | |
393 | ||
394 | STAGES = 0 1 2 3 | |
395 | ||
396 | define SREQ | |
397 | # $(1) is the stage number | |
398 | # $(2) is the target triple | |
399 | # $(3) is the host triple | |
400 | ||
401 | # Destinations of artifacts for the host compiler | |
402 | HROOT$(1)_H_$(3) = $(3)/stage$(1) | |
403 | HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin | |
92a42be0 | 404 | |
1a4d82fc | 405 | ifeq ($$(CFG_WINDOWSY_$(3)),1) |
92a42be0 SL |
406 | # On Windows we always store host runtime libraries in the 'bin' directory because |
407 | # there's no rpath. Target libraries go under $CFG_LIBDIR_RELATIVE (usually 'lib'). | |
408 | HLIB_RELATIVE$(1)_H_$(3) = bin | |
409 | TROOT$(1)_T_$(2)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)/rustlib/$(2) | |
410 | # Remove the next 3 lines after a snapshot | |
411 | ifeq ($(1),0) | |
412 | RUSTFLAGS_STAGE0 += -L $$(TROOT$(1)_T_$(2)_H_$(3))/lib | |
413 | endif | |
414 | ||
1a4d82fc | 415 | else |
92a42be0 | 416 | |
1a4d82fc | 417 | ifeq ($(1),0) |
92a42be0 | 418 | HLIB_RELATIVE$(1)_H_$(3) = lib |
1a4d82fc | 419 | else |
92a42be0 | 420 | HLIB_RELATIVE$(1)_H_$(3) = $$(CFG_LIBDIR_RELATIVE) |
1a4d82fc | 421 | endif |
92a42be0 SL |
422 | TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/rustlib/$(2) |
423 | ||
1a4d82fc | 424 | endif |
92a42be0 | 425 | HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(HLIB_RELATIVE$(1)_H_$(3)) |
1a4d82fc JJ |
426 | |
427 | # Destinations of artifacts for target architectures | |
1a4d82fc JJ |
428 | TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin |
429 | TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib | |
430 | ||
431 | # Preqrequisites for using the stageN compiler | |
432 | ifeq ($(1),0) | |
433 | HSREQ$(1)_H_$(3) = $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) | |
434 | else | |
435 | HSREQ$(1)_H_$(3) = \ | |
436 | $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ | |
437 | $$(MKFILE_DEPS) \ | |
438 | tmp/install-debugger-scripts$(1)_H_$(3)-$$(call TRIPLE_TO_DEBUGGER_SCRIPT_SETTING,$(3)).done | |
439 | endif | |
440 | ||
441 | # Prerequisites for using the stageN compiler to build target artifacts | |
442 | TSREQ$(1)_T_$(2)_H_$(3) = \ | |
443 | $$(HSREQ$(1)_H_$(3)) \ | |
92a42be0 | 444 | $$(foreach obj,$$(REQUIRED_OBJECTS_$(2)),\ |
d9579d0f | 445 | $$(TLIB$(1)_T_$(2)_H_$(3))/$$(obj)) |
1a4d82fc JJ |
446 | |
447 | # Prerequisites for a working stageN compiler and libraries, for a specific | |
448 | # target | |
449 | SREQ$(1)_T_$(2)_H_$(3) = \ | |
450 | $$(TSREQ$(1)_T_$(2)_H_$(3)) \ | |
7453a54e | 451 | $$(foreach dep,$$(TARGET_CRATES_$(2)), \ |
1a4d82fc JJ |
452 | $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep)) \ |
453 | tmp/install-debugger-scripts$(1)_T_$(2)_H_$(3)-$$(call TRIPLE_TO_DEBUGGER_SCRIPT_SETTING,$(2)).done | |
454 | ||
455 | # Prerequisites for a working stageN compiler and complete set of target | |
456 | # libraries | |
457 | CSREQ$(1)_T_$(2)_H_$(3) = \ | |
458 | $$(TSREQ$(1)_T_$(2)_H_$(3)) \ | |
459 | $$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \ | |
7453a54e | 460 | $$(foreach dep,$$(HOST_CRATES),$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep)) |
1a4d82fc JJ |
461 | |
462 | ifeq ($(1),0) | |
463 | # Don't run the stage0 compiler under valgrind - that ship has sailed | |
464 | CFG_VALGRIND_COMPILE$(1) = | |
465 | else | |
466 | CFG_VALGRIND_COMPILE$(1) = $$(CFG_VALGRIND_COMPILE) | |
467 | endif | |
468 | ||
469 | # Add RUSTFLAGS_STAGEN values to the build command | |
470 | EXTRAFLAGS_STAGE$(1) = $$(RUSTFLAGS_STAGE$(1)) | |
471 | ||
472 | CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1) | |
473 | ||
474 | endef | |
475 | ||
476 | # Same macro/variables as above, but defined in a separate loop so it can use | |
477 | # all the variables above for all archs. The RPATH_VAR setup sometimes needs to | |
478 | # reach across triples to get things in order. | |
479 | # | |
480 | # Defines (with the standard $(1)_T_$(2)_H_$(3) suffix): | |
481 | # * `LD_LIBRARY_PATH_ENV_NAME`: the name for the key to use in the OS | |
482 | # environment to access or extend the lookup path for dynamic | |
483 | # libraries. Note on Windows, that key is `$PATH`, and thus not | |
484 | # only conflates programs with dynamic libraries, but also often | |
485 | # contains spaces which confuse make. | |
486 | # * `LD_LIBRARY_PATH_ENV_HOSTDIR`: the entry to add to lookup path for the host | |
487 | # * `LD_LIBRARY_PATH_ENV_TARGETDIR`: the entry to add to lookup path for target | |
488 | # | |
489 | # Below that, HOST_RPATH_VAR and TARGET_RPATH_VAR are defined in terms of the | |
490 | # above settings. | |
491 | # | |
492 | define SREQ_CMDS | |
493 | ||
494 | ifeq ($$(OSTYPE_$(3)),apple-darwin) | |
495 | LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := DYLD_LIBRARY_PATH | |
496 | else | |
497 | ifeq ($$(CFG_WINDOWSY_$(3)),1) | |
498 | LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := PATH | |
499 | else | |
500 | LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3) := LD_LIBRARY_PATH | |
501 | endif | |
502 | endif | |
503 | ||
504 | LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3) := \ | |
9cc50fc6 | 505 | $$(CURDIR)/$$(HLIB$(1)_H_$(3)):$$(CFG_LLVM_INST_DIR_$(3))/lib |
1a4d82fc | 506 | LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3) := \ |
54a0048b | 507 | $$(CURDIR)/$$(TLIB$(1)_T_$(2)_H_$(3)) |
1a4d82fc JJ |
508 | |
509 | HOST_RPATH_VAR$(1)_T_$(2)_H_$(3) := \ | |
510 | $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))=$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3)):$$$$$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3)) | |
511 | TARGET_RPATH_VAR$(1)_T_$(2)_H_$(3) := \ | |
512 | $$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3))=$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3)):$$$$$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3)) | |
513 | ||
514 | RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(HOST_RPATH_VAR$(1)_T_$(2)_H_$(3)) | |
515 | ||
516 | # Pass --cfg stage0 only for the build->host part of stage0; | |
517 | # if you're building a cross config, the host->* parts are | |
518 | # effectively stage1, since it uses the just-built stage0. | |
519 | # | |
54a0048b SL |
520 | # Also be sure to use the right rpath because we're loading libraries from the |
521 | # CFG_BUILD's stage1 directory for our target, so switch this one instance of | |
522 | # `RPATH_VAR` to get the bootstrap working. | |
1a4d82fc JJ |
523 | ifeq ($(1),0) |
524 | ifneq ($(strip $(CFG_BUILD)),$(strip $(3))) | |
525 | CFGFLAG$(1)_T_$(2)_H_$(3) = stage1 | |
526 | ||
54a0048b | 527 | RPATH_VAR$(1)_T_$(2)_H_$(3) := $$(TARGET_RPATH_VAR1_T_$(2)_H_$$(CFG_BUILD)) |
1a4d82fc JJ |
528 | endif |
529 | endif | |
530 | ||
531 | STAGE$(1)_T_$(2)_H_$(3) := \ | |
532 | $$(Q)$$(RPATH_VAR$(1)_T_$(2)_H_$(3)) \ | |
533 | $$(call CFG_RUN_TARG_$(3),$(1), \ | |
534 | $$(CFG_VALGRIND_COMPILE$(1)) \ | |
535 | $$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \ | |
536 | --cfg $$(CFGFLAG$(1)_T_$(2)_H_$(3)) \ | |
537 | $$(CFG_RUSTC_FLAGS) $$(EXTRAFLAGS_STAGE$(1)) --target=$(2)) \ | |
538 | $$(RUSTC_FLAGS_$(2)) | |
539 | ||
1a4d82fc JJ |
540 | endef |
541 | ||
542 | $(foreach build,$(CFG_HOST), \ | |
543 | $(eval $(foreach target,$(CFG_TARGET), \ | |
544 | $(eval $(foreach stage,$(STAGES), \ | |
545 | $(eval $(call SREQ,$(stage),$(target),$(build)))))))) | |
546 | ||
547 | $(foreach build,$(CFG_HOST), \ | |
548 | $(eval $(foreach target,$(CFG_TARGET), \ | |
549 | $(eval $(foreach stage,$(STAGES), \ | |
550 | $(eval $(call SREQ_CMDS,$(stage),$(target),$(build)))))))) | |
551 | ||
552 | ###################################################################### | |
553 | # rustc-H-targets | |
554 | # | |
555 | # Builds a functional Rustc for the given host. | |
556 | ###################################################################### | |
557 | ||
558 | define DEF_RUSTC_STAGE_TARGET | |
559 | # $(1) == architecture | |
560 | # $(2) == stage | |
561 | ||
562 | rustc-stage$(2)-H-$(1): \ | |
563 | $$(foreach target,$$(CFG_TARGET),$$(SREQ$(2)_T_$$(target)_H_$(1))) | |
564 | ||
565 | endef | |
566 | ||
567 | $(foreach host,$(CFG_HOST), \ | |
568 | $(eval $(foreach stage,1 2 3, \ | |
569 | $(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage)))))) | |
570 | ||
571 | rustc-stage1: rustc-stage1-H-$(CFG_BUILD) | |
572 | rustc-stage2: rustc-stage2-H-$(CFG_BUILD) | |
573 | rustc-stage3: rustc-stage3-H-$(CFG_BUILD) | |
574 | ||
575 | define DEF_RUSTC_TARGET | |
576 | # $(1) == architecture | |
577 | ||
578 | rustc-H-$(1): rustc-stage2-H-$(1) | |
579 | endef | |
580 | ||
581 | $(foreach host,$(CFG_TARGET), \ | |
582 | $(eval $(call DEF_RUSTC_TARGET,$(host)))) | |
583 | ||
584 | rustc-stage1: rustc-stage1-H-$(CFG_BUILD) | |
585 | rustc-stage2: rustc-stage2-H-$(CFG_BUILD) | |
586 | rustc-stage3: rustc-stage3-H-$(CFG_BUILD) | |
587 | rustc: rustc-H-$(CFG_BUILD) | |
588 | ||
589 | rustc-H-all: $(foreach host,$(CFG_HOST),rustc-H-$(host)) | |
590 | ||
591 | ###################################################################### | |
592 | # Entrypoint rule | |
593 | ###################################################################### | |
594 | ||
595 | .DEFAULT_GOAL := all | |
596 | ||
597 | define ALL_TARGET_N | |
598 | ifneq ($$(findstring $(1),$$(CFG_HOST)),) | |
599 | # This is a host | |
600 | all-target-$(1)-host-$(2): $$(CSREQ2_T_$(1)_H_$(2)) | |
601 | else | |
602 | # This is a target only | |
603 | all-target-$(1)-host-$(2): $$(SREQ2_T_$(1)_H_$(2)) | |
604 | endif | |
605 | endef | |
606 | ||
607 | $(foreach target,$(CFG_TARGET), \ | |
608 | $(foreach host,$(CFG_HOST), \ | |
609 | $(eval $(call ALL_TARGET_N,$(target),$(host))))) | |
610 | ||
611 | ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET), \ | |
612 | $(foreach host,$(CFG_HOST), \ | |
613 | all-target-$(target)-host-$(host))) | |
614 | ||
615 | all: $(ALL_TARGET_RULES) $(GENERATED) docs | |
616 | ||
617 | ###################################################################### | |
618 | # Build system documentation | |
619 | ###################################################################### | |
620 | ||
621 | # $(1) is the name of the doc <section> in Makefile.in | |
622 | # pick everything between tags | remove first line | remove last line | |
623 | # | remove extra (?) line | strip leading `#` from lines | |
624 | SHOW_DOCS = $(Q)awk '/<$(1)>/,/<\/$(1)>/' $(S)/Makefile.in | sed '1d' | sed '$$d' | sed 's/^\# \?//' | |
625 | ||
626 | help: | |
627 | $(call SHOW_DOCS,help) | |
628 | ||
629 | tips: | |
630 | $(call SHOW_DOCS,tips) | |
631 | ||
632 | nitty-gritty: | |
633 | $(call SHOW_DOCS,nitty-gritty) |