From af3bc30cd0987c789818eb15244227d0f13b0003 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 2 Dec 2016 00:09:43 -0800 Subject: [PATCH] Pass /MT for crt-static on MSVC --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 7c258c1..79decf0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -463,7 +463,13 @@ impl Config { if msvc { cmd.args.push("/nologo".into()); - cmd.args.push("/MD".into()); // link against msvcrt.dll for now + let features = env::var("CARGO_CFG_TARGET_FEATURE") + .unwrap_or(String::new()); + if features.contains("crt-static") { + cmd.args.push("/MT".into()); + } else { + cmd.args.push("/MD".into()); + } match &opt_level[..] { "z" | "s" => cmd.args.push("/Os".into()), "2" => cmd.args.push("/O2".into()),