[Bug 255123] cmake compiler test fails with pthread

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed May 5 20:44:55 BST 2021


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=255123

Loïc Bartoletti <lbartoletti at FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lbartoletti at FreeBSD.org

--- Comment #5 from Loïc Bartoletti <lbartoletti at FreeBSD.org> ---
I think it's a false positive.

cmake use FindThreads module to determine how to build thread program.

First it searches pthread.h
https://gitlab.kitware.com/cmake/cmake/-/blob/d6da6784bfdb59456942d11d476593906945adbb/Modules/FindThreads.cmake#L144

> -- Looking for pthread.h
> -- Looking for pthread.h - found

We have pthread.h, so how to link it? With  -lpthread, -lpthread, -lthread or 
libc?

This part, and this is the test in the CMakeError.log file, is not for us.

CMake will
> Check if pthread functions are in normal C library.
> We list some pthread functions in PTHREAD_C_CXX_TEST_SOURCE test code.
> If the pthread functions already exist in C library, we could just use
> them instead of linking to the additional pthread library.

From
https://gitlab.kitware.com/cmake/cmake/-/blob/d6da6784bfdb59456942d11d476593906945adbb/Modules/FindThreads.cmake#L158-166 

> -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
> -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed

So, CMake will check with pthread,
https://gitlab.kitware.com/cmake/cmake/-/blob/d6da6784bfdb59456942d11d476593906945adbb/Modules/FindThreads.cmake#L171-177

-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes

It found pthread.h and libpthread, we can build the code.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the kde-freebsd mailing list