]> git.lizzy.rs Git - rust.git/blob - mk/cfg/x86_64-pc-windows-msvc.mk
mk: Update `make dist` for MSVC targets
[rust.git] / mk / cfg / x86_64-pc-windows-msvc.mk
1 # x86_64-pc-windows-msvc configuration
2 CC_x86_64-pc-windows-msvc="$(CFG_MSVC_CL)" -nologo
3 LINK_x86_64-pc-windows-msvc="$(CFG_MSVC_LINK)" -nologo
4 CXX_x86_64-pc-windows-msvc="$(CFG_MSVC_CL)" -nologo
5 CPP_x86_64-pc-windows-msvc="$(CFG_MSVC_CL)" -nologo
6 AR_x86_64-pc-windows-msvc="$(CFG_MSVC_LIB)" -nologo
7 CFG_LIB_NAME_x86_64-pc-windows-msvc=$(1).dll
8 CFG_STATIC_LIB_NAME_x86_64-pc-windows-msvc=$(1).lib
9 CFG_LIB_GLOB_x86_64-pc-windows-msvc=$(1)-*.dll
10 CFG_LIB_DSYM_GLOB_x86_64-pc-windows-msvc=$(1)-*.dylib.dSYM
11 CFG_JEMALLOC_CFLAGS_x86_64-pc-windows-msvc :=
12 CFG_GCCISH_CFLAGS_x86_64-pc-windows-msvc :=
13 CFG_GCCISH_CXXFLAGS_x86_64-pc-windows-msvc :=
14 CFG_GCCISH_LINK_FLAGS_x86_64-pc-windows-msvc :=
15 CFG_GCCISH_DEF_FLAG_x86_64-pc-windows-msvc :=
16 CFG_LLC_FLAGS_x86_64-pc-windows-msvc :=
17 CFG_INSTALL_NAME_x86_64-pc-windows-msvc =
18 CFG_EXE_SUFFIX_x86_64-pc-windows-msvc := .exe
19 CFG_WINDOWSY_x86_64-pc-windows-msvc := 1
20 CFG_UNIXY_x86_64-pc-windows-msvc :=
21 CFG_LDPATH_x86_64-pc-windows-msvc :=
22 CFG_RUN_x86_64-pc-windows-msvc=$(2)
23 CFG_RUN_TARG_x86_64-pc-windows-msvc=$(call CFG_RUN_x86_64-pc-windows-msvc,,$(2))
24 CFG_GNU_TRIPLE_x86_64-pc-windows-msvc := x86_64-pc-win32
25
26 # These two environment variables are scraped by the `./configure` script and
27 # are necessary for `cl.exe` to find standard headers (the INCLUDE variable) and
28 # for `link.exe` to find standard libraries (the LIB variable).
29 ifdef CFG_MSVC_INCLUDE_PATH
30 export INCLUDE := $(CFG_MSVC_INCLUDE_PATH)
31 endif
32 ifdef CFG_MSVC_LIB_PATH
33 export LIB := $(CFG_MSVC_LIB_PATH)
34 endif
35
36 # Unfortunately `link.exe` is also a program in `/usr/bin` on MinGW installs,
37 # but it's not the one that we want. As a result we make sure that our detected
38 # `link.exe` shows up in PATH first.
39 ifdef CFG_MSVC_LINK
40 export PATH := $(CFG_MSVC_ROOT)/VC/bin/amd64:$(PATH)
41 endif
42
43 # There are more comments about this available in the target specification for
44 # Windows MSVC in the compiler, but the gist of it is that we use `llvm-ar.exe`
45 # instead of `lib.exe` for assembling archives, so we need to inject this custom
46 # dependency here.
47 NATIVE_TOOL_DEPS_core_T_x86_64-pc-windows-msvc += llvm-ar.exe
48 INSTALLED_BINS_x86_64-pc-windows-msvc += llvm-ar.exe
49
50 # When working with MSVC on windows, each DLL needs to explicitly declare its
51 # interface to the outside world through some means. The options for doing so
52 # include:
53 #
54 # 1. A custom attribute on each function itself
55 # 2. A linker argument saying what to export
56 # 3. A file which lists all symbols that need to be exported
57 #
58 # The Rust compiler takes care (1) for us for all Rust code by annotating all
59 # public-facing functions with dllexport, but we have a few native dependencies
60 # which need to cross the DLL boundary. The most important of these dependencies
61 # is LLVM which is linked into `rustc_llvm.dll` but primarily used from
62 # `rustc_trans.dll`. This means that many of LLVM's C API functions need to be
63 # exposed from `rustc_llvm.dll` to be forwarded over the boundary.
64 #
65 # Unfortunately, at this time, LLVM does not handle this sort of exportation on
66 # Windows for us, so we're forced to do it ourselves if we want it (which seems
67 # like the path of least resistance right now). To do this we generate a `.DEF`
68 # file [1] which we then custom-pass to the linker when building the rustc_llvm
69 # crate. This DEF file list all symbols that are exported from
70 # `src/librustc_llvm/lib.rs` and is generated by a small python script.
71 #
72 # Fun times!
73 #
74 # [1]: https://msdn.microsoft.com/en-us/library/28d6s79h.aspx
75 RUSTFLAGS_rustc_llvm_T_x86_64-pc-windows-msvc += \
76         -C link-args="-DEF:x86_64-pc-windows-msvc/rt/rustc_llvm.def"
77 CUSTOM_DEPS_rustc_llvm_T_x86_64-pc-windows-msvc += \
78         x86_64-pc-windows-msvc/rt/rustc_llvm.def
79
80 x86_64-pc-windows-msvc/rt/rustc_llvm.def: $(S)src/etc/mklldef.py \
81                         $(S)src/librustc_llvm/lib.rs
82         $(CFG_PYTHON) $^ $@ rustc_llvm-$(CFG_FILENAME_EXTRA)