Skip to content

Commit 4648d2b

Browse files
committed
Auto merge of #29681 - vadimcn:fix-dist, r=alexcrichton
Resolves #29672. This happened because rust runtime startup objects, rsbegin.o and rsend.o, were not included in the target libraries package for -windows-gnu. r? @alexcrichton
2 parents bfdc358 + 9f9afe5 commit 4648d2b

8 files changed

+17
-52
lines changed

mk/cfg/i686-pc-windows-gnu.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ CFG_LDPATH_i686-pc-windows-gnu :=
2222
CFG_RUN_i686-pc-windows-gnu=$(2)
2323
CFG_RUN_TARG_i686-pc-windows-gnu=$(call CFG_RUN_i686-pc-windows-gnu,,$(2))
2424
CFG_GNU_TRIPLE_i686-pc-windows-gnu := i686-w64-mingw32
25-
CFG_LIBC_STARTUP_OBJECTS_i686-pc-windows-gnu := crt2.o dllcrt2.o
25+
CFG_THIRD_PARTY_OBJECTS_i686-pc-windows-gnu := crt2.o dllcrt2.o
26+
CFG_INSTALLED_OBJECTS_i686-pc-windows-gnu := crt2.o dllcrt2.o rsbegin.o rsend.o

mk/cfg/x86_64-pc-windows-gnu.mk

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ CFG_LDPATH_x86_64-pc-windows-gnu :=
2222
CFG_RUN_x86_64-pc-windows-gnu=$(2)
2323
CFG_RUN_TARG_x86_64-pc-windows-gnu=$(call CFG_RUN_x86_64-pc-windows-gnu,,$(2))
2424
CFG_GNU_TRIPLE_x86_64-pc-windows-gnu := x86_64-w64-mingw32
25-
CFG_LIBC_STARTUP_OBJECTS_x86_64-pc-windows-gnu := crt2.o dllcrt2.o
25+
CFG_THIRD_PARTY_OBJECTS_x86_64-pc-windows-gnu := crt2.o dllcrt2.o
26+
CFG_INSTALLED_OBJECTS_x86_64-pc-windows-gnu := crt2.o dllcrt2.o rsbegin.o rsend.o

mk/cfg/x86_64-unknown-linux-musl.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ CFG_LDPATH_x86_64-unknown-linux-musl :=
2121
CFG_RUN_x86_64-unknown-linux-musl=$(2)
2222
CFG_RUN_TARG_x86_64-unknown-linux-musl=$(call CFG_RUN_x86_64-unknown-linux-musl,,$(2))
2323
CFG_GNU_TRIPLE_x86_64-unknown-linux-musl := x86_64-unknown-linux-musl
24+
CFG_THIRD_PARTY_OBJECTS_x86_64-unknown-linux-musl := crt1.o crti.o crtn.o
25+
CFG_INSTALLED_OBJECTS_x86_64-unknown-linux-musl := crt1.o crti.o crtn.o
2426

2527
NATIVE_DEPS_libc_T_x86_64-unknown-linux-musl += libc.a
26-
NATIVE_DEPS_std_T_x86_64-unknown-linux-musl += libunwind.a \
27-
crt1.o crti.o crtn.o
28-
INSTALLED_OBJECTS_x86_64-unknown-linux-musl += crt1.o crti.o crtn.o
28+
NATIVE_DEPS_std_T_x86_64-unknown-linux-musl += libunwind.a crt1.o crti.o crtn.o

mk/main.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ endif
415415
# Prerequisites for using the stageN compiler to build target artifacts
416416
TSREQ$(1)_T_$(2)_H_$(3) = \
417417
$$(HSREQ$(1)_H_$(3)) \
418-
$$(foreach obj,$$(INSTALLED_OBJECTS_$(2)),\
418+
$$(foreach obj,$$(REQUIRED_OBJECTS_$(2)),\
419419
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(obj))
420420

421421
# Prerequisites for a working stageN compiler and libraries, for a specific

mk/platform.mk

+3
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ CFG_RLIB_GLOB=lib$(1)-*.rlib
113113
include $(wildcard $(CFG_SRC_DIR)mk/cfg/*.mk)
114114

115115
define ADD_INSTALLED_OBJECTS
116+
INSTALLED_OBJECTS_$(1) += $$(CFG_INSTALLED_OBJECTS_$(1))
117+
REQUIRED_OBJECTS_$(1) += $$(CFG_THIRD_PARTY_OBJECTS_$(1))
116118
INSTALLED_OBJECTS_$(1) += $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
119+
REQUIRED_OBJECTS_$(1) += $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
117120
endef
118121

119122
$(foreach target,$(CFG_TARGET), \

mk/rt.mk

+4
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ endif # endif for darwin
352352
ifeq ($$(findstring musl,$(1)),musl)
353353
$$(RT_OUTPUT_DIR_$(1))/%: $$(CFG_MUSL_ROOT)/lib/%
354354
cp $$^ $$@
355+
else
356+
# Ask gcc where it is
357+
$$(RT_OUTPUT_DIR_$(1))/%:
358+
cp $$(shell $$(CC_$(1)) -print-file-name=$$(@F)) $$@
355359
endif
356360

357361
endef

mk/target.mk

+2-42
Original file line numberDiff line numberDiff line change
@@ -132,26 +132,6 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \
132132

133133
endef
134134

135-
# Macro for building runtime startup objects
136-
# Of those we have two kinds:
137-
# - Rust runtime-specific: these are Rust's equivalents of GCC's crti.o/crtn.o,
138-
# - LibC-specific: these we don't build ourselves, but copy them from the system lib directory.
139-
#
140-
# $(1) - stage
141-
# $(2) - target triple
142-
# $(3) - host triple
143-
define TARGET_RT_STARTUP
144-
145-
# Expand build rules for rsbegin.o and rsend.o
146-
$$(foreach obj,rsbegin rsend, \
147-
$$(eval $$(call TARGET_RUSTRT_STARTUP_OBJ,$(1),$(2),$(3),$$(obj))) )
148-
149-
# Expand build rules for libc startup objects
150-
$$(foreach obj,$$(CFG_LIBC_STARTUP_OBJECTS_$(2)), \
151-
$$(eval $$(call TARGET_LIBC_STARTUP_OBJ,$(1),$(2),$(3),$$(obj))) )
152-
153-
endef
154-
155135
# Macro for building runtime startup/shutdown object files;
156136
# these are Rust's equivalent of crti.o, crtn.o
157137
#
@@ -178,27 +158,6 @@ $$(foreach crate, $$(TARGET_CRATES), \
178158

179159
endef
180160

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-
202161
# Every recipe in RUST_TARGET_STAGE_N outputs to $$(TLIB$(1)_T_$(2)_H_$(3),
203162
# a directory that can be cleaned out during the middle of a run of
204163
# the get-snapshot.py script. Therefore, every recipe needs to have
@@ -245,4 +204,5 @@ $(foreach host,$(CFG_HOST), \
245204
$(foreach host,$(CFG_HOST), \
246205
$(foreach target,$(CFG_TARGET), \
247206
$(foreach stage,$(STAGES), \
248-
$(eval $(call TARGET_RT_STARTUP,$(stage),$(target),$(host))))))
207+
$(foreach obj,rsbegin rsend, \
208+
$(eval $(call TARGET_RUSTRT_STARTUP_OBJ,$(stage),$(target),$(host),$(obj)))))))

src/etc/make-win-dist.py

-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ def make_win_dist(rust_root, plat_root, target_triple):
5858
rustc_dlls.append("libgcc_s_seh-1.dll")
5959

6060
target_libs = [ # MinGW libs
61-
"crtbegin.o",
62-
"crtend.o",
63-
"crt2.o",
64-
"dllcrt2.o",
6561
"libgcc.a",
6662
"libgcc_eh.a",
6763
"libgcc_s.a",

0 commit comments

Comments
 (0)