Skip to content

Commit 23a0c26

Browse files
committed
Auto merge of #39837 - alexcrichton:llvm-crt-static, r=brson
rustc: Link statically to the MSVCRT This commit changes all MSVC rustc binaries to be compiled with `-C target-feature=+crt-static` to link statically against the MSVCRT instead of dynamically (as it does today). This also necessitates compiling LLVM in a different fashion, ensuring it's compiled with `/MT` instead of `/MD`. cc #37406
2 parents 536a900 + c02c44d commit 23a0c26

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/bootstrap/bin/rustc.rs

+5
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ fn main() {
205205
}
206206
}
207207
}
208+
209+
if target.contains("pc-windows-msvc") {
210+
cmd.arg("-Z").arg("unstable-options");
211+
cmd.arg("-C").arg("target-feature=+crt-static");
212+
}
208213
}
209214

210215
if verbose > 1 {

src/bootstrap/native.rs

+6
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ pub fn llvm(build: &Build, target: &str) {
9999
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
100100
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);
101101

102+
if target.contains("msvc") {
103+
cfg.define("LLVM_USE_CRT_DEBUG", "MT");
104+
cfg.define("LLVM_USE_CRT_RELEASE", "MT");
105+
cfg.define("LLVM_USE_CRT_RELWITHDEBINFO", "MT");
106+
}
107+
102108
if target.starts_with("i686") {
103109
cfg.define("LLVM_BUILD_32_BITS", "ON");
104110
}

src/rustllvm/llvm-auto-clean-trigger

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
22
# The actual contents of this file do not matter, but to trigger a change on the
33
# build bots then the contents should be changed so git updates the mtime.
4-
2016-12-19
4+
2017-02-15

0 commit comments

Comments
 (0)