]> git.proxmox.com Git - rustc.git/blame - mk/rustllvm.mk
New upstream version 1.12.0+dfsg1
[rustc.git] / mk / rustllvm.mk
CommitLineData
223e47cc
LB
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
15define 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)
20ifdef CFG_WINDOWSY_$(1)
62682a34
SL
21LLVM_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)
223e47cc
LB
24endif
25
1a4d82fc 26RUSTLLVM_OBJS_CS_$(1) := $$(addprefix rustllvm/, \
5bcae85e 27 RustWrapper.cpp PassWrapper.cpp \
c1a9b12d 28 ArchiveWrapper.cpp)
223e47cc 29
223e47cc 30RUSTLLVM_INCS_$(1) = $$(LLVM_EXTRA_INCDIRS_$(1)) \
62682a34
SL
31 $$(call CFG_CC_INCLUDE_$(1),$$(LLVM_INCDIR_$(1))) \
32 $$(call CFG_CC_INCLUDE_$(1),$$(S)src/rustllvm/include)
1a4d82fc 33RUSTLLVM_OBJS_OBJS_$(1) := $$(RUSTLLVM_OBJS_CS_$(1):rustllvm/%.cpp=$(1)/rustllvm/%.o)
62682a34 34
5bcae85e
SL
35# Flag that we are building with Rust's llvm fork
36ifeq ($(CFG_LLVM_ROOT),)
37RUSTLLVM_CXXFLAGS_$(1) := -DLLVM_RUSTLLVM
38endif
39
62682a34
SL
40# Note that we appease `cl.exe` and its need for some sort of exception
41# handling flag with the `EHsc` argument here as well.
42ifeq ($$(findstring msvc,$(1)),msvc)
43EXTRA_RUSTLLVM_CXXFLAGS_$(1) := //EHsc
44endif
223e47cc 45
1a4d82fc
JJ
46$$(RT_OUTPUT_DIR_$(1))/$$(call CFG_STATIC_LIB_NAME_$(1),rustllvm): \
47 $$(RUSTLLVM_OBJS_OBJS_$(1))
223e47cc 48 @$$(call E, link: $$@)
62682a34 49 $$(Q)$$(call CFG_CREATE_ARCHIVE_$(1),$$@) $$^
223e47cc 50
a7813a04
XL
51RUSTLLVM_COMPONENTS_$(1) = $$(shell echo $$(LLVM_ALL_COMPONENTS_$(1)) |\
52 tr 'a-z-' 'A-Z_'| sed -e 's/^ //;s/\([^ ]*\)/\-DLLVM_COMPONENT_\1/g')
53
62682a34
SL
54# On MSVC we need to double-escape arguments that llvm-config printed which
55# start with a '/'. The shell we're running in will auto-translate the argument
56# `/foo` to `C:/msys64/foo` but we really want it to be passed through as `/foo`
57# so the argument passed to our shell must be `//foo`.
1a4d82fc 58$(1)/rustllvm/%.o: $(S)src/rustllvm/%.cpp $$(MKFILE_DEPS) $$(LLVM_CONFIG_$(1))
223e47cc 59 @$$(call E, compile: $$@)
62682a34
SL
60 $$(Q)$$(call CFG_COMPILE_CXX_$(1), $$@,) \
61 $$(subst /,//,$$(LLVM_CXXFLAGS_$(1))) \
a7813a04 62 $$(RUSTLLVM_COMPONENTS_$(1)) \
5bcae85e 63 $$(RUSTLLVM_CXXFLAGS_$(1)) \
62682a34
SL
64 $$(EXTRA_RUSTLLVM_CXXFLAGS_$(1)) \
65 $$(RUSTLLVM_INCS_$(1)) \
66 $$<
223e47cc
LB
67endef
68
69# Instantiate template for all stages
1a4d82fc 70$(foreach host,$(CFG_HOST), \
223e47cc 71 $(eval $(call DEF_RUSTLLVM_TARGETS,$(host))))