Skip to content

Commit 8fb62e7

Browse files
committed
SERVER-13964: Shrink Windows Binaries with VS2013 Update 2
Enable new compiler flags that shrink the binaries if we are using VS2013 Update 2 or later
1 parent 650c984 commit 8fb62e7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

SConstruct

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,38 @@ def doConfigure(myenv):
13561356
print( 'Failed to enable sanitizer with flag: ' + sanitizer_option )
13571357
Exit(1)
13581358

1359+
# When using msvc, check for VS 2013 Update 2+ so we can use new compiler flags
1360+
if using_msvc():
1361+
haveVS2013Update2OrLater = False
1362+
def CheckVS2013Update2(context):
1363+
test_body = """
1364+
#if _MSC_VER < 1800 || (_MSC_VER == 1800 && _MSC_FULL_VER < 180030501)
1365+
#error Old Version
1366+
#endif
1367+
int main(int argc, char* argv[]) {
1368+
return 0;
1369+
}
1370+
"""
1371+
context.Message('Checking for VS 2013 Update 2 or Later... ')
1372+
ret = context.TryCompile(textwrap.dedent(test_body), ".cpp")
1373+
context.Result(ret)
1374+
return ret
1375+
conf = Configure(myenv, help=False, custom_tests = {
1376+
'CheckVS2013Update2' : CheckVS2013Update2,
1377+
})
1378+
haveVS2013Update2OrLater = conf.CheckVS2013Update2()
1379+
conf.Finish()
1380+
1381+
if haveVS2013Update2OrLater and optBuild:
1382+
# http://blogs.msdn.com/b/vcblog/archive/2013/09/11/introducing-gw-compiler-switch.aspx
1383+
#
1384+
myenv.Append( CCFLAGS=["/Gw", "/Gy"] )
1385+
myenv.Append( LINKFLAGS=["/OPT:REF"])
1386+
1387+
# http://blogs.msdn.com/b/vcblog/archive/2014/03/25/linker-enhancements-in-visual-studio-2013-update-2-ctp2.aspx
1388+
#
1389+
myenv.Append( CCFLAGS=["/Zc:inline"])
1390+
13591391
# Apply any link time optimization settings as selected by the 'lto' option.
13601392
if has_option('lto'):
13611393
if using_msvc():

0 commit comments

Comments
 (0)