1
+ # An explanation of how the build is structured:
2
+ #
3
+ # There are multiple build stages (0-3) needed to verify that the
4
+ # compiler is properly self-hosting. Each stage is divided between
5
+ # 'host' artifacts and 'target' artifacts, where the stageN host
6
+ # compiler builds artifacts for 1 or more stageN target architectures.
7
+ # Once the stageN target compiler has been built for the host
8
+ # architecture it is promoted (copied) to a stageN+1 host artifact.
9
+ #
10
+ # The stage3 host compiler is a compiler that successfully builds
11
+ # itself and should (in theory) be bitwise identical to the stage2
12
+ # host compiler. The process is bootstrapped using a stage0 host
13
+ # compiler downloaded from a previous snapshot.
14
+ #
15
+ # At no time should stageN artifacts be interacting with artifacts
16
+ # from other stages. For consistency, we use the 'promotion' logic
17
+ # for all artifacts, even those that don't make sense on non-host
18
+ # architectures.
19
+ #
20
+ # The directory layout for a stage is intended to match the layout
21
+ # of the installed compiler, and looks like the following:
22
+ #
23
+ # stageN - this is the system root, corresponding to, e.g. /usr
24
+ # bin - binaries compiled for the host
25
+ # lib - libraries used by the host compiler
26
+ # rustc - rustc's own place to organize libraries
27
+ # $(target) - target-specific artifacts
28
+ # bin - binaries for target architectures
29
+ # lib - libraries for target architectures
30
+ #
31
+ # A note about host libraries:
32
+ #
33
+ # The only libraries that get promoted to stageN/lib are those needed
34
+ # by rustc. In general, rustc programs, even those compiled for the
35
+ # host architecture will use libraries from the target
36
+ # directories. This gives rust some freedom to experiment with how
37
+ # libraries are managed and versioned without polluting the common
38
+ # areas of the filesystem.
39
+ #
40
+ # General rust binaries may stil live in the host bin directory; they
41
+ # will just link against the libraries in the target lib directory.
42
+ #
43
+ # Admittedly this is a little convoluted.
44
+
1
45
# #####################################################################
2
46
# Residual auto-configuration
3
47
# #####################################################################
@@ -142,12 +186,16 @@ COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/comp/, \
142
186
# Exports for sub-utilities
143
187
# #####################################################################
144
188
189
+ # Note that any variable that re-configure should pick up needs to be
190
+ # exported
191
+
145
192
export CFG_SRC_DIR
146
193
export CFG_BUILD_DIR
147
194
export CFG_VERSION
148
195
export CFG_HOST_TRIPLE
149
196
export CFG_LLVM_ROOT
150
197
export CFG_ENABLE_MINGW_CROSS
198
+ export CFG_PREFIX
151
199
152
200
# #####################################################################
153
201
# Subprograms
@@ -179,33 +227,34 @@ TARGET_HOST_ROOT$(1) = $$(TARGET_ROOT$(1)$$(CFG_HOST_TRIPLE))
179
227
TARGET_HOST_BIN$(1 ) = $$(TARGET_BIN$(1 )$$(CFG_HOST_TRIPLE ) )
180
228
TARGET_HOST_LIB$(1 ) = $$(TARGET_LIB$(1 )$$(CFG_HOST_TRIPLE ) )
181
229
230
+ # The name of the standard library used by rustc
182
231
ifdef CFG_DISABLE_SHAREDSTD
183
232
HOST_STDLIB_DEFAULT$(1) = $$(HOST_LIB$(1 ) ) /libstd.rlib
233
+ TARGET_STDLIB_DEFAULT$(1)$(2) = $$(TARGET_LIB$(1 )$(2 ) ) /libstd.rlib
184
234
else
185
235
HOST_STDLIB_DEFAULT$(1) = $$(HOST_LIB$(1 ) ) /$(CFG_STDLIB )
236
+ TARGET_STDLIB_DEFAULT$(1)$(2) = $$(TARGET_LIB$(1 )$(2 ) ) /$(CFG_STDLIB )
186
237
endif
187
238
188
- ifdef CFG_DISABLE_SHAREDSTD
189
- SREQ$(1)$(2) = $$(HOST_BIN$(1 ) ) /rustc$(X ) \
190
- $$(HOST_LIB$(1 ) ) /$$(CFG_RUNTIME ) \
191
- $$(HOST_STDLIB_DEFAULT$(1 ) ) \
192
- $$(HOST_LIB$(1 ) ) /$$(CFG_RUSTLLVM ) \
193
- $$(TARGET_LIB$(1 )$(2 ) ) /$$(CFG_RUNTIME ) \
194
- $$(TARGET_LIB$(1 )$(2 ) ) /$$(CFG_STDLIB ) \
195
- $$(TARGET_LIB$(1 )$(2 ) ) /intrinsics.bc \
196
- $$(TARGET_LIB$(1 )$(2 ) ) /main.o \
197
- $$(MKFILES )
198
- else
199
- SREQ$(1)$(2) = $$(HOST_BIN$(1 ) ) /rustc$(X ) \
200
- $$(HOST_LIB$(1 ) ) /$$(CFG_RUNTIME ) \
201
- $$(HOST_STDLIB_DEFAULT$(1 ) ) \
202
- $$(HOST_LIB$(1 ) ) /$$(CFG_RUSTLLVM ) \
203
- $$(TARGET_LIB$(1 )$(2 ) ) /$$(CFG_RUNTIME ) \
204
- $$(TARGET_LIB$(1 )$(2 ) ) /$$(CFG_STDLIB ) \
205
- $$(TARGET_LIB$(1 )$(2 ) ) /intrinsics.bc \
206
- $$(TARGET_LIB$(1 )$(2 ) ) /main.o \
207
- $$(MKFILES )
208
- endif
239
+ # Preqrequisites for using the stageN compiler
240
+ HOST_SREQ$(1 ) = \
241
+ $$(HOST_BIN$(1 ) ) /rustc$$(X ) \
242
+ $$(HOST_LIB$(1 ) ) /$$(CFG_RUNTIME ) \
243
+ $$(HOST_LIB$(1 ) ) /$$(CFG_RUSTLLVM ) \
244
+ $$(HOST_STDLIB_DEFAULT$(1 ) ) \
245
+ $$(MKFILES )
246
+
247
+ # Prerequisites for using the stageN compiler to build target artifacts
248
+ TARGET_SREQ$(1 )$(2 ) = \
249
+ $$(HOST_SREQ$(1 ) ) \
250
+ $$(TARGET_LIB$(1 )$(2 ) ) /$$(CFG_RUNTIME ) \
251
+ $$(TARGET_LIB$(1 )$(2 ) ) /intrinsics.bc \
252
+ $$(TARGET_LIB$(1 )$(2 ) ) /main.o
253
+
254
+ # Prerequisites for complete stageN targets
255
+ SREQ$(1 )$(2 ) = \
256
+ $$(TARGET_SREQ$(1 )$(2 ) ) \
257
+ $$(TARGET_LIB$(1 )$(2 ) ) /$$(CFG_STDLIB )
209
258
210
259
ifeq ($(1 ) ,0)
211
260
# Don't run the the stage0 compiler under valgrind - that ship has sailed
@@ -241,16 +290,14 @@ CFG_INFO := $(info cfg: *** compiler is in snapshot transition ***)
241
290
CFG_INFO := $(info cfg: *** stage2 and later will not be built *** )
242
291
CFG_INFO := $(info cfg:)
243
292
244
- FUZZ := $(HOST_BIN1 ) /fuzzer $( X )
293
+ all : $(SREQ1 $( CFG_HOST_TRIPLE ) ) $( GENERATED ) $( DOCS )
245
294
246
- all : $(SREQ0$(CFG_HOST_TRIPLE ) ) $(SREQ1$(CFG_HOST_TRIPLE ) ) \
247
- $(GENERATED) $(DOCS) $(FUZZ)
248
295
else
249
296
250
- ALL_SREQS = $(foreach target,$(CFG_TARGET_TRIPLES ) , \
251
- $(SREQ0$(target ) ) $(SREQ1$(target ) ) $(SREQ2$(target ) ) $(SREQ3$(target ) ) )
297
+ FUZZ := $(HOST_BIN3 ) /fuzzer$(X )
298
+
299
+ all : $(SREQ3$(CFG_HOST_TRIPLE ) ) $(GENERATED ) $(DOCS ) $(FUZZ )
252
300
253
- all : $(ALL_SREQS ) $(GENERATED ) $(DOCS ) $(FUZZ )
254
301
endif
255
302
256
303
@@ -268,7 +315,8 @@ config.mk: $(S)configure $(S)Makefile.in $(S)src/snapshots.txt
268
315
# #####################################################################
269
316
270
317
include $(CFG_SRC_DIR ) /mk/intrinsics.mk
271
- include $(CFG_SRC_DIR ) /mk/stageN.mk
318
+ include $(CFG_SRC_DIR ) /mk/target.mk
319
+ include $(CFG_SRC_DIR ) /mk/host.mk
272
320
include $(CFG_SRC_DIR ) /mk/stage0.mk
273
321
include $(CFG_SRC_DIR ) /mk/rt.mk
274
322
include $(CFG_SRC_DIR ) /mk/rustllvm.mk
0 commit comments