Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Apr 2021 14:27:55 +0000
From:      bugzilla-noreply@freebsd.org
To:        ports-bugs@FreeBSD.org
Subject:   [Bug 255123] cmake compiler test fails with pthread
Message-ID:  <bug-255123-7788@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D255123

            Bug ID: 255123
           Summary: cmake compiler test fails with pthread
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: ports-bugs@FreeBSD.org
          Reporter: info@babaei.net
                CC: pavelivolkov@gmail.com
                CC: pavelivolkov@gmail.com
             Flags: maintainer-feedback?(pavelivolkov@gmail.com)

I have a few cmake-based C++ projects, which fail to build on 12.2 and 13.0.
They used to work on earlier versions of FreeBSD:

$ cat build/CMakeFiles/CMakeError.log

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the follo=
wing
output:
Change Dir: /home/mamadou/barandazstorm/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/local/bin/ninja cmTC_cea33 && [1/2] Building C ob=
ject
CMakeFiles/cmTC_cea33.dir/src.c.o
[2/2] Linking C executable cmTC_cea33
FAILED: cmTC_cea33=20
: && /usr/bin/cc   CMakeFiles/cmTC_cea33.dir/src.c.o -o cmTC_cea33   && :
ld: error: undefined symbol: pthread_create
>>> referenced by src.c
>>>               CMakeFiles/cmTC_cea33.dir/src.c.o:(main)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.


Source file was:
#include <pthread.h>

static void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the backtrace exist failed with the following output:
Change Dir: /home/mamadou/barandazstorm/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/local/bin/ninja cmTC_1559d && [1/2] Building C ob=
ject
CMakeFiles/cmTC_1559d.dir/CheckSymbolExists.c.o
[2/2] Linking C executable cmTC_1559d
FAILED: cmTC_1559d=20
: && /usr/bin/cc   CMakeFiles/cmTC_1559d.dir/CheckSymbolExists.c.o -o
cmTC_1559d   && :
ld: error: undefined symbol: backtrace
>>> referenced by CheckSymbolExists.c
>>>               CMakeFiles/cmTC_1559d.dir/CheckSymbolExists.c.o:(main)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.


File /home/mamadou/barandazstorm/build/CMakeFiles/CMakeTmp/CheckSymbolExist=
s.c:
/* */
#include <execinfo.h>

int main(int argc, char** argv)
{
  (void)argv;
#ifndef backtrace
  return ((int*)(&backtrace))[argc];
#else
  (void)argc;
  return 0;
#endif
}


Here is how Threads are being enabled and used:

set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)

target_link_libraries(bbackend
    PRIVATE
    ${libzmq_LIBRARIES}
    Threads::Threads
)

There is a similar thread for databases/sqlite3, but I am not sure how these
changes affect cmake-based projects on FreeBSD?

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-255123-7788>