Skip to content

Commit 3623b13

Browse files
committed
---
yaml --- r: 208735 b: refs/heads/snap-stage3 c: b538189 h: refs/heads/master i: 208733: f83ffde 208731: 603af23 208727: 5e15c83 208719: c74ef94 208703: 4d93aec v: v3
1 parent 0601270 commit 3623b13

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 38a97becdf3e6a6157f6f7ec2d98ade8d8edc193
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: ce8b317558a83021b7ea0f40c5719995e234da03
4+
refs/heads/snap-stage3: b538189ba0abb77658c7b082d2d541daaaa7f80a
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/mk/cfg/x86_64-pc-windows-msvc.mk

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,37 @@ endif
4545
# instead of `lib.exe` for assembling archives, so we need to inject this custom
4646
# dependency here.
4747
NATIVE_TOOL_DEPS_core_T_x86_64-pc-windows-msvc += llvm-ar.exe
48+
49+
# When working with MSVC on windows, each DLL needs to explicitly declare its
50+
# interface to the outside world through some means. The options for doing so
51+
# include:
52+
#
53+
# 1. A custom attribute on each function itself
54+
# 2. A linker argument saying what to export
55+
# 3. A file which lists all symbols that need to be exported
56+
#
57+
# The Rust compiler takes care (1) for us for all Rust code by annotating all
58+
# public-facing functions with dllexport, but we have a few native dependencies
59+
# which need to cross the DLL boundary. The most important of these dependencies
60+
# is LLVM which is linked into `rustc_llvm.dll` but primarily used from
61+
# `rustc_trans.dll`. This means that many of LLVM's C API functions need to be
62+
# exposed from `rustc_llvm.dll` to be forwarded over the boundary.
63+
#
64+
# Unfortunately, at this time, LLVM does not handle this sort of exportation on
65+
# Windows for us, so we're forced to do it ourselves if we want it (which seems
66+
# like the path of least resistance right now). To do this we generate a `.DEF`
67+
# file [1] which we then custom-pass to the linker when building the rustc_llvm
68+
# crate. This DEF file list all symbols that are exported from
69+
# `src/librustc_llvm/lib.rs` and is generated by a small python script.
70+
#
71+
# Fun times!
72+
#
73+
# [1]: https://msdn.microsoft.com/en-us/library/28d6s79h.aspx
74+
RUSTFLAGS_rustc_llvm_T_x86_64-pc-windows-msvc += \
75+
-C link-args="-DEF:x86_64-pc-windows-msvc/rt/rustc_llvm.def"
76+
CUSTOM_DEPS_rustc_llvm_T_x86_64-pc-windows-msvc += \
77+
x86_64-pc-windows-msvc/rt/rustc_llvm.def
78+
79+
x86_64-pc-windows-msvc/rt/rustc_llvm.def: $(S)src/etc/mklldef.py \
80+
$(S)src/librustc_llvm/lib.rs
81+
$(CFG_PYTHON) $^ $@ rustc_llvm-$(CFG_FILENAME_EXTRA)

branches/snap-stage3/mk/target.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4) := \
3939
$$(foreach dep,$$(NATIVE_DEPS_$(4)_T_$(2)), \
4040
$$(RT_OUTPUT_DIR_$(2))/$$(dep)) \
4141
$$(foreach dep,$$(NATIVE_TOOL_DEPS_$(4)_T_$(2)), \
42-
$$(TBIN$(1)_T_$(3)_H_$(3))/$$(dep))
42+
$$(TBIN$(1)_T_$(3)_H_$(3))/$$(dep)) \
43+
$$(CUSTOM_DEPS_$(4)_T_$(2))
4344
endef
4445

4546
$(foreach host,$(CFG_HOST), \
@@ -92,6 +93,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
9293
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
9394
$$(LLVM_STDCPP_RUSTFLAGS_$(2)) \
9495
$$(RUSTFLAGS_$(4)) \
96+
$$(RUSTFLAGS_$(4)_T_$(2)) \
9597
--out-dir $$(@D) \
9698
-C extra-filename=-$$(CFG_FILENAME_EXTRA) \
9799
$$<
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2015 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+
import sys
12+
13+
input_file = sys.argv[1]
14+
output_file = sys.argv[2]
15+
name = sys.argv[3]
16+
17+
with open(input_file, 'r') as f:
18+
with open(output_file, 'w') as g:
19+
print >> g, 'LIBRARY ' + name
20+
print >> g, 'EXPORTS'
21+
for x in f:
22+
x = str(x)
23+
if not x.startswith(' pub fn LLVM'): continue
24+
name = x[11:x.find('(')]
25+
print >> g, ' ' + name

0 commit comments

Comments
 (0)