[llvm] 09153ab - [windows] Add /Gw to compiler flags

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 19 23:51:35 PST 2020


Might as well cherry-pick this to 10.x as well.
f004359106cfda578733dff1380560b68f9c3713

On Fri, Feb 14, 2020 at 9:15 PM Nico Weber via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
>
> Author: Nico Weber
> Date: 2020-02-14T15:15:00-05:00
> New Revision: 09153ab9d267a86d6e9bce18d5074617de5879a5
>
> URL: https://github.com/llvm/llvm-project/commit/09153ab9d267a86d6e9bce18d5074617de5879a5
> DIFF: https://github.com/llvm/llvm-project/commit/09153ab9d267a86d6e9bce18d5074617de5879a5.diff
>
> LOG: [windows] Add /Gw to compiler flags
>
> 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
>
> Added:
>
>
> Modified:
>     llvm/cmake/modules/HandleLLVMOptions.cmake
>     llvm/utils/gn/build/BUILD.gn
>
> Removed:
>
>
>
> ################################################################################
> diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
> index cd48f93f80ca..1c75c8ea35be 100644
> --- a/llvm/cmake/modules/HandleLLVMOptions.cmake
> +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
> @@ -793,6 +793,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)
>
> diff  --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
> index 7947a367cf28..b74268996f15 100644
> --- a/llvm/utils/gn/build/BUILD.gn
> +++ b/llvm/utils/gn/build/BUILD.gn
> @@ -59,8 +59,8 @@ config("compiler_defaults") {
>      }
>      if (is_optimized) {
>        cflags += [
> -        # FIXME: evaluate /Gw (not part of /O2)
>          "/O2",
> +        "/Gw",
>          "/Zc:inline",
>        ]
>        ldflags += [
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list