[all-commits] [llvm/llvm-project] bfa644: [compiler-rt] Fix incorrect usages of check_cxx_co...

Alexander Richardson via All-commits all-commits at lists.llvm.org
Thu Mar 7 23:25:21 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bfa6444a332f82843f9fa44821d68fcc772e0272
      https://github.com/llvm/llvm-project/commit/bfa6444a332f82843f9fa44821d68fcc772e0272
  Author: Alexander Richardson <alexrichardson at google.com>
  Date:   2024-03-07 (Thu, 07 Mar 2024)

  Changed paths:
    M compiler-rt/cmake/config-ix.cmake

  Log Message:
  -----------
  [compiler-rt] Fix incorrect usages of check_cxx_compiler_flag

These checks have been broken since 6afe972195454a1110ed8d20c6f2a547e6366379.
The check_cxx_compiler_flag macro only takes two arguments and passing
three to it ends up calling
`cmake_check_compiler_flag(CXX "${_FLAG}" ${_RESULT})` with ${_FLAG}
equal to `-Werror` and the result variable being the actually tested
compiler flag.

I noticed this because some of the flags that I know should be supported
were being flagged as not supported. `--debug-trycompile` shows the
following surprising line in the generated CMakeLists.txt:
`add_definitions([==[-D-Wempty-body]==] [==[-Werror]==])` which then
results in the following error while running the check:
```
FAILED: CMakeFiles/cmTC_72736.dir/src.cxx.o
tmp/upstream-llvm-readonly/bin/clang++   -nodefaultlibs -std=c++17 -fcolor-diagnostics   -D-Wempty-body -Werror -MD -MT CMakeFiles/cmTC_72736.dir/src.cxx.o -MF CMakeFiles/cmTC_72736.dir/src.cxx.o.d -o CMakeFiles/cmTC_72736.dir/src.cxx.o -c .../cmake-build-all-sanitizers/CMakeFiles/CMakeScratch/TryCompile-nyh3QR/src.cxx
In file included from <built-in>:450:
<command line>:1:9: error: macro name must be an identifier
    1 | #define -Wempty-body 1
      |         ^
   1 error generated.
```

It would be great if CMake could be a bit more helpful here so I've
filed https://gitlab.kitware.com/cmake/cmake/-/issues/25735.

See also https://reviews.llvm.org/D146920.

Reviewed By: nikic

Pull Request: https://github.com/llvm/llvm-project/pull/83779



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list