Skip to content

Commit

Permalink
Use gcc -print-file-name for finding C runtime startup objects:
Browse files Browse the repository at this point in the history
reverted changes in configure, refactored target.mk
  • Loading branch information
vadimcn committed Oct 21, 2015
1 parent 145b843 commit 9a71c5c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 29 deletions.
15 changes: 0 additions & 15 deletions configure
Expand Up @@ -625,7 +625,6 @@ valopt_nosave local-rust-root "/usr/local" "set prefix for local rust binary"
valopt_nosave host "${CFG_BUILD}" "GNUs ./configure syntax LLVM host triples"
valopt_nosave target "${CFG_HOST}" "GNUs ./configure syntax LLVM target triples"
valopt_nosave mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
valopt_nosave libc-dir "/usr/lib" "installation directory of the system libc"

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

#CFG_LIB_SEARCH_PATH=$($CFG_CC -print-search-dirs | sed -n "/libraries: =/ { s/.*=//; P }")
#putvar CFG_LIB_SEARCH_PATH

# a little post-processing of various config values
CFG_PREFIX=${CFG_PREFIX%/}
CFG_MANDIR=${CFG_MANDIR%/}
Expand Down Expand Up @@ -1284,16 +1280,6 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
putvar CFG_DISABLE_JEMALLOC
;;

*-windows-gnu)
if [ -z "$CFG_LIBC_DIR_PROVIDED" ]; then
# Use gcc location to find mingw libc directory
for dir in $(dirname $CFG_GCC)/../*-mingw32/lib; do
if [ -d "$dir" ]; then
CFG_LIBC_DIR=$dir
fi
done
fi
;;
*)
;;
esac
Expand Down Expand Up @@ -1752,7 +1738,6 @@ putvar CFG_AARCH64_LINUX_ANDROID_NDK
putvar CFG_ARM_LINUX_ANDROIDEABI_NDK
putvar CFG_I686_LINUX_ANDROID_NDK
putvar CFG_MANDIR
putvar CFG_LIBC_DIR

# Avoid spurious warnings from clang by feeding it original source on
# ccache-miss rather than preprocessed input.
Expand Down
41 changes: 27 additions & 14 deletions mk/target.mk
Expand Up @@ -146,19 +146,10 @@ define TARGET_RT_STARTUP
$$(foreach obj,rsbegin rsend, \
$$(eval $$(call TARGET_RUSTRT_STARTUP_OBJ,$(1),$(2),$(3),$$(obj))) )

# Expand build rules for libc startup objects
$$(foreach obj,$$(CFG_LIBC_STARTUP_OBJECTS_$(2)), \
$$(eval $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.core : $$(TLIB$(1)_T_$(2)_H_$(3))/$$(obj)) \
$$(eval $$(call COPY_LIBC_STARTUP,$$(TLIB$(1)_T_$(2)_H_$(3)),$$(obj))) )
endef

# TARGET_RT_STARTUP's helper for copying LibC startup objects
# $(1) - target lib directory
# $(2) - object name
define COPY_LIBC_STARTUP
$$(eval $$(call TARGET_LIBC_STARTUP_OBJ,$(1),$(2),$(3),$$(obj))) )

$(1)/$(2) : $$(CFG_LIBC_DIR)/$(2)
@$$(call E, cp: $$@)
@cp $$^ $$@
endef

# Macro for building runtime startup/shutdown object files;
Expand All @@ -167,10 +158,10 @@ endef
# $(1) - stage
# $(2) - target triple
# $(3) - host triple
# $(4) - object name
# $(4) - object basename
define TARGET_RUSTRT_STARTUP_OBJ

$$(TLIB$(1)_T_$(2)_H_$(3))/$(4).o:\
$$(TLIB$(1)_T_$(2)_H_$(3))/$(4).o: \
$(S)src/rtstartup/$(4).rs \
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.core \
$$(HSREQ$(1)_T_$(2)_H_$(3)) \
Expand All @@ -183,9 +174,31 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(4).o:\
# but before everything else (since they are needed for linking dylib crates).
$$(foreach crate, $$(TARGET_CRATES), \
$$(if $$(findstring core,$$(DEPS_$$(crate))), \
$$(eval $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate) : $$(TLIB$(1)_T_$(2)_H_$(3))/$(4).o) ))
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate))) : $$(TLIB$(1)_T_$(2)_H_$(3))/$(4).o

endef

# Macro for copying libc startup objects into the target's lib directory.
#
# $(1) - stage
# $(2) - target triple
# $(3) - host triple
# $(4) - object name
define TARGET_LIBC_STARTUP_OBJ

# Ask gcc where the startup object is located
$$(TLIB$(1)_T_$(2)_H_$(3))/$(4) : $$(shell $$(CC_$(2)) -print-file-name=$(4))
@$$(call E, cp: $$@)
@cp $$^ $$@

# Make sure this is done before libcore has finished building
# (libcore itself does not depend on these objects, but other crates do,
# so might as well do it here)
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.core : $$(TLIB$(1)_T_$(2)_H_$(3))/$(4)

endef


# Every recipe in RUST_TARGET_STAGE_N outputs to $$(TLIB$(1)_T_$(2)_H_$(3),
# a directory that can be cleaned out during the middle of a run of
# the get-snapshot.py script. Therefore, every recipe needs to have
Expand Down

0 comments on commit 9a71c5c

Please sign in to comment.