Skip to content

Commit

Permalink
[windows] Add /Gw to compiler flags
Browse files Browse the repository at this point in the history
This is like -fdata-sections, and it's not part of /O2 by default for some reason.

In the cmake build, reduces the size of clang.exe from 70,358,016 bytes to 69,982,720 bytes.

clang-format.exe goes from 3,703,296 bytes to 3,331,072 bytes.

Differential Revision: https://reviews.llvm.org/D74573

(cherry picked from commit 09153ab)
  • Loading branch information
nico authored and zmodem committed Feb 20, 2020
1 parent 5175565 commit f004359
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llvm/cmake/modules/HandleLLVMOptions.cmake
Expand Up @@ -788,6 +788,10 @@ if(NOT CYGWIN AND NOT WIN32)
endif()
add_flag_if_supported("-fdata-sections" FDATA_SECTIONS)
endif()
elseif(MSVC)
if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
append("/Gw" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()
endif()

if(MSVC)
Expand Down
1 change: 1 addition & 0 deletions llvm/utils/gn/build/BUILD.gn
Expand Up @@ -60,6 +60,7 @@ config("compiler_defaults") {
if (is_optimized) {
cflags += [
"/O2",
"/Gw",
"/Zc:inline",
]
ldflags += [
Expand Down

0 comments on commit f004359

Please sign in to comment.