Fix CMake configuration error when run with -Werror/-Wall
authorAlex Denisov <alex@lowlevelbits.org>
Sat, 10 Oct 2020 19:22:40 +0000 (21:22 +0200)
committerAlex Denisov <alex@lowlevelbits.org>
Sat, 10 Oct 2020 19:22:40 +0000 (21:22 +0200)
The following code doesn't compile

  uint64_t i = x.load(std::memory_order_relaxed);
  return 0;

when CMAKE_C_FLAGS set to -Werror -Wall, thus incorrectly
breaking the CMake configuration step:

  -- Looking for __atomic_load_8 in atomic
  -- Looking for __atomic_load_8 in atomic - not found
  CMake Error at cmake/modules/CheckAtomic.cmake:79 (message):
    Host compiler appears to require libatomic for 64-bit operations, but
    cannot find it.
  Call Stack (most recent call first):
    cmake/config-ix.cmake:360 (include)
    CMakeLists.txt:671 (include)

llvm/cmake/modules/CheckAtomic.cmake

index d0b75f3..04eed14 100644 (file)
@@ -32,6 +32,7 @@ function(check_working_cxx_atomics64 varname)
 std::atomic<uint64_t> x (0);
 int main() {
   uint64_t i = x.load(std::memory_order_relaxed);
+  (void)i;
   return 0;
 }
 " ${varname})