From e032d57642d2a042b9445b2199277bb24fee2eb5 Mon Sep 17 00:00:00 2001 From: Niranjan Nilakantan Date: Wed, 24 May 2023 12:48:51 -0700 Subject: Build googletest with IntelLLVM compilers. Use the same flags as Clang if the compiler id is IntelLLVM. IntelLLVM warns if a double constant is assigned to a float. ``` [build] .../googletest/googletest/include/gtest/gtest-printers.h:516:17: warning: implicit conversion between floating point types of different sizes [-Wimplicit-float-size-conversion] [build] mulfor6 = 1e1; ``` IntelLLVM uses fp-model=fast by default, breaking IsNan and IsInf tests. Use -ffp-model=precise to fix this. IntelLLVM does not support -Wchar-subscripts Fixes #4255 --- googletest/cmake/internal_utils.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index fa7da4e..f45a3be 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -94,12 +94,18 @@ macro(config_compiler_and_linker) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(cxx_base_flags "${cxx_base_flags} -utf-8") endif() - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR + CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") set(cxx_base_flags "-Wall -Wshadow -Wconversion -Wundef") set(cxx_exception_flags "-fexceptions") set(cxx_no_exception_flags "-fno-exceptions") - set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wredundant-decls") + set(cxx_strict_flags "-W -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wunused-parameter -Wcast-align -Winline -Wredundant-decls") set(cxx_no_rtti_flags "-fno-rtti") + if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") + set(cxx_base_flags "${cxx_base_flags} -Wno-implicit-float-size-conversion -ffp-model=precise") + else() + set(cxx_strict_flags "${cxx_strict_flags} -Wchar-subscripts") + endif() elseif (CMAKE_COMPILER_IS_GNUCXX) set(cxx_base_flags "-Wall -Wshadow -Wundef") if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0) -- cgit v0.12 From 029d3dddd4ba2788c5203490e63a24c02328bff8 Mon Sep 17 00:00:00 2001 From: niranjan Date: Wed, 24 May 2023 17:33:46 -0700 Subject: Disable some warnings for IntelLLVM on Windows. Use /fp:precise to override IntelLLVM's default of /fp:fast. This makes IsInf and IsNan work as expected by googletest. ``` [build]...\googletest\googlemock\test\gmock-function-mocker_test.cc(143,21): error: 'VoidReturning' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override] [build] MOCK_METHOD(void, VoidReturning, (int n)); // NOLINT ``` ``` [build] ...\googletest\googlemock\test\gmock-function-mocker_test.cc(182,20): error: exception specification of overriding function is more lax than base version [-Werror,-Wmicrosoft-exception-spec] [build] MOCK_METHOD(int, CTNullary, (), (Calltype(STDMETHODCALLTYPE))); ``` ``` [build] ...\googletest\googletest\test\googletest-death-test-test.cc(209,5): error: unused function 'DieInCRTDebugElse12' [-Werror,-Wunused-function] [build] int DieInCRTDebugElse12(int* sideeffect) { [build] ^ ``` ``` [build] ...\googletest\googletest\test\gtest_unittest.cc(4096,7): error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable] [build] int n = 0; ``` --- googletest/cmake/internal_utils.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index f45a3be..e7927a3 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -94,6 +94,9 @@ macro(config_compiler_and_linker) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(cxx_base_flags "${cxx_base_flags} -utf-8") endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") + set(cxx_base_flags "${cxx_base_flags} /fp:precise -Wno-inconsistent-missing-override -Wno-microsoft-exception-spec -Wno-unused-function -Wno-unused-but-set-variable") + endif() elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM") set(cxx_base_flags "-Wall -Wshadow -Wconversion -Wundef") -- cgit v0.12 From a7833a19bda5e3c7e0dc226875752514cf77645b Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Wed, 31 May 2023 09:32:35 -0700 Subject: Update GoogleTest to RE2 release `2023-06-01`. Note that RE2 has taken a dependency on Abseil, so the `main` branch should be used from now on. The `abseil` branch will go away soon... PiperOrigin-RevId: 536737543 Change-Id: I0e595ee8e754b924881f997f286cdec3822763bf --- googletest_deps.bzl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/googletest_deps.bzl b/googletest_deps.bzl index 65e56ab..5e807d7 100644 --- a/googletest_deps.bzl +++ b/googletest_deps.bzl @@ -7,10 +7,10 @@ def googletest_deps(): if not native.existing_rule("com_googlesource_code_re2"): http_archive( - name = "com_googlesource_code_re2", # 2022-12-21T14:29:10Z - sha256 = "b9ce3a51beebb38534d11d40f8928d40509b9e18a735f6a4a97ad3d014c87cb5", - strip_prefix = "re2-d0b1f8f2ecc2ea74956c7608b6f915175314ff0e", - urls = ["https://github.com/google/re2/archive/d0b1f8f2ecc2ea74956c7608b6f915175314ff0e.zip"], + name = "com_googlesource_code_re2", # 2023-06-01 + sha256 = "1726508efc93a50854c92e3f7ac66eb28f0e57652e413f11d7c1e28f97d997ba", + strip_prefix = "re2-03da4fc0857c285e3a26782f6bc8931c4c950df4", + urls = ["https://github.com/google/re2/archive/03da4fc0857c285e3a26782f6bc8931c4c950df4.zip"], ) if not native.existing_rule("com_google_absl"): -- cgit v0.12 From 04cf2989168a3f9218d463bea6f15f8ade2032fd Mon Sep 17 00:00:00 2001 From: Dino Radakovic Date: Wed, 31 May 2023 10:45:02 -0700 Subject: Provide example for setting C++ language standard in GoogleTest's Bazel quickstart and readme. An equivalent for CMake was merged in https://github.com/google/googletest/commit/aa99ce5a0db4215bb8e2cda3ee68b6b8d4896815 Fixes #4254 PiperOrigin-RevId: 536759641 Change-Id: I8400064a24e0d78f17a0720046f505efa1167b4f --- docs/quickstart-bazel.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/quickstart-bazel.md b/docs/quickstart-bazel.md index 15c27a2..4f693db 100644 --- a/docs/quickstart-bazel.md +++ b/docs/quickstart-bazel.md @@ -105,10 +105,17 @@ file (`@com_google_googletest`). For more information about Bazel `BUILD` files, see the [Bazel C++ Tutorial](https://docs.bazel.build/versions/main/tutorial/cpp.html). +{: .callout .note} +NOTE: In the example below, we assume Clang or GCC and set `--cxxopt=-std=c++14` +to ensure that GoogleTest is compiled as C++14 instead of the compiler's default +setting (which could be C++11). For MSVC, the equivalent would be +`--cxxopt=/std:c++14`. See [Supported Platforms](platforms.md) for more details +on supported language versions. + Now you can build and run your test:
-my_workspace$ bazel test --test_output=all //:hello_test
+my_workspace$ bazel test --cxxopt=-std=c++14 --test_output=all //:hello_test
 INFO: Analyzed target //:hello_test (26 packages loaded, 362 targets configured).
 INFO: Found 1 test target...
 INFO: From Testing //:hello_test:
-- 
cgit v0.12


From 06f44bc951046150f1348598854b211afdcf37fc Mon Sep 17 00:00:00 2001
From: Dino Radakovic 
Date: Thu, 1 Jun 2023 07:28:00 -0700
Subject: Copy supported platforms from README onto
 https://google.github.io/googletest/platforms.html

PiperOrigin-RevId: 537016664
Change-Id: Ie62891a1061465a009b90feba0ccb91d85591160
---
 docs/platforms.md | 39 ++++++---------------------------------
 1 file changed, 6 insertions(+), 33 deletions(-)

diff --git a/docs/platforms.md b/docs/platforms.md
index eba6ef8..d35a7be 100644
--- a/docs/platforms.md
+++ b/docs/platforms.md
@@ -1,35 +1,8 @@
 # Supported Platforms
 
-GoogleTest requires a codebase and compiler compliant with the C++11 standard or
-newer.
-
-The GoogleTest code is officially supported on the following platforms.
-Operating systems or tools not listed below are community-supported. For
-community-supported platforms, patches that do not complicate the code may be
-considered.
-
-If you notice any problems on your platform, please file an issue on the
-[GoogleTest GitHub Issue Tracker](https://github.com/google/googletest/issues).
-Pull requests containing fixes are welcome!
-
-### Operating systems
-
-*   Linux
-*   macOS
-*   Windows
-
-### Compilers
-
-*   gcc 5.0+
-*   clang 5.0+
-*   MSVC 2015+
-
-**macOS users:** Xcode 9.3+ provides clang 5.0+.
-
-### Build systems
-
-*   [Bazel](https://bazel.build/)
-*   [CMake](https://cmake.org/)
-
-Bazel is the build system used by the team internally and in tests. CMake is
-supported on a best-effort basis and by the community.
+GoogleTest follows Google's
+[Foundational C++ Support Policy](https://opensource.google/documentation/policies/cplusplus-support).
+See
+[this table](https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md)
+for a list of currently supported versions compilers, platforms, and build
+tools.
-- 
cgit v0.12