mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Parameterize the LLVM build over the target triples
This commit is contained in:
parent
a4e1a438f6
commit
4b6585c924
36
Makefile.in
36
Makefile.in
@ -196,19 +196,31 @@ COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/comp/, \
|
|||||||
# LLVM macros
|
# LLVM macros
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
# Any rules that depend on LLVM should depend on LLVM_CONFIG
|
define DEF_LLVM_VARS
|
||||||
LLVM_CONFIG:=$(CFG_LLVM_INST_DIR)/bin/llvm-config
|
# The configure script defines these variables with the target triples
|
||||||
LLVM_VERSION=$(shell "$(LLVM_CONFIG)" --version)
|
# separated by Z. This defines new ones with the expected format.
|
||||||
LLVM_BINDIR=$(shell "$(LLVM_CONFIG)" --bindir)
|
CFG_LLVM_BUILD_DIR_$(1):=$$(CFG_LLVM_BUILD_DIR_$(subst -,_,$(1)))
|
||||||
LLVM_INCDIR=$(shell "$(LLVM_CONFIG)" --includedir)
|
CFG_LLVM_INST_DIR_$(1):=$$(CFG_LLVM_INST_DIR_$(subst -,_,$(1)))
|
||||||
LLVM_LIBDIR=$(shell "$(LLVM_CONFIG)" --libdir)
|
|
||||||
LLVM_LIBS=$(shell "$(LLVM_CONFIG)" --libs)
|
# Any rules that depend on LLVM should depend on LLVM_CONFIG
|
||||||
LLVM_LDFLAGS=$(shell "$(LLVM_CONFIG)" --ldflags)
|
LLVM_CONFIG_$(1):=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-config
|
||||||
LLVM_CXXFLAGS=$(shell "$(LLVM_CONFIG)" --cxxflags)
|
LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
|
||||||
LLVM_HOST_TRIPLE=$(shell "$(LLVM_CONFIG)" --host-target)
|
LLVM_BINDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --bindir)
|
||||||
|
LLVM_INCDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --includedir)
|
||||||
|
LLVM_LIBDIR_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libdir)
|
||||||
|
LLVM_LIBS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --libs)
|
||||||
|
LLVM_LDFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --ldflags)
|
||||||
|
LLVM_CXXFLAGS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --cxxflags)
|
||||||
|
LLVM_HOST_TRIPLE_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --host-target)
|
||||||
|
|
||||||
|
LLVM_AS_$(1)=$$(LLVM_BINDIR_$(1))/llvm-as$$(X)
|
||||||
|
LLC_$(1)=$$(LLVM_BINDIR_$(1))/llc$$(X)
|
||||||
|
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(foreach target,$(CFG_TARGET_TRIPLES), \
|
||||||
|
$(eval $(call DEF_LLVM_VARS,$(target))))
|
||||||
|
|
||||||
LLVM_AS=$(LLVM_BINDIR)/llvm-as$(X)
|
|
||||||
LLC=$(LLVM_BINDIR)/llc$(X)
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# Exports for sub-utilities
|
# Exports for sub-utilities
|
||||||
|
49
configure
vendored
49
configure
vendored
@ -372,12 +372,17 @@ for i in \
|
|||||||
nd nd/std \
|
nd nd/std \
|
||||||
dl \
|
dl \
|
||||||
test/run-pass test/run-fail test/compile-fail \
|
test/run-pass test/run-fail test/compile-fail \
|
||||||
test/bench test/perf test/pretty \
|
test/bench test/perf test/pretty
|
||||||
llvm
|
|
||||||
do
|
do
|
||||||
make_dir $i
|
make_dir $i
|
||||||
done
|
done
|
||||||
|
|
||||||
|
make_dir llvm
|
||||||
|
for t in $CFG_TARGET_TRIPLES
|
||||||
|
do
|
||||||
|
make_dir llvm/$t
|
||||||
|
done
|
||||||
|
|
||||||
make_dir rustllvm
|
make_dir rustllvm
|
||||||
for t in $CFG_TARGET_TRIPLES
|
for t in $CFG_TARGET_TRIPLES
|
||||||
do
|
do
|
||||||
@ -446,18 +451,23 @@ msg
|
|||||||
|
|
||||||
# Configure llvm. Here we go...
|
# Configure llvm. Here we go...
|
||||||
CFG_LLVM_SRC_DIR=${CFG_SRC_DIR}src/llvm
|
CFG_LLVM_SRC_DIR=${CFG_SRC_DIR}src/llvm
|
||||||
CFG_LLVM_BUILD_DIR=${CFG_BUILD_DIR}/llvm
|
putvar CFG_LLVM_SRC_DIR
|
||||||
# Just use LLVM straight from its build directory to avoid 'make install' time
|
|
||||||
CFG_LLVM_INST_DIR=${CFG_LLVM_BUILD_DIR}/Release+Asserts
|
|
||||||
|
|
||||||
|
for t in $CFG_TARGET_TRIPLES
|
||||||
|
do
|
||||||
if [ -z $CFG_LLVM_ROOT ]
|
if [ -z $CFG_LLVM_ROOT ]
|
||||||
then
|
then
|
||||||
step_msg "configuring LLVM"
|
step_msg "configuring LLVM for $t"
|
||||||
|
|
||||||
|
LLVM_BUILD_DIR=$CFG_BUILD_DIR/llvm/$t
|
||||||
|
# Just use LLVM straight from its build directory to
|
||||||
|
# avoid 'make install' time
|
||||||
|
LLVM_INST_DIR=$LLVM_BUILD_DIR/Release+Asserts
|
||||||
|
|
||||||
LLVM_TARGETS="--enable-targets=x86,x86_64"
|
LLVM_TARGETS="--enable-targets=x86,x86_64"
|
||||||
LLVM_BUILD="--build=${CFG_HOST_TRIPLE}"
|
LLVM_BUILD="--build=$t"
|
||||||
LLVM_HOST="--host=${CFG_HOST_TRIPLE}"
|
LLVM_HOST="--host=$t"
|
||||||
LLVM_TARGET="--target=${CFG_HOST_TRIPLE}"
|
LLVM_TARGET="--target=$t"
|
||||||
LLVM_OPTS="--enable-optimized --disable-docs"
|
LLVM_OPTS="--enable-optimized --disable-docs"
|
||||||
|
|
||||||
LLVM_CXX_32="g++ -m32"
|
LLVM_CXX_32="g++ -m32"
|
||||||
@ -490,18 +500,29 @@ then
|
|||||||
export CXXFLAGS
|
export CXXFLAGS
|
||||||
export LDFLAGS
|
export LDFLAGS
|
||||||
|
|
||||||
cd $CFG_LLVM_BUILD_DIR
|
cd $LLVM_BUILD_DIR
|
||||||
# FIXME: This won't work if CFG_SRC_DIR is absolute
|
# FIXME: This won't work if CFG_SRC_DIR is absolute
|
||||||
${CFG_BUILD_DIR}/${CFG_LLVM_SRC_DIR}/configure $LLVM_FLAGS
|
${CFG_BUILD_DIR}/${CFG_LLVM_SRC_DIR}/configure $LLVM_FLAGS
|
||||||
cd $CFG_BUILD_DIR
|
cd $CFG_BUILD_DIR
|
||||||
else
|
else
|
||||||
|
LLVM_BUILD_DIR=bogus
|
||||||
# The user is using their own LLVM
|
# The user is using their own LLVM
|
||||||
CFG_LLVM_INST_DIR=$CFG_LLVM_ROOT
|
LLVM_INST_DIR=$CFG_LLVM_ROOT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
putvar CFG_LLVM_SRC_DIR
|
# Construct variables for LLVM build and install directories for
|
||||||
putvar CFG_LLVM_BUILD_DIR
|
# each target. These will be named
|
||||||
putvar CFG_LLVM_INST_DIR
|
# CFG_LLVM_BUILD_DIR_${target_triple} but all the hyphens in
|
||||||
|
# target_triple will be converted to underscore, because bash
|
||||||
|
# variables can't contain hyphens. The makefile will then have to
|
||||||
|
# convert back.
|
||||||
|
CFG_LLVM_BUILD_DIR=$(echo CFG_LLVM_BUILD_DIR_${t} | tr - _)
|
||||||
|
CFG_LLVM_INST_DIR=$(echo CFG_LLVM_INST_DIR_${t} | tr - _)
|
||||||
|
eval ${CFG_LLVM_BUILD_DIR}="'$LLVM_BUILD_DIR'"
|
||||||
|
eval ${CFG_LLVM_INST_DIR}="'$LLVM_INST_DIR'"
|
||||||
|
putvar $CFG_LLVM_BUILD_DIR
|
||||||
|
putvar $CFG_LLVM_INST_DIR
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
# Munge any paths that appear in config.mk back to posix-y
|
# Munge any paths that appear in config.mk back to posix-y
|
||||||
|
@ -14,11 +14,11 @@ rt/%.d: rt/%.cpp $(MKFILES)
|
|||||||
$(Q)rm -f $@.tmp.bak
|
$(Q)rm -f $@.tmp.bak
|
||||||
$(Q)mv $@.tmp $@
|
$(Q)mv $@.tmp $@
|
||||||
|
|
||||||
rustllvm/%.d: rustllvm/%.cpp $(MKFILES) $(LLVM_CONFIG)
|
rustllvm/%.d: rustllvm/%.cpp $(MKFILES) $(LLVM_CONFIG_$(CFG_HOST_TRIPLE))
|
||||||
@$(call E, dep: $@)
|
@$(call E, dep: $@)
|
||||||
$(Q)$(call CFG_DEPEND_C, $@ \
|
$(Q)$(call CFG_DEPEND_C, $@ \
|
||||||
$(subst $(S)src/,,$(patsubst %.cpp, %.o, $<)), \
|
$(subst $(S)src/,,$(patsubst %.cpp, %.o, $<)), \
|
||||||
$(LLVM_CXXFLAGS) $(RUSTLLVM_INCS)) $< >$@.tmp
|
$(LLVM_CXXFLAGS_$(CFG_HOST_TRIPLE)) $(RUSTLLVM_INCS)) $< >$@.tmp
|
||||||
$(Q)$(CFG_PATH_MUNGE) $@.tmp
|
$(Q)$(CFG_PATH_MUNGE) $@.tmp
|
||||||
$(Q)rm -f $@.tmp.bak
|
$(Q)rm -f $@.tmp.bak
|
||||||
$(Q)mv $@.tmp $@
|
$(Q)mv $@.tmp $@
|
||||||
|
18
mk/llvm.mk
18
mk/llvm.mk
@ -2,6 +2,18 @@
|
|||||||
LLVM_DEPS:=$(wildcard $(addprefix $(CFG_LLVM_SRC_DIR)/, \
|
LLVM_DEPS:=$(wildcard $(addprefix $(CFG_LLVM_SRC_DIR)/, \
|
||||||
* */*h */*/*h */*/*/*h */*cpp */*/*cpp */*/*/*cpp))
|
* */*h */*/*h */*/*/*h */*cpp */*/*cpp */*/*/*cpp))
|
||||||
|
|
||||||
$(LLVM_CONFIG): $(LLVM_DEPS)
|
define DEF_LLVM_RULES
|
||||||
@$(call E, make: llvm)
|
|
||||||
$(Q)make -C $(CFG_LLVM_BUILD_DIR)
|
# If CFG_LLVM_ROOT is defined then we don't build LLVM ourselves
|
||||||
|
ifeq ($(CFG_LLVM_ROOT),)
|
||||||
|
|
||||||
|
$$(LLVM_CONFIG_$(1)): $$(LLVM_DEPS_$(1))
|
||||||
|
@$$(call E, make: llvm)
|
||||||
|
$$(Q)make -C $$(CFG_LLVM_BUILD_DIR_$(1))
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(foreach target,$(CFG_TARGET_TRIPLES), \
|
||||||
|
$(eval $(call DEF_LLVM_RULES,$(target))))
|
@ -14,7 +14,7 @@ endif
|
|||||||
|
|
||||||
RUSTLLVM_DEF_$(1) := rustllvm/rustllvm$$(CFG_DEF_SUFFIX)
|
RUSTLLVM_DEF_$(1) := rustllvm/rustllvm$$(CFG_DEF_SUFFIX)
|
||||||
|
|
||||||
RUSTLLVM_INCS_$(1) := -iquote $$(LLVM_INCDIR) \
|
RUSTLLVM_INCS_$(1) = -iquote $$(LLVM_INCDIR_$(1)) \
|
||||||
-iquote $$(S)src/rustllvm/include
|
-iquote $$(S)src/rustllvm/include
|
||||||
RUSTLLVM_OBJS_OBJS_$(1) := $$(RUSTLLVM_OBJS_CS_$(1):rustllvm/%.cpp=rustllvm/$(1)/%.o)
|
RUSTLLVM_OBJS_OBJS_$(1) := $$(RUSTLLVM_OBJS_CS_$(1):rustllvm/%.cpp=rustllvm/$(1)/%.o)
|
||||||
|
|
||||||
@ -22,13 +22,13 @@ rustllvm/$(1)/$(CFG_RUSTLLVM): $$(RUSTLLVM_OBJS_OBJS_$(1)) \
|
|||||||
$$(MKFILES) $$(RUSTLLVM_DEF_$(1))
|
$$(MKFILES) $$(RUSTLLVM_DEF_$(1))
|
||||||
@$$(call E, link: $$@)
|
@$$(call E, link: $$@)
|
||||||
$$(Q)$$(call CFG_LINK_C_$(1),$$@,$$(RUSTLLVM_OBJS_OBJS_$(1)) \
|
$$(Q)$$(call CFG_LINK_C_$(1),$$@,$$(RUSTLLVM_OBJS_OBJS_$(1)) \
|
||||||
$$(CFG_GCCISH_PRE_LIB_FLAGS) $$(LLVM_LIBS) \
|
$$(CFG_GCCISH_PRE_LIB_FLAGS) $$(LLVM_LIBS_$(1)) \
|
||||||
$$(CFG_GCCISH_POST_LIB_FLAGS) \
|
$$(CFG_GCCISH_POST_LIB_FLAGS) \
|
||||||
$$(LLVM_LDFLAGS),$$(RUSTLLVM_DEF_$(1)),$$(CFG_RUSTLLVM))
|
$$(LLVM_LDFLAGS_$(1)),$$(RUSTLLVM_DEF_$(1)),$$(CFG_RUSTLLVM))
|
||||||
|
|
||||||
rustllvm/$(1)/%.o: rustllvm/%.cpp $$(MKFILES) $$(LLVM_CONFIG)
|
rustllvm/$(1)/%.o: rustllvm/%.cpp $$(MKFILES) $$(LLVM_CONFIG_$(1))
|
||||||
@$$(call E, compile: $$@)
|
@$$(call E, compile: $$@)
|
||||||
$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, $$(LLVM_CXXFLAGS) $$(RUSTLLVM_INCS_$(1))) $$<
|
$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, $$(LLVM_CXXFLAGS_$(1)) $$(RUSTLLVM_INCS_$(1))) $$<
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# Instantiate template for all stages
|
# Instantiate template for all stages
|
||||||
|
@ -13,9 +13,9 @@ $$(TARGET_LIB$(1)$(2))/intrinsics.ll: \
|
|||||||
$$(Q)sed s/@CFG_TARGET_TRIPLE@/$(2)/ $$< > $$@
|
$$(Q)sed s/@CFG_TARGET_TRIPLE@/$(2)/ $$< > $$@
|
||||||
|
|
||||||
$$(TARGET_LIB$(1)$(2))/intrinsics.bc: $$(TARGET_LIB$(1)$(2))/intrinsics.ll \
|
$$(TARGET_LIB$(1)$(2))/intrinsics.bc: $$(TARGET_LIB$(1)$(2))/intrinsics.ll \
|
||||||
$$(LLVM_CONFIG)
|
$$(LLVM_CONFIG_$(2))
|
||||||
@$$(call E, llvms-as: $$@)
|
@$$(call E, llvms-as: $$@)
|
||||||
$$(Q)$$(LLVM_AS) -o $$@ $$<
|
$$(Q)$$(LLVM_AS_$(2)) -o $$@ $$<
|
||||||
|
|
||||||
$$(TARGET_LIB$(1)$(2))/$$(CFG_STDLIB): \
|
$$(TARGET_LIB$(1)$(2))/$$(CFG_STDLIB): \
|
||||||
$$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
|
$$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
|
||||||
|
Loading…
Reference in New Issue
Block a user