Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake error (can't resolve pthread_create?) #1916

Closed
ilya-ratner opened this issue Apr 30, 2019 · 9 comments
Closed

cmake error (can't resolve pthread_create?) #1916

ilya-ratner opened this issue Apr 30, 2019 · 9 comments
Labels
question This is a topic requesting clarification.

Comments

@ilya-ratner
Copy link

-- Found LLVM 3.8.0
-- Added 14 tests to 'ebpf-bcc' (0 xfails)
-- Added 14 tests to 'ebpf' (0 xfails)
-- Added 5 tests to 'p4' (0 xfails)
-- Added 533 tests to 'p4' (5 xfails)
-- Added 5 tests to 'err' (0 xfails)
-- Added 160 tests to 'err' (0 xfails)
-- Added 207 tests to 'p14_to_16' (0 xfails)
-- CTest parallel: -j 4
-- Configuring incomplete, errors occurred!
See also "/home/ilya/p4/p4c/build/CMakeFiles/CMakeOutput.log".
See also "/home/ilya/p4/p4c/build/CMakeFiles/CMakeError.log".

...Below is the dump of the CMakeError.log; it appears that it can't resolve pthread_create, even though I can link with it just fine, if I use '-lpthread'

cat /home/ilya/p4/p4c/build/CMakeFiles/CMakeError.log
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_30d9b/fast"
/usr/bin/make -f CMakeFiles/cmTC_30d9b.dir/build.make CMakeFiles/cmTC_30d9b.dir/build
make[1]: Entering directory '/home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_30d9b.dir/CheckSymbolExists.c.o
/usr/bin/cc -o CMakeFiles/cmTC_30d9b.dir/CheckSymbolExists.c.o -c /home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c
Linking C executable cmTC_30d9b
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_30d9b.dir/link.txt --verbose=1
/usr/bin/cc CMakeFiles/cmTC_30d9b.dir/CheckSymbolExists.c.o -o cmTC_30d9b -rdynamic
CMakeFiles/cmTC_30d9b.dir/CheckSymbolExists.c.o: In function main': CheckSymbolExists.c:(.text+0x16): undefined reference to pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_30d9b.dir/build.make:97: recipe for target 'cmTC_30d9b' failed
make[1]: *** [cmTC_30d9b] Error 1
make[1]: Leaving directory '/home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_30d9b/fast' failed
make: *** [cmTC_30d9b/fast] Error 2

File /home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <pthread.h>

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

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_15b4a/fast"
/usr/bin/make -f CMakeFiles/cmTC_15b4a.dir/build.make CMakeFiles/cmTC_15b4a.dir/build
make[1]: Entering directory '/home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_15b4a.dir/CheckFunctionExists.c.o
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_15b4a.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.5/Modules/CheckFunctionExists.c
Linking C executable cmTC_15b4a
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_15b4a.dir/link.txt --verbose=1
/usr/bin/cc -DCHECK_FUNCTION_EXISTS=pthread_create CMakeFiles/cmTC_15b4a.dir/CheckFunctionExists.c.o -o cmTC_15b4a -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads

collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_15b4a.dir/build.make:97: recipe for target 'cmTC_15b4a' failed
make[1]: *** [cmTC_15b4a] Error 1
make[1]: Leaving directory '/home/ilya/p4/p4c/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_15b4a/fast' failed
make: *** [cmTC_15b4a/fast] Error 2

@antoninbas
Copy link
Member

This is not an error. See #1534 (comment)
The real error should be displayed in the cmake output. That fragment of CMakeError.log is not useful.

@ilya-ratner
Copy link
Author

It's not a fragment; it's an entire CMakeError.log.
If it's not an error, then why doesn't subsequent 'make -j4' work? True, CMakeOutput.log doesn't show any errors. I am just following the instructions here. All dependencies have been installed successfully.

I can see why there's an issue: it looks for 'libpthreads' -- and there's no such library; it's 'libpthread'.

@antoninbas
Copy link
Member

There should be some errors before the output you shared:

-- Found LLVM 3.8.0
-- Added 14 tests to 'ebpf-bcc' (0 xfails)
-- Added 14 tests to 'ebpf' (0 xfails)
-- Added 5 tests to 'p4' (0 xfails)
-- Added 533 tests to 'p4' (5 xfails)
-- Added 5 tests to 'err' (0 xfails)
-- Added 160 tests to 'err' (0 xfails)
-- Added 207 tests to 'p14_to_16' (0 xfails)
-- CTest parallel: -j 4
-- Configuring incomplete, errors occurred!

@jafingerhut
Copy link
Contributor

I do not know why this message is appearing, but if you are willing to start from a freshly installed Ubuntu 16.04 or 18.04 Linux system, the script [1] can install p4c and its needed dependencies, and the script [2] installs those plus BMv2 plus open source P4Runtime API software. They do not do anything more than the README instructions say to do, but they can help the process be more reproducible across installs.

[1] https://github.com/jafingerhut/p4-guide/blob/master/bin/install-p4c-without-bmv2.sh
[2] https://github.com/jafingerhut/p4-guide/blob/master/bin/install-p4dev-p4runtime.sh

@ilya-ratner
Copy link
Author

Yes, starting from fresh again is plan c :). This is a brand new install of Ubuntu 16.04. And, seemingly, everything was working fine -- got all the dependencies, built protobuf, etc.
Here's the entirety of cmake output:
(and I notice that there's an error; not sure what it means)
ilya@ilya-virtual-machine:~/p4/p4c/build$ cmake ..
-- Boost version: 1.58.0
-- Found the following Boost libraries:
-- iostreams
-- regex
-- Program 'simple_switch_CLI' (https://github.com/p4lang/behavioral-model.git) not found;
Searched .
Will not run BMv2 tests. (missing: SIMPLE_SWITCH SIMPLE_SWITCH_CLI)
-- Program 'psa_switch_CLI' (https://github.com/p4lang/behavioral-model.git) not found;
Searched .
Will not run PSA BMv2 tests. (missing: PSA_SWITCH PSA_SWITCH_CLI)
-- Using the GNU gold linker.
-- Available extensions
CMake Warning at backends/bmv2/CMakeLists.txt:189 (MESSAGE):
BMv2 simple switch is not available, not adding v1model BMv2 tests

CMake Warning at backends/bmv2/CMakeLists.txt:195 (MESSAGE):
BMv2 PSA switch is not available, not adding PSA BMv2 tests

CMake Warning at backends/ebpf/CMakeLists.txt:102 (MESSAGE):
Kernel version 4.10.0 too small, expected 4.15.0. Ignoring ebpf kernel
tests...

CMake Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:178 (include):
include could not find load file:

/usr/share/llvm/cmake/LLVMExports.cmake

Call Stack (most recent call first):
backends/ebpf/CMakeLists.txt:111 (find_package)

CMake Error at /usr/share/llvm-3.8/cmake/LLVMConfig.cmake:181 (include):
include could not find load file:

/usr/share/llvm/cmake/LLVM-Config.cmake

Call Stack (most recent call first):
backends/ebpf/CMakeLists.txt:111 (find_package)

-- Found LLVM 3.8.0
-- Added 14 tests to 'ebpf-bcc' (0 xfails)
-- Added 14 tests to 'ebpf' (0 xfails)
-- Added 5 tests to 'p4' (0 xfails)
-- Added 533 tests to 'p4' (5 xfails)
-- Added 5 tests to 'err' (0 xfails)
-- Added 160 tests to 'err' (0 xfails)
-- Added 207 tests to 'p14_to_16' (0 xfails)
-- CTest parallel: -j 4
-- Configuring incomplete, errors occurred!
See also "/home/ilya/p4/p4c/build/CMakeFiles/CMakeOutput.log".
See also "/home/ilya/p4/p4c/build/CMakeFiles/CMakeError.log".

@mihaibudiu
Copy link
Contributor

It looks like you have hit this issue: #1376
There is no simple solution; the issue links to a solution which requires you to edit some llvm configuration files.

@ilya-ratner
Copy link
Author

Yep, that's it looks like! Thanks for the link. I will plod along.

@ilya-ratner
Copy link
Author

And thanks to antoninbas -- -DENABLE_EBPF=OFF seems to have done the trick.

@mihaibudiu mihaibudiu added the question This is a topic requesting clarification. label May 7, 2019
@mihaibudiu
Copy link
Contributor

Hopefully the LLVM issue has been solved, so I am closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is a topic requesting clarification.
Projects
None yet
Development

No branches or pull requests

4 participants