[all-commits] [llvm/llvm-project] a54545: [CMake] Fix __builtin_thread_pointer check with LTO

Sam James via All-commits all-commits at lists.llvm.org
Sun Nov 5 06:55:14 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a54545ba6514802178cf7cf1c1dd9f7efbf3cde7
      https://github.com/llvm/llvm-project/commit/a54545ba6514802178cf7cf1c1dd9f7efbf3cde7
  Author: Sam James <sam at gentoo.org>
  Date:   2023-11-05 (Sun, 05 Nov 2023)

  Changed paths:
    M llvm/cmake/config-ix.cmake

  Log Message:
  -----------
  [CMake] Fix __builtin_thread_pointer check with LTO

With LTO, gcc's IPA passes might drop the foo() function and then the test
will pass even on platforms where __builtin_thread_pointer is unavailable.

On PPC64, we get this as a result:
```
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp:361:61: error: ‘__builtin_thread_pointer’ is not supported on this targ
```

Just mark the function in the CMake configure test with the 'used' attribute to
avoid it being optimised out. The test then behaves correctly with -flto.

Tested with e.g. 'powerpc64le-linux-gnu-gcc -O2 -flto a.c'.

Reported-by: matoro
Reviewed-by: maskray
Closes: https://github.com/llvm/llvm-project/pull/70968
Signed-off-by: Sam James <sam at gentoo.org>




More information about the All-commits mailing list