Issue |
90810
|
Summary |
[packaging] clang-18 from apt.llvm.org on Ubuntu 23.10 mantic fails to build using pthread when LTO is enabled
|
Labels |
new issue
|
Assignees |
|
Reporter |
illwieckz
|
When I build the [Daemon game engine](https://github.com/DaemonEngine/Daemon) with Clang 18 from https://apt.llvm.org On Ubuntu 23.10 mantis and enable LTO, the configuration fails at the pthread detection step. It works with Clang 18 if I disable LTO. It also works with Clang 17 and 19 if I enable or disable LTO.
|Clang 17|Clang 18|Clang 19
-|-|-|-
LTO ON|✅️ ok|❌️ ko|✅️ ok
LTO OFF|✅️ ok|✅️ ok|✅️ ok
The reported Clang is `18.1.3`.
As a side note, I noticed that with Intel ICX `2024.1` which is based on Clang `18.0.0` I can configure and build with LTO enabled.
## Environment
```
$ dpkg -l clang-18 | grep -E '^ii'
ii clang-18 1:18.1.3~++20240322073236+ef6d1ec07c69-1~exp1~20240322193248.98 amd64 C, C++ and Objective-C compiler
$ clang-18 -v 2>&1 | head -n1
Ubuntu clang version 18.1.3 (++20240322073236+ef6d1ec07c69-1~exp1~20240322193248.98)
$ lsb_release -irc
Distributor ID: Ubuntu
Release: 23.10
Codename: mantic
```
## How to reproduce
```sh
git clone -b 'unvanquished/0.54.1' --recurse-submodules 'https://github.com/DaemonEngine/Daemon.git'
cd Daemon
mkdir build
cd build
cmake .. -D'CMAKE_C_COMPILER'='clang-18' -D'CMAKE_CXX_COMPILER'='clang++-18' -D'USE_LTO'='ON'
```
## Some logs
Here is an excerpt of the log, including the error:
```
$ rm -f CMakeCache.txt
$ cmake .. -D'CMAKE_C_COMPILER'='clang-18' -D'CMAKE_CXX_COMPILER'='clang'++-18' -D'USE_LTO'='ON'
-- The C compiler identification is Clang 18.1.3
-- The CXX compiler identification is Clang 18.1.3
…
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - no
CMake Error at /usr/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
/usr/share/cmake-3.27/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.27/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:580 (find_package)
-- Configuring incomplete, errors occurred!
```
It works if I use Clang 18 with LTO disabled, or if I use Clang 17 or Clang 19 with LTO enabled or disabled:
```
$ rm -f CMakeCache.txt
$ cmake .. -D'CMAKE_C_COMPILER'='clang-18' -D'CMAKE_CXX_COMPILER'='clang'++-18' -D'USE_LTO'='OFF'
-- The C compiler identification is Clang 18.1.3
-- The CXX compiler identification is Clang 18.1.3
…
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
…
-- Configuring done (7.2s)
-- Generating done (0.1s)
-- Build files have been written to: Daemon/build
```
```
$ rm -f CMakeCache.txt
$ cmake .. -D'CMAKE_C_COMPILER'='clang-17' -D'CMAKE_CXX_COMPILER'='clang'++-17' -D'USE_LTO'='ON'
-- The C compiler identification is Clang 17.0.6
-- The CXX compiler identification is Clang 17.0.6
…
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
…
-- Configuring done (7.2s)
-- Generating done (0.1s)
-- Build files have been written to: Daemon/build
```
```
$ rm -f CMakeCache.txt
$ cmake .. -D'CMAKE_C_COMPILER'='clang-19' -D'CMAKE_CXX_COMPILER'='clang'++-19' -D'USE_LTO'='ON'
-- The C compiler identification is Clang 19.0.0
-- The CXX compiler identification is Clang 19.0.0
…
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
…
-- Configuring done (7.2s)
-- Generating done (0.1s)
-- Build files have been written to: Daemon/build
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs