]> git.lizzy.rs Git - rust.git/blob - mk/llvm.mk
Rollup merge of #21496 - ColonelJ:paatch, r=alexcrichton
[rust.git] / mk / llvm.mk
1 # Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
4 #
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
10
11
12 ifdef CFG_ENABLE_FAST_MAKE
13 LLVM_DEPS := $(S)/.gitmodules
14 else
15
16 # This is just a rough approximation of LLVM deps
17 LLVM_DEPS_SRC=$(call rwildcard,$(CFG_LLVM_SRC_DIR)lib,*cpp *hpp)
18 LLVM_DEPS_INC=$(call rwildcard,$(CFG_LLVM_SRC_DIR)include,*cpp *hpp)
19 LLVM_DEPS=$(LLVM_DEPS_SRC) $(LLVM_DEPS_INC)
20 endif
21
22 define DEF_LLVM_RULES
23
24 # If CFG_LLVM_ROOT is defined then we don't build LLVM ourselves
25 ifeq ($(CFG_LLVM_ROOT),)
26
27 LLVM_STAMP_$(1) = $$(CFG_LLVM_BUILD_DIR_$(1))/llvm-auto-clean-stamp
28
29 $$(LLVM_CONFIG_$(1)): $$(LLVM_DEPS) $$(LLVM_STAMP_$(1))
30         @$$(call E, make: llvm)
31         $$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1)) $$(CFG_LLVM_BUILD_ENV_$(1)) ONLY_TOOLS="$$(LLVM_TOOLS)"
32         $$(Q)touch $$(LLVM_CONFIG_$(1))
33 endif
34
35 # This is used to independently force an LLVM clean rebuild
36 # when we changed something not otherwise captured by builtin
37 # dependencies. In these cases, commit a change that touches
38 # the stamp in the source dir.
39 $$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger
40         @$$(call E, make: cleaning llvm)
41         $(Q)$(MAKE) clean-llvm$(1)
42         @$$(call E, make: done cleaning llvm)
43         touch $$@
44
45 ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP),1)
46 LLVM_STDCPP_LOCATION_$(1) = $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
47                                         -print-file-name=libstdc++.a)
48 else
49 LLVM_STDCPP_LOCATION_$(1) =
50 endif
51
52
53 # LLVM linkage:
54 LLVM_LINKAGE_PATH_$(1):=$$(abspath $$(RT_OUTPUT_DIR_$(1))/llvmdeps.rs)
55 $$(LLVM_LINKAGE_PATH_$(1)): $(S)src/etc/mklldeps.py $$(LLVM_CONFIG_$(1))
56         $(Q)$(CFG_PYTHON) "$$<" "$$@" "$$(LLVM_COMPONENTS)" "$$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \
57                 $$(LLVM_CONFIG_$(1))
58 endef
59
60 $(foreach host,$(CFG_HOST), \
61  $(eval $(call DEF_LLVM_RULES,$(host))))
62
63 $(foreach host,$(CFG_HOST), \
64  $(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_$(host))))
65
66 # This can't be done in target.mk because it's included before this file.
67 define LLVM_LINKAGE_DEPS
68 $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.rustc_llvm: $$(LLVM_LINKAGE_PATH_$(3))
69 endef
70
71 $(foreach source,$(CFG_HOST), \
72  $(foreach target,$(CFG_TARGET), \
73   $(eval $(call LLVM_LINKAGE_DEPS,0,$(target),$(source))) \
74   $(eval $(call LLVM_LINKAGE_DEPS,1,$(target),$(source))) \
75   $(eval $(call LLVM_LINKAGE_DEPS,2,$(target),$(source))) \
76   $(eval $(call LLVM_LINKAGE_DEPS,3,$(target),$(source)))))