2012-12-11 02:32:48 +01:00
|
|
|
# Copyright 2012 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
# file at the top-level directory of this distribution and at
|
|
|
|
# http://rust-lang.org/COPYRIGHT.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
# option. This file may not be copied, modified, or distributed
|
|
|
|
# except according to those terms.
|
|
|
|
|
2012-02-10 21:07:01 +01:00
|
|
|
|
|
|
|
ifdef CFG_ENABLE_FAST_MAKE
|
|
|
|
LLVM_DEPS := $(S)/.gitmodules
|
|
|
|
else
|
2011-11-26 04:25:09 +01:00
|
|
|
|
2011-11-02 01:09:44 +01:00
|
|
|
# This is just a rough approximation of LLVM deps
|
2013-11-30 02:09:10 +01:00
|
|
|
LLVM_DEPS_SRC=$(call rwildcard,$(CFG_LLVM_SRC_DIR)lib,*cpp *hpp)
|
|
|
|
LLVM_DEPS_INC=$(call rwildcard,$(CFG_LLVM_SRC_DIR)include,*cpp *hpp)
|
2013-05-22 01:34:41 +02:00
|
|
|
LLVM_DEPS=$(LLVM_DEPS_SRC) $(LLVM_DEPS_INC)
|
2012-02-10 21:07:01 +01:00
|
|
|
endif
|
2011-11-01 23:48:30 +01:00
|
|
|
|
2015-05-11 23:03:45 +02:00
|
|
|
ifdef CFG_DISABLE_OPTIMIZE_LLVM
|
|
|
|
LLVM_BUILD_CONFIG_MODE := Debug
|
|
|
|
else
|
|
|
|
LLVM_BUILD_CONFIG_MODE := Release
|
|
|
|
endif
|
|
|
|
|
2011-11-03 00:21:17 +01:00
|
|
|
define DEF_LLVM_RULES
|
|
|
|
|
2016-06-28 03:59:55 +02:00
|
|
|
ifeq ($(1),$$(CFG_BUILD))
|
|
|
|
LLVM_DEPS_TARGET_$(1) := $$(LLVM_DEPS)
|
|
|
|
else
|
|
|
|
LLVM_DEPS_TARGET_$(1) := $$(LLVM_DEPS) $$(LLVM_CONFIG_$$(CFG_BUILD))
|
|
|
|
endif
|
|
|
|
|
2011-11-03 00:21:17 +01:00
|
|
|
# If CFG_LLVM_ROOT is defined then we don't build LLVM ourselves
|
|
|
|
ifeq ($(CFG_LLVM_ROOT),)
|
|
|
|
|
2013-09-04 08:47:13 +02:00
|
|
|
LLVM_STAMP_$(1) = $$(CFG_LLVM_BUILD_DIR_$(1))/llvm-auto-clean-stamp
|
2016-06-29 22:45:18 +02:00
|
|
|
LLVM_DONE_$(1) = $$(CFG_LLVM_BUILD_DIR_$(1))/llvm-finished-building
|
2013-09-04 08:47:13 +02:00
|
|
|
|
2016-06-29 22:45:18 +02:00
|
|
|
$$(LLVM_CONFIG_$(1)): $$(LLVM_DONE_$(1))
|
|
|
|
|
|
|
|
$$(LLVM_DONE_$(1)): $$(LLVM_DEPS_TARGET_$(1)) $$(LLVM_STAMP_$(1))
|
2015-05-11 23:03:45 +02:00
|
|
|
@$$(call E, cmake: llvm)
|
2016-07-02 01:47:30 +02:00
|
|
|
ifneq ($$(CFG_NINJA),)
|
|
|
|
$$(Q)$$(CFG_NINJA) -C $$(CFG_LLVM_BUILD_DIR_$(1))
|
|
|
|
else ifeq ($$(findstring msvc,$(1)),msvc)
|
2015-05-11 23:03:45 +02:00
|
|
|
$$(Q)$$(CFG_CMAKE) --build $$(CFG_LLVM_BUILD_DIR_$(1)) \
|
|
|
|
--config $$(LLVM_BUILD_CONFIG_MODE)
|
|
|
|
else
|
2016-06-02 02:41:27 +02:00
|
|
|
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1))
|
|
|
|
endif
|
2016-06-29 22:45:18 +02:00
|
|
|
$$(Q)touch $$@
|
2015-05-11 23:03:45 +02:00
|
|
|
|
2016-07-02 01:47:30 +02:00
|
|
|
ifneq ($$(CFG_NINJA),)
|
|
|
|
clean-llvm$(1):
|
|
|
|
@$$(call E, clean: llvm)
|
|
|
|
$$(Q)$$(CFG_NINJA) -C $$(CFG_LLVM_BUILD_DIR_$(1)) -t clean
|
|
|
|
else ifeq ($$(findstring msvc,$(1)),msvc)
|
2015-05-11 23:03:45 +02:00
|
|
|
clean-llvm$(1):
|
2016-07-02 02:19:23 +02:00
|
|
|
@$$(call E, clean: llvm)
|
|
|
|
$$(Q)$$(CFG_CMAKE) --build $$(CFG_LLVM_BUILD_DIR_$(1)) \
|
|
|
|
--config $$(LLVM_BUILD_CONFIG_MODE) \
|
|
|
|
--target clean
|
2016-06-28 03:59:55 +02:00
|
|
|
else
|
|
|
|
clean-llvm$(1):
|
|
|
|
@$$(call E, clean: llvm)
|
|
|
|
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1)) clean
|
|
|
|
endif
|
2015-05-11 23:03:45 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
clean-llvm$(1):
|
2011-11-03 00:21:17 +01:00
|
|
|
endif
|
|
|
|
|
2015-05-11 23:14:11 +02:00
|
|
|
$$(LLVM_AR_$(1)): $$(LLVM_CONFIG_$(1))
|
|
|
|
|
2013-09-04 08:47:13 +02:00
|
|
|
# This is used to independently force an LLVM clean rebuild
|
|
|
|
# when we changed something not otherwise captured by builtin
|
|
|
|
# dependencies. In these cases, commit a change that touches
|
|
|
|
# the stamp in the source dir.
|
2015-11-13 20:54:25 +01:00
|
|
|
$$(LLVM_STAMP_$(1)): $$(S)src/rustllvm/llvm-auto-clean-trigger
|
2013-11-28 23:16:17 +01:00
|
|
|
@$$(call E, make: cleaning llvm)
|
2015-11-13 20:54:25 +01:00
|
|
|
$$(Q)touch $$@.start_time
|
|
|
|
$$(Q)$$(MAKE) clean-llvm$(1)
|
2013-11-28 23:16:17 +01:00
|
|
|
@$$(call E, make: done cleaning llvm)
|
2015-03-03 15:11:01 +01:00
|
|
|
touch -r $$@.start_time $$@ && rm $$@.start_time
|
2013-09-04 08:47:13 +02:00
|
|
|
|
2016-02-02 08:27:04 +01:00
|
|
|
ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP),1)
|
2015-03-12 12:09:12 +01:00
|
|
|
LLVM_STDCPP_RUSTFLAGS_$(1) = -L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
|
2015-09-18 16:30:45 +02:00
|
|
|
-print-file-name=lib$(CFG_STDCPP_NAME).a))"
|
2014-04-16 19:45:04 +02:00
|
|
|
else
|
2015-03-12 12:09:12 +01:00
|
|
|
LLVM_STDCPP_RUSTFLAGS_$(1) =
|
2014-04-16 19:45:04 +02:00
|
|
|
endif
|
|
|
|
|
2014-11-26 00:28:49 +01:00
|
|
|
|
|
|
|
# LLVM linkage:
|
2015-08-22 06:43:56 +02:00
|
|
|
# Note: Filter with llvm-config so that optional targets which aren't present
|
|
|
|
# don't cause errors (ie PNaCl's target is only present within PNaCl's LLVM
|
|
|
|
# fork).
|
2014-11-26 00:28:49 +01:00
|
|
|
LLVM_LINKAGE_PATH_$(1):=$$(abspath $$(RT_OUTPUT_DIR_$(1))/llvmdeps.rs)
|
|
|
|
$$(LLVM_LINKAGE_PATH_$(1)): $(S)src/etc/mklldeps.py $$(LLVM_CONFIG_$(1))
|
2015-08-22 06:43:56 +02:00
|
|
|
$(Q)$(CFG_PYTHON) "$$<" "$$@" "$$(filter $$(shell \
|
|
|
|
$$(LLVM_CONFIG_$(1)) --components), \
|
|
|
|
$(LLVM_OPTIONAL_COMPONENTS)) $(LLVM_REQUIRED_COMPONENTS)" \
|
|
|
|
"$$(CFG_ENABLE_LLVM_STATIC_STDCPP)" $$(LLVM_CONFIG_$(1)) \
|
|
|
|
"$(CFG_STDCPP_NAME)" "$$(CFG_USING_LIBCPP)"
|
2011-11-03 00:21:17 +01:00
|
|
|
endef
|
|
|
|
|
2013-12-01 05:52:21 +01:00
|
|
|
$(foreach host,$(CFG_HOST), \
|
2014-04-16 19:45:04 +02:00
|
|
|
$(eval $(call DEF_LLVM_RULES,$(host))))
|
2013-12-01 05:52:21 +01:00
|
|
|
|
2016-02-02 08:27:04 +01:00
|
|
|
$(foreach host,$(CFG_HOST), \
|
|
|
|
$(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_$(host))))
|
|
|
|
|
2014-11-26 00:28:49 +01:00
|
|
|
# This can't be done in target.mk because it's included before this file.
|
|
|
|
define LLVM_LINKAGE_DEPS
|
2015-12-16 17:06:27 +01:00
|
|
|
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.rustc_llvm: $$(LLVM_LINKAGE_PATH_$(2))
|
|
|
|
RUSTFLAGS$(1)_rustc_llvm_T_$(2) += $$(shell echo $$(LLVM_ALL_COMPONENTS_$(2)) | tr '-' '_' |\
|
2016-01-22 00:39:22 +01:00
|
|
|
sed -e 's/^ //;s/\([^ ]*\)/\-\-cfg "llvm_component=\\"\1\\""/g')
|
2014-11-26 00:28:49 +01:00
|
|
|
endef
|
|
|
|
|
|
|
|
$(foreach source,$(CFG_HOST), \
|
|
|
|
$(foreach target,$(CFG_TARGET), \
|
|
|
|
$(eval $(call LLVM_LINKAGE_DEPS,0,$(target),$(source))) \
|
|
|
|
$(eval $(call LLVM_LINKAGE_DEPS,1,$(target),$(source))) \
|
|
|
|
$(eval $(call LLVM_LINKAGE_DEPS,2,$(target),$(source))) \
|
|
|
|
$(eval $(call LLVM_LINKAGE_DEPS,3,$(target),$(source)))))
|