googletest icon indicating copy to clipboard operation
googletest copied to clipboard

[Bug]: Old CMake with IntelLLVM: Unsupported command line options, multiple warnings

Open al42and opened this issue 2 years ago • 3 comments
trafficstars

Describe the issue

IntelLLVM is recognized only by CMake 3.20+: https://cmake.org/cmake/help/latest/release/3.20.html#compilers

When an older CMake is used, CMAKE_CXX_COMPILER_ID is set to Clang. This causes -Wchar-subscripts flag to be added to cxx_strict_flags, while a bunch of flags used to silence warnings are not added:

https://github.com/google/googletest/blob/cc366710bbf40a9816d47c35802d06dbaccb8792/googletest/cmake/internal_utils.cmake#L99-L104

Steps to reproduce the problem

$ docker run --pull --rm -it docker.io/intel/oneapi:2023.1.0-devel-ubuntu20.04
<<< 4 GiB later >>>
# wget https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.sh
# bash cmake-3.18.0-Linux-x86_64.sh --skip-license --prefix=/opt/
# git clone https://github.com/google/googletest.git && cd googletest
# /opt/bin/cmake -S . -B build/ -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx
# /opt/bin/cmake --build build/
Scanning dependencies of target gtest
[ 12%] Building CXX object googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
icpx: command line warning #10430: Unsupported command line options encountered
These options as listed are not supported.
For more information, use '-qnextgen-diag'.
option list: 
        -Wchar-subscripts
In file included from /googletest/googletest/src/gtest-all.cc:49:
/googletest/googletest/src/gtest.cc:1655:8: warning: explicit comparison with NaN in fast floating point mode [-Wtautological-constant-compare]
  if (!(std::isnan)(val1) && !(std::isnan)(val2) && abs_error > 0 &&
       ^~~~~~~~~~~~~~~~~~
/googletest/googletest/src/gtest.cc:1655:31: warning: explicit comparison with NaN in fast floating point mode [-Wtautological-constant-compare]
  if (!(std::isnan)(val1) && !(std::isnan)(val2) && abs_error > 0 &&
                              ^~~~~~~~~~~~~~~~~~
In file included from /googletest/googletest/src/gtest-all.cc:38:
In file included from /googletest/googletest/include/gtest/gtest.h:65:
In file included from /googletest/googletest/include/gtest/gtest-death-test.h:43:
In file included from /googletest/googletest/include/gtest/internal/gtest-death-test-internal.h:47:
In file included from /googletest/googletest/include/gtest/gtest-matchers.h:49:
/googletest/googletest/include/gtest/gtest-printers.h:512:25: warning: implicit conversion between floating point types of different sizes [-Wimplicit-float-size-conversion]
    FloatType mulfor6 = 1e10;
              ~~~~~~~   ^~~~
<<< and so on >>>

What version of GoogleTest are you using?

cc366710bbf40a9816d47c35802d06dbaccb8792

What operating system and version are you using?

Ubuntu Linux 20.04

What compiler and version are you using?

Intel(R) oneAPI DPC++/C++ Compiler 2023.1.0 (2023.1.0.20230320) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/intel/oneapi/compiler/2023.1.0/linux/bin-llvm Configuration file: /opt/intel/oneapi/compiler/2023.1.0/linux/bin-llvm/../bin/icpx.cfg

What build system are you using?

cmake version 3.18.0

Additional context

The docker image used for reproducer ships with a newer CMake, but by default, Ubuntu 20.04 provides CMake 3.16.3

al42and avatar Jul 14 '23 11:07 al42and

https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md

IntelLLVM is not a supported compiler. We are open to patches from the community for this issue.

derekmauro avatar Jul 17 '23 19:07 derekmauro

@derekmauro I might be missing something, but: Wouldn't adding a simple check for CMAKE_CXX_COMPILER==icpx together with a check for the current CMAKE version (as provided by CMAKE using the CMAKE_VERSION variable in https://github.com/google/googletest/blob/cc366710bbf40a9816d47c35802d06dbaccb8792/googletest/cmake/internal_utils.cmake#L99-L104 fix this issue?

EDIT: I'm on a roll when it comes to doing stuff on this project, so I'm gonna give it a try.

tobbi avatar May 14 '24 07:05 tobbi

I've provided a fix for this issue in #4541. Please test this thoroughly (I've tested it using the VM provided in the initial comment.

tobbi avatar May 14 '24 10:05 tobbi

I'm closing this issue. If you want to use IntelLLVM with CMake, upgrade CMake.

derekmauro avatar May 22 '24 17:05 derekmauro