Skip to content

Commit

Permalink
Rollup merge of rust-lang#39837 - alexcrichton:llvm-crt-static, r=brson
Browse files Browse the repository at this point in the history
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 rust-lang#37406
  • Loading branch information
GuillaumeGomez authored Feb 16, 2017
2 parents c1c555b + c02c44d commit edbd3d7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ fn main() {
}
}
}

if target.contains("pc-windows-msvc") {
cmd.arg("-Z").arg("unstable-options");
cmd.arg("-C").arg("target-feature=+crt-static");
}
}

if verbose > 1 {
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ pub fn llvm(build: &Build, target: &str) {
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);

if target.contains("msvc") {
cfg.define("LLVM_USE_CRT_DEBUG", "MT");
cfg.define("LLVM_USE_CRT_RELEASE", "MT");
cfg.define("LLVM_USE_CRT_RELWITHDEBINFO", "MT");
}

if target.starts_with("i686") {
cfg.define("LLVM_BUILD_32_BITS", "ON");
}
Expand Down
2 changes: 1 addition & 1 deletion src/rustllvm/llvm-auto-clean-trigger
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
# The actual contents of this file do not matter, but to trigger a change on the
# build bots then the contents should be changed so git updates the mtime.
2016-12-19
2017-02-15

0 comments on commit edbd3d7

Please sign in to comment.