@@ -41,14 +41,19 @@ ifneq ($(strip $(findstring snap,$(MAKECMDGOALS))),)
41
41
SNAP_DEFINES=-DRUST_SNAPSHOT
42
42
endif
43
43
44
-
45
44
define DEF_RUNTIME_TARGETS
46
45
47
46
# #####################################################################
48
47
# Runtime (C++) library variables
49
48
# #####################################################################
50
49
51
- RUNTIME_CXXS_$(1 ) := \
50
+ # $(1) is the target triple
51
+ # $(2) is the stage number
52
+
53
+ RUNTIME_CFLAGS_$(1 ) _$(2 ) = -D_RUST_STAGE$(2 )
54
+ RUNTIME_CXXFLAGS_$(1 ) _$(2 ) = -D_RUST_STAGE$(2 )
55
+
56
+ RUNTIME_CXXS_$(1 ) _$(2 ) := \
52
57
rt/sync/timer.cpp \
53
58
rt/sync/lock_and_signal.cpp \
54
59
rt/sync/rust_thread.cpp \
@@ -83,70 +88,70 @@ RUNTIME_CXXS_$(1) := \
83
88
rt/rust_android_dummy.cpp \
84
89
rt/rust_test_helpers.cpp
85
90
86
- RUNTIME_CS_$(1 ) := rt/linenoise/linenoise.c rt/linenoise/utf8.c
91
+ RUNTIME_CS_$(1 ) _ $( 2 ) := rt/linenoise/linenoise.c rt/linenoise/utf8.c
87
92
88
- RUNTIME_S_$(1 ) := rt/arch/$$(HOST_$(1 ) ) /_context.S \
89
- rt/arch/$$(HOST_$(1 ) ) /ccall.S \
90
- rt/arch/$$(HOST_$(1 ) ) /record_sp.S
93
+ RUNTIME_S_$(1 ) _ $( 2 ) := rt/arch/$$(HOST_$(1 ) ) /_context.S \
94
+ rt/arch/$$(HOST_$(1 ) ) /ccall.S \
95
+ rt/arch/$$(HOST_$(1 ) ) /record_sp.S
91
96
92
97
ifeq ($$(CFG_WINDOWSY_$(1 ) ) , 1)
93
- LIBUV_OSTYPE_$(1) := win
94
- LIBUV_LIB_$(1) := rt/$(1 ) /libuv/libuv.a
98
+ LIBUV_OSTYPE_$(1)_$(2) := win
99
+ LIBUV_LIB_$(1)_$(2) := rt/$(1 ) /stage $( 2 ) /libuv/libuv.a
95
100
else ifeq ($(OSTYPE_$(1)), apple-darwin)
96
- LIBUV_OSTYPE_$(1) := mac
97
- LIBUV_LIB_$(1) := rt/$(1 ) /libuv/libuv.a
101
+ LIBUV_OSTYPE_$(1)_$(2) := mac
102
+ LIBUV_LIB_$(1)_$(2) := rt/$(1 ) /stage $( 2 ) /libuv/libuv.a
98
103
else ifeq ($(OSTYPE_$(1)), unknown-freebsd)
99
- LIBUV_OSTYPE_$(1) := unix/freebsd
100
- LIBUV_LIB_$(1) := rt/$(1 ) /libuv/libuv.a
104
+ LIBUV_OSTYPE_$(1)_$(2) := unix/freebsd
105
+ LIBUV_LIB_$(1)_$(2) := rt/$(1 ) /stage $( 2 ) /libuv/libuv.a
101
106
else ifeq ($(OSTYPE_$(1)), linux-androideabi)
102
- LIBUV_OSTYPE_$(1) := unix/android
103
- LIBUV_LIB_$(1) := rt/$(1 ) /libuv/libuv.a
107
+ LIBUV_OSTYPE_$(1)_$(2) := unix/android
108
+ LIBUV_LIB_$(1)_$(2) := rt/$(1 ) /stage $( 2 ) /libuv/libuv.a
104
109
else
105
- LIBUV_OSTYPE_$(1) := unix/linux
106
- LIBUV_LIB_$(1) := rt/$(1 ) /libuv/libuv.a
110
+ LIBUV_OSTYPE_$(1)_$(2) := unix/linux
111
+ LIBUV_LIB_$(1)_$(2) := rt/$(1 ) /stage $( 2 ) /libuv/libuv.a
107
112
endif
108
113
109
- RUNTIME_DEF_$(1 ) := rt/rustrt$(CFG_DEF_SUFFIX_$(1 ) )
110
- RUNTIME_INCS_$(1 ) := -I $$(S ) src/rt -I $$(S ) src/rt/isaac -I $$(S ) src/rt/uthash \
114
+ RUNTIME_DEF_$(1 ) _ $( 2 ) := rt/rustrt$(CFG_DEF_SUFFIX_$(1 ) )
115
+ RUNTIME_INCS_$(1 ) _ $( 2 ) := -I $$(S ) src/rt -I $$(S ) src/rt/isaac -I $$(S ) src/rt/uthash \
111
116
-I $$(S ) src/rt/arch/$$(HOST_$(1 ) ) \
112
117
-I $$(S ) src/rt/linenoise \
113
118
-I $$(S ) src/libuv/include
114
- RUNTIME_OBJS_$(1 ) := $$(RUNTIME_CXXS_$(1 ) :rt/%.cpp=rt/$(1 ) /%.o ) \
115
- $$(RUNTIME_CS_$(1 ) :rt/%.c=rt/$(1 ) /%.o ) \
116
- $$(RUNTIME_S_$(1 ) :rt/%.S=rt/$(1 ) /%.o )
117
- ALL_OBJ_FILES += $$(RUNTIME_OBJS_$(1 ) )
119
+ RUNTIME_OBJS_$(1 ) _ $( 2 ) := $$(RUNTIME_CXXS_$(1 ) _ $( 2 ) :rt/%.cpp=rt/$(1 ) /stage $( 2 ) /%.o ) \
120
+ $$(RUNTIME_CS_$(1 ) _ $( 2 ) :rt/%.c=rt/$(1 ) /stage $( 2 ) /%.o ) \
121
+ $$(RUNTIME_S_$(1 ) _ $( 2 ) :rt/%.S=rt/$(1 ) /stage $( 2 ) /%.o )
122
+ ALL_OBJ_FILES += $$(RUNTIME_OBJS_$(1 ) _ $( 2 ) )
118
123
119
- MORESTACK_OBJ_$(1 ) := rt/$(1 ) /arch/$$(HOST_$(1 ) ) /morestack.o
120
- ALL_OBJ_FILES += $$(MORESTACK_OBJS_$(1 ) )
124
+ MORESTACK_OBJ_$(1 ) _ $( 2 ) := rt/$(1 ) /stage $( 2 ) /arch/$$(HOST_$(1 ) ) /morestack.o
125
+ ALL_OBJ_FILES += $$(MORESTACK_OBJS_$(1 ) _ $( 2 ) )
121
126
122
- RUNTIME_LIBS_$(1 ) := $$(LIBUV_LIB_$(1 ) )
127
+ RUNTIME_LIBS_$(1 ) _ $( 2 ) := $$(LIBUV_LIB_$(1 ) _ $( 2 ) )
123
128
124
- rt/$(1 ) /%.o: rt/%.cpp $$(MKFILE_DEPS )
129
+ rt/$(1 ) /stage $( 2 ) / %.o: rt/%.cpp $$(MKFILE_DEPS )
125
130
@$$(call E, compile: $$@ )
126
- $$(Q )$$(call CFG_COMPILE_CXX_$(1 ) , $$@ , $$(RUNTIME_INCS_$(1 ) ) \
127
- $$(SNAP_DEFINES ) ) $$<
131
+ $$(Q )$$(call CFG_COMPILE_CXX_$(1 ) , $$@ , $$(RUNTIME_INCS_$(1 ) _ $( 2 ) ) \
132
+ $$(SNAP_DEFINES ) $$( RUNTIME_CXXFLAGS_ $( 1 ) _ $( 2 ) ) ) $$<
128
133
129
- rt/$(1 ) /%.o: rt/%.c $$(MKFILE_DEPS )
134
+ rt/$(1 ) /stage $( 2 ) / %.o: rt/%.c $$(MKFILE_DEPS )
130
135
@$$(call E, compile: $$@ )
131
- $$(Q )$$(call CFG_COMPILE_C_$(1 ) , $$@ , $$(RUNTIME_INCS_$(1 ) ) \
132
- $$(SNAP_DEFINES ) ) $$<
136
+ $$(Q )$$(call CFG_COMPILE_C_$(1 ) , $$@ , $$(RUNTIME_INCS_$(1 ) _ $( 2 ) ) \
137
+ $$(SNAP_DEFINES ) $$( RUNTIME_CFLAGS_ $( 1 ) _ $( 2 ) ) ) $$<
133
138
134
- rt/$(1 ) /%.o: rt/%.S $$(MKFILE_DEPS ) \
139
+ rt/$(1 ) /stage $( 2 ) / %.o: rt/%.S $$(MKFILE_DEPS ) \
135
140
$$(LLVM_CONFIG_$$(CFG_BUILD_TRIPLE ) )
136
141
@$$(call E, compile: $$@ )
137
142
$$(Q )$$(call CFG_ASSEMBLE_$(1 ) ,$$@ ,$$< )
138
143
139
- rt/$(1 ) /arch/$$(HOST_$(1 ) ) /libmorestack.a: $$(MORESTACK_OBJ_$(1 ) )
144
+ rt/$(1 ) /stage $( 2 ) / arch/$$(HOST_$(1 ) ) /libmorestack.a: $$(MORESTACK_OBJ_$(1 ) _ $( 2 ) )
140
145
@$$(call E, link: $$@ )
141
146
$$(Q )$(AR_$(1 ) ) rcs $$@ $$<
142
147
143
- rt/$(1 ) /$( CFG_RUNTIME_$(1 ) ) : $$(RUNTIME_OBJS_$(1 ) ) $$(MKFILE_DEPS ) \
144
- $$(RUNTIME_DEF_$(1 ) ) \
145
- $$(RUNTIME_LIBS_$(1 ) )
148
+ rt/$(1 ) /stage $( 2 ) / $( CFG_RUNTIME_$(1 ) ) : $$(RUNTIME_OBJS_$(1 ) _ $( 2 ) ) $$(MKFILE_DEPS ) \
149
+ $$(RUNTIME_DEF_$(1 ) _ $( 2 ) ) \
150
+ $$(RUNTIME_LIBS_$(1 ) _ $( 2 ) )
146
151
@$$(call E, link: $$@ )
147
- $$(Q )$$(call CFG_LINK_CXX_$(1 ) ,$$@ , $$(RUNTIME_OBJS_$(1 ) ) \
148
- $$(CFG_GCCISH_POST_LIB_FLAGS_$(1 ) ) $$(RUNTIME_LIBS_$(1 ) ) \
149
- $$(CFG_LIBUV_LINK_FLAGS_$(1 ) ) ,$$(RUNTIME_DEF_$(1 ) ) ,$$(CFG_RUNTIME_$(1 ) ) )
152
+ $$(Q )$$(call CFG_LINK_CXX_$(1 ) ,$$@ , $$(RUNTIME_OBJS_$(1 ) _ $( 2 ) ) \
153
+ $$(CFG_GCCISH_POST_LIB_FLAGS_$(1 ) ) $$(RUNTIME_LIBS_$(1 ) _ $( 2 ) ) \
154
+ $$(CFG_LIBUV_LINK_FLAGS_$(1 ) ) ,$$(RUNTIME_DEF_$(1 ) _ $( 2 ) ) ,$$(CFG_RUNTIME_$(1 ) ) )
150
155
151
156
# FIXME: For some reason libuv's makefiles can't figure out the
152
157
# correct definition of CC on the mingw I'm using, so we are
@@ -165,32 +170,32 @@ endif
165
170
166
171
# XXX: Shouldn't need platform-specific conditions here
167
172
ifdef CFG_WINDOWSY_$(1)
168
- $$(LIBUV_LIB_$(1 ) ) : $$(LIBUV_DEPS )
173
+ $$(LIBUV_LIB_$(1 ) _ $( 2 ) ) : $$(LIBUV_DEPS )
169
174
$$(Q )$$(MAKE ) -C $$(S ) src/libuv/ \
170
- builddir_name=" $$ (CFG_BUILD_DIR)/rt/$( 1) /libuv" \
175
+ builddir_name=" $$ (CFG_BUILD_DIR)/rt/$( 1) /stage $( 2 ) / libuv" \
171
176
OS=mingw \
172
177
V=$$(VERBOSE )
173
178
else ifeq ($(OSTYPE_$(1)), linux-androideabi)
174
- $$(LIBUV_LIB_$(1 ) ) : $$(LIBUV_DEPS )
179
+ $$(LIBUV_LIB_$(1 ) _ $( 2 ) ) : $$(LIBUV_DEPS )
175
180
$$(Q )$$(MAKE ) -C $$(S ) src/libuv/ \
176
181
CFLAGS=" $$ (CFG_GCCISH_CFLAGS) $$ (LIBUV_FLAGS_$$ (HOST_$( 1) )) $$ (SNAP_DEFINES)" \
177
182
LDFLAGS=" $$ (CFG_GCCISH_LINK_FLAGS) $$ (LIBUV_FLAGS_$$ (HOST_$( 1) ))" \
178
183
CC=" $$ (CC_$( 1) )" \
179
184
CXX=" $$ (CXX_$( 1) )" \
180
185
AR=" $$ (AR_$( 1) )" \
181
186
BUILDTYPE=Release \
182
- builddir_name=" $$ (CFG_BUILD_DIR)/rt/$( 1) /libuv" \
187
+ builddir_name=" $$ (CFG_BUILD_DIR)/rt/$( 1) /stage $( 2 ) / libuv" \
183
188
host=android OS=linux \
184
189
V=$$(VERBOSE )
185
190
else
186
- $$(LIBUV_LIB_$(1 ) ) : $$(LIBUV_DEPS )
191
+ $$(LIBUV_LIB_$(1 ) _ $( 2 ) ) : $$(LIBUV_DEPS )
187
192
$$(Q )$$(MAKE ) -C $$(S ) src/libuv/ \
188
193
CFLAGS=" $$ (CFG_GCCISH_CFLAGS) $$ (LIBUV_FLAGS_$$ (HOST_$( 1) )) $$ (SNAP_DEFINES)" \
189
194
LDFLAGS=" $$ (CFG_GCCISH_LINK_FLAGS) $$ (LIBUV_FLAGS_$$ (HOST_$( 1) ))" \
190
195
CC=" $$ (CC_$( 1) )" \
191
196
CXX=" $$ (CXX_$( 1) )" \
192
197
AR=" $$ (AR_$( 1) )" \
193
- builddir_name=" $$ (CFG_BUILD_DIR)/rt/$( 1) /libuv" \
198
+ builddir_name=" $$ (CFG_BUILD_DIR)/rt/$( 1) /stage $( 2 ) / libuv" \
194
199
V=$$(VERBOSE )
195
200
endif
196
201
@@ -229,5 +234,6 @@ endif
229
234
endef
230
235
231
236
# Instantiate template for all stages
232
- $(foreach target,$(CFG_TARGET_TRIPLES), \
233
- $(eval $(call DEF_RUNTIME_TARGETS,$(target))))
237
+ $(foreach stage,$(STAGES), \
238
+ $(foreach target,$(CFG_TARGET_TRIPLES), \
239
+ $(eval $(call DEF_RUNTIME_TARGETS,$(target),$(stage)))))
0 commit comments