Skip to content

Commit 9a71c5c

Browse files
committed
Use gcc -print-file-name for finding C runtime startup objects:
reverted changes in configure, refactored target.mk
1 parent 145b843 commit 9a71c5c

File tree

2 files changed

+27
-29
lines changed

2 files changed

+27
-29
lines changed

configure

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,6 @@ valopt_nosave local-rust-root "/usr/local" "set prefix for local rust binary"
625625
valopt_nosave host "${CFG_BUILD}" "GNUs ./configure syntax LLVM host triples"
626626
valopt_nosave target "${CFG_HOST}" "GNUs ./configure syntax LLVM target triples"
627627
valopt_nosave mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
628-
valopt_nosave libc-dir "/usr/lib" "installation directory of the system libc"
629628

630629
# Temporarily support old triples until buildbots get updated
631630
CFG_BUILD=$(to_llvm_triple $CFG_BUILD)
@@ -1081,9 +1080,6 @@ program_transform_name=$($CFG_CC -v 2>&1 | sed -n "s/.*--program-transform-name=
10811080
CFG_STDCPP_NAME=$(echo "stdc++" | sed "${program_transform_name}")
10821081
putvar CFG_STDCPP_NAME
10831082

1084-
#CFG_LIB_SEARCH_PATH=$($CFG_CC -print-search-dirs | sed -n "/libraries: =/ { s/.*=//; P }")
1085-
#putvar CFG_LIB_SEARCH_PATH
1086-
10871083
# a little post-processing of various config values
10881084
CFG_PREFIX=${CFG_PREFIX%/}
10891085
CFG_MANDIR=${CFG_MANDIR%/}
@@ -1284,16 +1280,6 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
12841280
putvar CFG_DISABLE_JEMALLOC
12851281
;;
12861282

1287-
*-windows-gnu)
1288-
if [ -z "$CFG_LIBC_DIR_PROVIDED" ]; then
1289-
# Use gcc location to find mingw libc directory
1290-
for dir in $(dirname $CFG_GCC)/../*-mingw32/lib; do
1291-
if [ -d "$dir" ]; then
1292-
CFG_LIBC_DIR=$dir
1293-
fi
1294-
done
1295-
fi
1296-
;;
12971283
*)
12981284
;;
12991285
esac
@@ -1752,7 +1738,6 @@ putvar CFG_AARCH64_LINUX_ANDROID_NDK
17521738
putvar CFG_ARM_LINUX_ANDROIDEABI_NDK
17531739
putvar CFG_I686_LINUX_ANDROID_NDK
17541740
putvar CFG_MANDIR
1755-
putvar CFG_LIBC_DIR
17561741

17571742
# Avoid spurious warnings from clang by feeding it original source on
17581743
# ccache-miss rather than preprocessed input.

mk/target.mk

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,19 +146,10 @@ define TARGET_RT_STARTUP
146146
$$(foreach obj,rsbegin rsend, \
147147
$$(eval $$(call TARGET_RUSTRT_STARTUP_OBJ,$(1),$(2),$(3),$$(obj))) )
148148

149+
# Expand build rules for libc startup objects
149150
$$(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))) )
158152

159-
$(1)/$(2) : $$(CFG_LIBC_DIR)/$(2)
160-
@$$(call E, cp: $$@)
161-
@cp $$^ $$@
162153
endef
163154

164155
# Macro for building runtime startup/shutdown object files;
@@ -167,10 +158,10 @@ endef
167158
# $(1) - stage
168159
# $(2) - target triple
169160
# $(3) - host triple
170-
# $(4) - object name
161+
# $(4) - object basename
171162
define TARGET_RUSTRT_STARTUP_OBJ
172163

173-
$$(TLIB$(1)_T_$(2)_H_$(3))/$(4).o:\
164+
$$(TLIB$(1)_T_$(2)_H_$(3))/$(4).o: \
174165
$(S)src/rtstartup/$(4).rs \
175166
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.core \
176167
$$(HSREQ$(1)_T_$(2)_H_$(3)) \
@@ -183,9 +174,31 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(4).o:\
183174
# but before everything else (since they are needed for linking dylib crates).
184175
$$(foreach crate, $$(TARGET_CRATES), \
185176
$$(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+
187179
endef
188180

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+
189202
# Every recipe in RUST_TARGET_STAGE_N outputs to $$(TLIB$(1)_T_$(2)_H_$(3),
190203
# a directory that can be cleaned out during the middle of a run of
191204
# the get-snapshot.py script. Therefore, every recipe needs to have

0 commit comments

Comments
 (0)