1
- # StageN template: arg 1 is the N we're building *from*, arg 2 is N+1.
1
+ # STAGE_N template: arg 1 is the N we're building *from*, arg 2 is N+1, arg 3
2
+ # is the target triple we're building for. You have to invoke this for each
3
+ # target triple.
2
4
#
3
5
# The easiest way to read this template is to assume we're building stage2
4
6
# using stage1, and mentally gloss $(1) as 1, $(2) as 2.
5
7
#
6
- # LIBGEN is pulled out seperately because we need to specially invoke
8
+ # TARGET_LIBS is pulled out seperately because we need to specially invoke
7
9
# it to build stage0/lib/libstd using stage0/rustc and to use the
8
10
# new rustrt in stage0/lib/.
9
11
10
- define LIBGEN
11
- stage$(2 ) /lib/$$(CFG_STDLIB ) : $$(STDLIB_CRATE ) $$(STDLIB_INPUTS ) \
12
- stage$(2 ) /rustc$$(X ) \
13
- stage$(2 ) /$$(CFG_RUNTIME ) \
14
- stage$(2 ) /$$(CFG_RUSTLLVM ) \
15
- stage$(2 ) /lib/glue.o \
16
- $$(SREQ$(1 ) )
17
- @$$(call E, compile_and_link: $$@ )
18
- $$(STAGE$(2 ) ) --lib -o $$@ $$<
19
-
20
- stage$(2 ) /lib/libstd.rlib: $$(STDLIB_CRATE ) $$(STDLIB_INPUTS ) \
21
- stage$(2 ) /rustc$$(X ) \
22
- stage$(2 ) /$$(CFG_RUNTIME ) \
23
- stage$(2 ) /$$(CFG_RUSTLLVM ) \
24
- stage$(2 ) /lib/glue.o \
25
- $$(SREQ$(1 ) )
26
- @$$(call E, compile_and_link: $$@ )
27
- $$(STAGE$(2 ) ) --lib --static -o $$@ $$<
28
-
29
- stage$(2 ) /lib/$$(CFG_RUNTIME ) : rt/$$(CFG_RUNTIME )
30
- @$$(call E, cp: $$@ )
31
- $$(Q ) cp $$< $$@
32
-
33
- endef
34
-
35
- define STAGEN
12
+ define STAGE_N
36
13
37
14
# Host libraries and executables (stage$(2)/rustc and its runtime needs)
38
15
#
@@ -74,9 +51,14 @@ stage$(2)/$$(CFG_RUSTLLVM): rustllvm/$$(CFG_RUSTLLVM)
74
51
@$$(call E, cp: $$@ )
75
52
$$(Q ) cp $$< $$@
76
53
54
+ # Expand out target libraries
77
55
78
- # Target libraries (for binaries generated by stage$(2)/rustc )
56
+ $( eval $( call TARGET_LIBS, $( 1 ) , $( 2 ) , $( 3 ) ) )
79
57
58
+ endef
59
+
60
+
61
+ define TARGET_LIBS
80
62
stage$(2 ) /lib/intrinsics.bc: $$(INTRINSICS_BC )
81
63
@$$(call E, cp: $$@ )
82
64
$$(Q ) cp $$< $$@
@@ -89,8 +71,6 @@ stage$(2)/lib/glue.o: stage$(2)/rustc$$(X) \
89
71
@$$(call E, generate: $$@ )
90
72
$$(STAGE$(2 ) ) -c -o $$@ --glue
91
73
92
- $(eval $(call LIBGEN,$(1 ) ,$(2 ) ) )
93
-
94
74
stage$(2 ) /lib/main.o: rt/main.o
95
75
@$$(call E, cp: $$@ )
96
76
$$(Q ) cp $$< $$@
@@ -100,10 +80,86 @@ stage$(2)/lib/$$(CFG_LIBRUSTC): $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
100
80
@$$(call E, compile_and_link: $$@ )
101
81
$$(STAGE$(2 ) ) --lib -o $$@ $$<
102
82
83
+ stage$(2 ) /lib/$$(CFG_STDLIB ) : $$(STDLIB_CRATE ) $$(STDLIB_INPUTS ) \
84
+ stage$(2 ) /rustc$$(X ) \
85
+ stage$(2 ) /$$(CFG_RUNTIME ) \
86
+ stage$(2 ) /$$(CFG_RUSTLLVM ) \
87
+ stage$(2 ) /lib/glue.o \
88
+ $$(SREQ$(1 ) )
89
+ @$$(call E, compile_and_link: $$@ )
90
+ $$(STAGE$(2 ) ) --lib -o $$@ $$<
91
+
92
+ stage$(2 ) /lib/libstd.rlib: $$(STDLIB_CRATE ) $$(STDLIB_INPUTS ) \
93
+ stage$(2 ) /rustc$$(X ) \
94
+ stage$(2 ) /$$(CFG_RUNTIME ) \
95
+ stage$(2 ) /$$(CFG_RUSTLLVM ) \
96
+ stage$(2 ) /lib/glue.o \
97
+ $$(SREQ$(1 ) )
98
+ @$$(call E, compile_and_link: $$@ )
99
+ $$(STAGE$(2 ) ) --lib --static -o $$@ $$<
100
+
101
+ stage$(2 ) /lib/$$(CFG_RUNTIME ) : rt/$$(CFG_RUNTIME )
102
+ @$$(call E, cp: $$@ )
103
+ $$(Q ) cp $$< $$@
104
+
105
+
106
+ # New per-target-arch target libraries; when we've transitioned to
107
+ # using these exclusively, you should delete the non-arch-prefixed
108
+ # rules above. They're duplicates, redundant.
109
+
110
+ stage$(2 ) /lib/rustc/$(3 ) /intrinsics.bc: $$(INTRINSICS_BC )
111
+ @$$(call E, cp: $$@ )
112
+ $$(Q ) cp $$< $$@
113
+
114
+ stage$(2 ) /lib/rustc/$(3 ) /glue.o: \
115
+ stage$(2 ) /rustc$$(X ) \
116
+ stage$(2 ) /$$(CFG_RUNTIME ) \
117
+ stage$(2 ) /$$(CFG_RUSTLLVM ) \
118
+ stage$(2 ) /lib/intrinsics.bc \
119
+ $$(SREQ$(1 ) )
120
+ @$$(call E, generate: $$@ )
121
+ $$(STAGE$(2 ) ) -c -o $$@ --glue
122
+
123
+ stage$(2 ) /lib/rustc/$(3 ) /main.o: rt/main.o
124
+ @$$(call E, cp: $$@ )
125
+ $$(Q ) cp $$< $$@
126
+
127
+ stage$(2 ) /lib/rustc/$(3 ) /$$(CFG_LIBRUSTC ) : \
128
+ $$(COMPILER_CRATE ) $$(COMPILER_INPUTS ) \
129
+ $$(SREQ$(2 ) )
130
+ @$$(call E, compile_and_link: $$@ )
131
+ $$(STAGE$(2 ) ) --lib -o $$@ $$<
132
+
133
+ stage$(2 ) /lib/rustc/$(3 ) /$$(CFG_STDLIB ) : \
134
+ $$(STDLIB_CRATE ) $$(STDLIB_INPUTS ) \
135
+ stage$(2 ) /rustc$$(X ) \
136
+ stage$(2 ) /$$(CFG_RUNTIME ) \
137
+ stage$(2 ) /$$(CFG_RUSTLLVM ) \
138
+ stage$(2 ) /lib/rustc/$(3 ) /glue.o \
139
+ $$(SREQ$(1 ) )
140
+ @$$(call E, compile_and_link: $$@ )
141
+ $$(STAGE$(2 ) ) --lib -o $$@ $$<
142
+
143
+ stage$(2 ) /lib/rustc/$(3 ) /libstd.rlib: \
144
+ $$(STDLIB_CRATE ) $$(STDLIB_INPUTS ) \
145
+ stage$(2 ) /rustc$$(X ) \
146
+ stage$(2 ) /$$(CFG_RUNTIME ) \
147
+ stage$(2 ) /$$(CFG_RUSTLLVM ) \
148
+ stage$(2 ) /lib/rustc/$(3 ) /glue.o \
149
+ $$(SREQ$(1 ) )
150
+ @$$(call E, compile_and_link: $$@ )
151
+ $$(STAGE$(2 ) ) --lib --static -o $$@ $$<
152
+
153
+ stage$(2 ) /lib/rustc/$(3 ) /$$(CFG_RUNTIME ) : rt/$$(CFG_RUNTIME )
154
+ @$$(call E, cp: $$@ )
155
+ $$(Q ) cp $$< $$@
156
+
103
157
endef
104
158
105
- # Instantiate template for 0->1, 1->2, 2->3 build dirs
106
159
107
- $(eval $(call STAGEN,0,1))
108
- $(eval $(call STAGEN,1,2))
109
- $(eval $(call STAGEN,2,3))
160
+
161
+ # Instantiate template for 0->1, 1->2, 2->3 build dirs
162
+ $(foreach target,$(CFG_TARGET_TRIPLES), \
163
+ $(eval $(call STAGE_N,0,1,$(target))) \
164
+ $(eval $(call STAGE_N,1,2,$(target))) \
165
+ $(eval $(call STAGE_N,2,3,$(target))))
0 commit comments