]> git.lizzy.rs Git - rust.git/blob - mk/rustllvm.mk
Auto merge of #26935 - oli-obk:const_val_description, r=eddyb
[rust.git] / mk / rustllvm.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 # rustc LLVM-extensions (C++) library variables and rules
13 ######################################################################
14
15 define DEF_RUSTLLVM_TARGETS
16
17 # FIXME: Lately, on windows, llvm-config --includedir is not enough
18 # to find the llvm includes (probably because we're not actually installing
19 # llvm, but using it straight out of the build directory)
20 ifdef CFG_WINDOWSY_$(1)
21 LLVM_EXTRA_INCDIRS_$(1)= $$(call CFG_CC_INCLUDE_$(1),$(S)src/llvm/include) \
22                          $$(call CFG_CC_INCLUDE_$(1),\
23                            $$(CFG_LLVM_BUILD_DIR_$(1))/include)
24 endif
25
26 RUSTLLVM_OBJS_CS_$(1) := $$(addprefix rustllvm/, \
27         ExecutionEngineWrapper.cpp RustWrapper.cpp PassWrapper.cpp \
28         ArchiveWrapper.cpp)
29
30 RUSTLLVM_INCS_$(1) = $$(LLVM_EXTRA_INCDIRS_$(1)) \
31                      $$(call CFG_CC_INCLUDE_$(1),$$(LLVM_INCDIR_$(1))) \
32                      $$(call CFG_CC_INCLUDE_$(1),$$(S)src/rustllvm/include)
33 RUSTLLVM_OBJS_OBJS_$(1) := $$(RUSTLLVM_OBJS_CS_$(1):rustllvm/%.cpp=$(1)/rustllvm/%.o)
34
35 # Note that we appease `cl.exe` and its need for some sort of exception
36 # handling flag with the `EHsc` argument here as well.
37 ifeq ($$(findstring msvc,$(1)),msvc)
38 EXTRA_RUSTLLVM_CXXFLAGS_$(1) := //EHsc
39 endif
40
41 $$(RT_OUTPUT_DIR_$(1))/$$(call CFG_STATIC_LIB_NAME_$(1),rustllvm): \
42             $$(RUSTLLVM_OBJS_OBJS_$(1))
43         @$$(call E, link: $$@)
44         $$(Q)$$(call CFG_CREATE_ARCHIVE_$(1),$$@) $$^
45
46 # On MSVC we need to double-escape arguments that llvm-config printed which
47 # start with a '/'. The shell we're running in will auto-translate the argument
48 # `/foo` to `C:/msys64/foo` but we really want it to be passed through as `/foo`
49 # so the argument passed to our shell must be `//foo`.
50 $(1)/rustllvm/%.o: $(S)src/rustllvm/%.cpp $$(MKFILE_DEPS) $$(LLVM_CONFIG_$(1))
51         @$$(call E, compile: $$@)
52         $$(Q)$$(call CFG_COMPILE_CXX_$(1), $$@,) \
53                 $$(subst  /,//,$$(LLVM_CXXFLAGS_$(1))) \
54                 $$(EXTRA_RUSTLLVM_CXXFLAGS_$(1)) \
55                 $$(RUSTLLVM_INCS_$(1)) \
56                 $$<
57 endef
58
59 # Instantiate template for all stages
60 $(foreach host,$(CFG_HOST), \
61  $(eval $(call DEF_RUSTLLVM_TARGETS,$(host))))