[llvm] 20b0e0a - [gn build] Stop defining GTEST_LANG_CXX11, pass /Zc:__cplusplus with msvc

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 15 07:57:24 PST 2022


Author: Nico Weber
Date: 2022-11-15T10:56:53-05:00
New Revision: 20b0e0a71a333842e13f292c1d224877be6fe538

URL: https://github.com/llvm/llvm-project/commit/20b0e0a71a333842e13f292c1d224877be6fe538
DIFF: https://github.com/llvm/llvm-project/commit/20b0e0a71a333842e13f292c1d224877be6fe538.diff

LOG: [gn build] Stop defining GTEST_LANG_CXX11, pass /Zc:__cplusplus with msvc

Ports:
* https://reviews.llvm.org/D84023
* https://reviews.llvm.org/rG4f5ccc72f6a6e
  (but see https://reviews.llvm.org/rG4901199f5b84b223)

No intended behavior change.

Added: 
    

Modified: 
    llvm/utils/gn/build/BUILD.gn
    llvm/utils/gn/secondary/third-party/unittest/BUILD.gn

Removed: 
    


################################################################################
diff  --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index 522f54f734da5..827f382910e30 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -183,6 +183,12 @@ config("compiler_defaults") {
     cflags += [ "/EHs-c-" ]
     cflags_cc += [ "/std:c++17" ]
 
+    # cl.exe doesn't set __cplusplus correctly by default.
+    # clang-cl gets it right by default, so don't needlessly add the flag there.
+    if (!is_clang) {
+      cflags_cc += [ "/Zc:__cplusplus" ]
+    }
+
     # The MSVC default value (1 MB) is not enough for parsing recursive C++
     # templates in Clang.
     ldflags += [ "/STACK:10000000" ]

diff  --git a/llvm/utils/gn/secondary/third-party/unittest/BUILD.gn b/llvm/utils/gn/secondary/third-party/unittest/BUILD.gn
index 844e43c856f4f..d4efb45ec4b55 100644
--- a/llvm/utils/gn/secondary/third-party/unittest/BUILD.gn
+++ b/llvm/utils/gn/secondary/third-party/unittest/BUILD.gn
@@ -7,9 +7,7 @@ config("googletest_config") {
     "googletest/include",
   ]
 
-  # LLVM requires C++11 but gtest doesn't correctly detect the availability
-  # of C++11 on MSVC, so we force it on.
-  defines = [ "GTEST_LANG_CXX11" ]
+  defines = []
   if (host_os == "win") {
     defines += [ "GTEST_OS_WINDOWS" ]
   }


        


More information about the llvm-commits mailing list