@@ -146,19 +146,10 @@ define TARGET_RT_STARTUP
146
146
$$(foreach obj,rsbegin rsend, \
147
147
$$(eval $$(call TARGET_RUSTRT_STARTUP_OBJ,$(1 ) ,$(2 ) ,$(3 ) ,$$(obj ) ) ) )
148
148
149
+ # Expand build rules for libc startup objects
149
150
$$(foreach obj,$$(CFG_LIBC_STARTUP_OBJECTS_$(2 ) ) , \
150
- $$(eval $$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /stamp.core : $$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /$$(obj ) ) \
151
- $$(eval $$(call COPY_LIBC_STARTUP,$$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) ,$$(obj ) ) ) )
152
- endef
153
-
154
- # TARGET_RT_STARTUP's helper for copying LibC startup objects
155
- # $(1) - target lib directory
156
- # $(2) - object name
157
- define COPY_LIBC_STARTUP
151
+ $$(eval $$(call TARGET_LIBC_STARTUP_OBJ,$(1 ) ,$(2 ) ,$(3 ) ,$$(obj ) ) ) )
158
152
159
- $(1 ) /$(2 ) : $$(CFG_LIBC_DIR ) /$(2 )
160
- @$$(call E, cp: $$@ )
161
- @cp $$^ $$@
162
153
endef
163
154
164
155
# Macro for building runtime startup/shutdown object files;
@@ -167,10 +158,10 @@ endef
167
158
# $(1) - stage
168
159
# $(2) - target triple
169
160
# $(3) - host triple
170
- # $(4) - object name
161
+ # $(4) - object basename
171
162
define TARGET_RUSTRT_STARTUP_OBJ
172
163
173
- $$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /$(4 ) .o:\
164
+ $$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /$(4 ) .o: \
174
165
$(S ) src/rtstartup/$(4 ) .rs \
175
166
$$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /stamp.core \
176
167
$$(HSREQ$(1 ) _T_$(2 ) _H_$(3 ) ) \
@@ -183,9 +174,31 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(4).o:\
183
174
# but before everything else (since they are needed for linking dylib crates).
184
175
$$(foreach crate, $$(TARGET_CRATES ) , \
185
176
$$(if $$(findstring core,$$(DEPS_$$(crate ) ) ) , \
186
- $$(eval $$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /stamp.$$(crate ) : $$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /$(4 ) .o) ) )
177
+ $$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /stamp.$$(crate ) ) ) : $$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /$(4 ) .o
178
+
187
179
endef
188
180
181
+ # Macro for copying libc startup objects into the target's lib directory.
182
+ #
183
+ # $(1) - stage
184
+ # $(2) - target triple
185
+ # $(3) - host triple
186
+ # $(4) - object name
187
+ define TARGET_LIBC_STARTUP_OBJ
188
+
189
+ # Ask gcc where the startup object is located
190
+ $$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /$(4 ) : $$(shell $$(CC_$(2 ) ) -print-file-name=$(4 ) )
191
+ @$$(call E, cp: $$@ )
192
+ @cp $$^ $$@
193
+
194
+ # Make sure this is done before libcore has finished building
195
+ # (libcore itself does not depend on these objects, but other crates do,
196
+ # so might as well do it here)
197
+ $$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /stamp.core : $$(TLIB$(1 ) _T_$(2 ) _H_$(3 ) ) /$(4 )
198
+
199
+ endef
200
+
201
+
189
202
# Every recipe in RUST_TARGET_STAGE_N outputs to $$(TLIB$(1)_T_$(2)_H_$(3),
190
203
# a directory that can be cleaned out during the middle of a run of
191
204
# the get-snapshot.py script. Therefore, every recipe needs to have
0 commit comments