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

Build error #1475

Closed
dingrui37 opened this issue Sep 7, 2018 · 4 comments
Closed

Build error #1475

dingrui37 opened this issue Sep 7, 2018 · 4 comments
Labels
duplicate This issue or pull request is a duplicate.

Comments

@dingrui37
Copy link

I have cloned the latest version of p4c, then install all dependencies. However, when building the project, it always gives an error.

mkdir build
cd build
cmake ..     // cmake error

The command console outputs as follows,

..........
-- Using the GNU gold linker.
-- Available extensions
-- Added 307 tests to 'bmv2' (8 xfails)
-- Added 4 tests to 'bmv2' (4 xfails)
CMake Warning at backends/ebpf/CMakeLists.txt:99 (MESSAGE):
  Kernel version 4.13.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:108 (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:108 (find_package)

-- Found LLVM 3.8.0
-- Added 13 tests to 'ebpf-bcc' (0 xfails)
-- Added 13 tests to 'ebpf' (0 xfails)
-- Added 154 tests to 'p4' (0 xfails)
-- Added 440 tests to 'p4' (1 xfails)
-- Added 195 tests to 'p14_to_16' (0 xfails)
-- CTest parallel: -j 12
-- Configuring incomplete, errors occurred!
See also "/home/workspace/p4lang/p4c/build/CMakeFiles/CMakeOutput.log".
See also "/home/workspace/p4lang/p4c/build/CMakeFiles/CMakeError.log".

CMakeError.log:

/usr/bin/cc       CMakeFiles/cmTC_f12d2.dir/CheckSymbolExists.c.o  -o cmTC_f12d2 -rdynamic
CMakeFiles/cmTC_f12d2.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_f12d2.dir/build.make:97: recipe for target 'cmTC_f12d2' failed
make[1]: *** [cmTC_f12d2] Error 1
make[1]: Leaving directory '/home/workspace/p4lang/p4c/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_f12d2/fast' failed
make: *** [cmTC_f12d2/fast] Error 2

File /home/workspace/p4lang/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/workspace/p4lang/p4c/build/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/make" "cmTC_1a26c/fast"
/usr/bin/make -f CMakeFiles/cmTC_1a26c.dir/build.make CMakeFiles/cmTC_1a26c.dir/build
make[1]: Entering directory '/home/workspace/p4lang/p4c/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_1a26c.dir/CheckFunctionExists.c.o
/usr/bin/cc    -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_1a26c.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-3.5/Modules/CheckFunctionExists.c
Linking C executable cmTC_1a26c
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_1a26c.dir/link.txt --verbose=1
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create    CMakeFiles/cmTC_1a26c.dir/CheckFunctionExists.c.o  -o cmTC_1a26c -rdynamic -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
CMakeFiles/cmTC_1a26c.dir/build.make:97: recipe for target 'cmTC_1a26c' failed
make[1]: *** [cmTC_1a26c] Error 1
make[1]: Leaving directory '/home/workspace/p4lang/p4c/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_1a26c/fast' failed
make: *** [cmTC_1a26c/fast] Error 2

BTW: I can call pthread_create successfully in my local environment.(e.g. gcc -o test test.c -lpthreads)

@hesingh
Copy link
Contributor

hesingh commented Sep 7, 2018

Ding,

Did you do a “sudo apt-get install llvm” on your machine? New p4c has added a llvm dependency. I downloaded latest p4c right now and ‘cmake ..’ runs fine for me. My machine is using a 4.15.0 kernel and I use Ubuntu 18.04. Your kernel is 4.13.0 and I also see some llvm issues in your log.

Hemant

@mihaibudiu
Copy link
Contributor

This is probably the same as #1376.
This is quite annoying, but I don't know what other workarounds to propose than the ones in that issue.

@mihaibudiu mihaibudiu added the duplicate This issue or pull request is a duplicate. label Sep 7, 2018
@cc10512
Copy link
Contributor

cc10512 commented Sep 7, 2018

How about turning off the EBPF backend by default until you solve these issues? (Set ENABLE_EBPF to OFF in CMakeLists.txt:34)

@dingrui37
Copy link
Author

@mbudiu-vmw I have solved the problem temporarily according to Antonin's method. But it does not seem like a perfect solution.
cmake .. -DENABLE_EBPF=OFF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request is a duplicate.
Projects
None yet
Development

No branches or pull requests

4 participants