From 4fc5c90853290fc358c9d5113d2a5b1758e40e30 Mon Sep 17 00:00:00 2001 From: Markus Heikkinen Date: Thu, 15 Mar 2018 18:32:08 +0200 Subject: [PATCH] Msvc needs /O1 (which implies /Os) to generate smallest binaries --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9ec2309..7fa768e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1054,8 +1054,8 @@ impl Build { cmd.args.push(crt_flag.into()); match &opt_level[..] { - "z" | "s" => cmd.args.push("/Os".into()), - "1" => cmd.args.push("/O1".into()), + // Msvc uses /O1 to enable all optimizations that minimize code size. + "z" | "s" | "1" => cmd.args.push("/O1".into()), // -O3 is a valid value for gcc and clang compilers, but not msvc. Cap to /O2. "2" | "3" => cmd.args.push("/O2".into()), _ => {}