[P4-dev] p4c CMake Failed

hemant at mnkcg.com hemant at mnkcg.com
Wed Dec 26 08:56:27 EST 2018


Not sure why Xiaoban had to build llvm.  I have used 'sudo apt-get llvm'.
Also, I didn't have to edit the ebpf CMakeLists.txt file.

 

Andy,

 

Maybe you can add these two lines to your script so that EBPF dependencies
are also installed.  'pip install' does not support a '-y or -yes' option.  

 

sudo apt-get --yes install clang llvm libpcap-dev libelf-dev iproute2
net-tools

sudo pip install pyroute2 ply scapy

 

thanks,

 

Hemant

 

From: Wu, Xiaoban <Xiaoban_Wu at student.uml.edu> 
Sent: Tuesday, December 25, 2018 3:55 PM
To: 'Alex Bernstein' <alex at mnkcg.com>; p4-dev at lists.p4.org; hemant at mnkcg.com
Subject: Re: [P4-dev] p4c CMake Failed

 

Dear All,

 

Thanks very much for your input and help. I have solved this issue and the
following is what I did.

 

1. First, I tried the bash script at
<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_jafingerhut
_p4-2Dguide_blob_master_bin_install-2Dp4dev.sh-23L67&d=DwMFAg&c=UycKcnKpT5zz
KpcCVf29TA&r=NAfqbdZpYio_GjgwEysEgS0WV4l9eSbIbehFm-ZuE3w&m=c-QkuBocoahB2ssAh
ynowLXUM7Q0jlcT866PAyp3598&s=aAO-DAz0g_ReAUbxt_AMryb_Ju9ZGlvtsP_pOU10Ffs&e=>
https://github.com/jafingerhut/p4-guide/blob/master/bin/install-p4dev.sh#L67
, unfortunately, it still errors at the cmake of llvm part.

 

2. Then I followed the link at
https://stackoverflow.com/questions/38171543/error-when-using-cmake-with-llv
m which directed me to https://github.com/abenkhadra/llvm-pass-tutorial.
>From then I manually downloaded llvm and installed it.

wget http://releases.llvm.org/3.8.0/llvm-3.8.0.src.tar.xz

tar -xvf llvm-3.8.0.src.tar.xz

cd llvm-3.8.0.src

mkdir build

cd build

cmake ..

make -j12

sudo make install





3. I changed the backends/ebpf/CMakeLists.txt line 111 into 

set(LLVM_DIR /usr/local/*)

find_package(LLVM QUIET)





4. cmake again, there is no more error.

Best wishes,
Xiaoban

  _____  

From: hemant at mnkcg.com <mailto:hemant at mnkcg.com>  <hemant at mnkcg.com
<mailto:hemant at mnkcg.com> >
Sent: Tuesday, December 25, 2018 8:09:41 AM
To: 'Alex Bernstein'; Wu, Xiaoban; p4-dev at lists.p4.org
<mailto:p4-dev at lists.p4.org> 
Subject: RE: [P4-dev] p4c CMake Failed 

 

Also, at this URL, BEPF dependencies are listed if one would like to use
EBPF.

 

https://github.com/p4lang/p4c/blob/master/backends/ebpf/README.md
<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_p4lang_p4c_
blob_master_backends_ebpf_README.md&d=DwMFAg&c=UycKcnKpT5zzKpcCVf29TA&r=NAfq
bdZpYio_GjgwEysEgS0WV4l9eSbIbehFm-ZuE3w&m=lpDLCvyDuz7VWdfRuZILKC5layjEZ_JEjX
yUe0qZKBc&s=UmYKY4umqCBpJWrWA8pHYGBL86L_p3Wvdkbq-PJUtDM&e=> 

 

$ sudo apt-get install clang llvm libpcap-dev libelf-dev iproute2 net-tools

$ sudo pip install pyroute2 ply scapy

 

Hemant

 

From: P4-dev <p4-dev-bounces at lists.p4.org
<mailto:p4-dev-bounces at lists.p4.org> > On Behalf Of Alex Bernstein
Sent: Tuesday, December 25, 2018 4:11 AM
To: Wu, Xiaoban <Xiaoban_Wu at student.uml.edu
<mailto:Xiaoban_Wu at student.uml.edu> >; p4-dev at lists.p4.org
<mailto:p4-dev at lists.p4.org> 
Subject: Re: [P4-dev] p4c CMake Failed

 

Xiaoban,

 

Try running cmake with EBPF switched off "cmake .. -DENABLE_EBPF=OFF". Could
be caused by https://github.com/p4lang/p4c/issues/1376
<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_p4lang_p4c_
issues_1376&d=DwMFAg&c=UycKcnKpT5zzKpcCVf29TA&r=NAfqbdZpYio_GjgwEysEgS0WV4l9
eSbIbehFm-ZuE3w&m=lpDLCvyDuz7VWdfRuZILKC5layjEZ_JEjXyUe0qZKBc&s=0vMCMDotkBUc
cRI3Z4Fcg5p6iQIa0ZSUlyusEsbNXv0&e=> 

 

--Alex

On 12/25/2018 2:06 AM, Wu, Xiaoban wrote:

Dear All,

 

I am trying to install p4c on ubuntu 16.04.1 with kernel 4.15.0-36-generic.
However, I could not get a success after many trials. Can anyone please help
me point out the possible issue? Thanks very much.

 

Alternative approach, could anyone tell me your OS and kernel version that
works for you, then I will try to follow your setup? Thanks very much.

 

Best wishes,

Xiaoban

 

First, I did "

git clone --recursive https://github.com/p4lang/p4c.git
<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_p4lang_p4c.
git&d=DwMFAg&c=UycKcnKpT5zzKpcCVf29TA&r=NAfqbdZpYio_GjgwEysEgS0WV4l9eSbIbehF
m-ZuE3w&m=lpDLCvyDuz7VWdfRuZILKC5layjEZ_JEjXyUe0qZKBc&s=LodY57pCeWGdivdqeKHN
mEuSPbD7mq8D8bqZJZWS1mE&e=> 

" 

 

Second, I did "sudo apt-get install cmake g++ git automake libtool libgc-dev
bison flex libfl-dev libgmp-dev libboost-dev libboost-iostreams-dev
libboost-graph-dev llvm pkg-config python python-scapy python-ipaddr
python-ply tcpdump"

 

Third, I did "

$ git clone https://github.com/protocolbuffers/protobuf.git
<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_protocolbuf
fers_protobuf.git&d=DwMFAg&c=UycKcnKpT5zzKpcCVf29TA&r=NAfqbdZpYio_GjgwEysEgS
0WV4l9eSbIbehFm-ZuE3w&m=lpDLCvyDuz7VWdfRuZILKC5layjEZ_JEjXyUe0qZKBc&s=YPLHKD
jJmbsMyw3iyyxASbzUBBgEcIZBqSE-Mfrg1eo&e=> 
$ cd protobuf
$ git submodule update --init --recursive

  $ git checkout v3.2.0

$ ./autogen.sh
$ ./configure
$ make
$ make check
$ sudo make install
$ sudo ldconfig # refresh shared library cache.

" 

 

Fourth, I did "

mkdir build
cd build
cmake ..

" 

Then I saw these logs on the screen 

"

-- The C compiler identification is GNU 5.4.0

-- The CXX compiler identification is GNU 5.4.0

-- Check for working C compiler: /usr/bin/cc

-- Check for working C compiler: /usr/bin/cc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Detecting C compile features

-- Detecting C compile features - done

-- Check for working CXX compiler: /usr/bin/c++

-- Check for working CXX compiler: /usr/bin/c++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Detecting CXX compile features

-- Detecting CXX compile features - done

-- Found PythonInterp: /usr/bin/python (found version "2.7.12") 

-- Found FLEX: /usr/bin/flex (found version "2.6.0") 

-- Found BISON: /usr/bin/bison (found suitable version "3.0.4", minimum
required is "3.0.2") 

-- Looking for pthread.h

-- Looking for pthread.h - found

-- Looking for pthread_create

-- Looking for pthread_create - not found

-- 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 - found

-- Found Threads: TRUE  

-- Found Protobuf: /usr/local/lib/libprotobuf.a (Required is at least
version "3.0.0") 

-- Boost version: 1.58.0

-- Found the following Boost libraries:

--   iostreams

--   regex

-- Found LibGc: /usr/lib/x86_64-linux-gnu/libgccpp.so (found suitable
version "7.4.2", minimum required is "7.2.0") 

-- Found LibGmp: /usr/lib/x86_64-linux-gnu/libgmpxx.so  

-- Looking for clock_gettime in rt

-- Looking for clock_gettime in rt - found

-- Looking for execinfo.h

-- Looking for execinfo.h - found

-- Looking for ucontext.h

-- Looking for ucontext.h - found

-- Looking for C++ include cxxabi.h

-- Looking for C++ include cxxabi.h - found

-- Looking for memchr

-- Looking for memchr - found

-- Looking for pipe2

-- Looking for pipe2 - found

-- Looking for GC_print_stats

-- Looking for GC_print_stats - found

-- Found PY_difflib: /usr/lib/python2.7/difflib.pyc  

-- Found PY_shutil: /usr/lib/python2.7/shutil.pyc  

-- Found PY_tempfile: /usr/lib/python2.7/tempfile.pyc  

-- Found PY_subprocess: /usr/lib/python2.7/subprocess.pyc  

-- Found PY_re: /usr/lib/python2.7/re.pyc  

-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE) 

-- Program 'simple_switch_CLI'
(https://github.com/p4lang/behavioral-model.git
<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_p4lang_beha
vioral-2Dmodel.git&d=DwMFAg&c=UycKcnKpT5zzKpcCVf29TA&r=NAfqbdZpYio_GjgwEysEg
S0WV4l9eSbIbehFm-ZuE3w&m=lpDLCvyDuz7VWdfRuZILKC5layjEZ_JEjXyUe0qZKBc&s=F5ckZ
kJ6uraXfKcqR186DUVd5EV5iN7GtzvwrueGg_c&e=> ) 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
<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_p4lang_beha
vioral-2Dmodel.git&d=DwMFAg&c=UycKcnKpT5zzKpcCVf29TA&r=NAfqbdZpYio_GjgwEysEg
S0WV4l9eSbIbehFm-ZuE3w&m=lpDLCvyDuz7VWdfRuZILKC5layjEZ_JEjXyUe0qZKBc&s=F5ckZ
kJ6uraXfKcqR186DUVd5EV5iN7GtzvwrueGg_c&e=> ) not found;

Searched .

Will not run PSA BMv2 tests. (missing:  PSA_SWITCH PSA_SWITCH_CLI) 

-- Performing Test _HAVE_OPTION_Wall_

-- Performing Test _HAVE_OPTION_Wall_ - Success

-- Performing Test _HAVE_OPTION_Wextra_

-- Performing Test _HAVE_OPTION_Wextra_ - Success

-- Performing Test _HAVE_OPTION_Wnooverloadedvirtual_

-- Performing Test _HAVE_OPTION_Wnooverloadedvirtual_ - Success

-- Performing Test _HAVE_OPTION_Wnodeprecated_

-- Performing Test _HAVE_OPTION_Wnodeprecated_ - Success

-- Using the GNU gold linker.

-- Available extensions 

CMake Warning at backends/bmv2/CMakeLists.txt:174 (MESSAGE):

  BMv2 simple switch is not available, not adding v1model BMv2 tests

 

 

CMake Warning at backends/bmv2/CMakeLists.txt:180 (MESSAGE):

  BMv2 PSA switch is not available, not adding PSA BMv2 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-kernel' (0 xfails)

-- Added 14 tests to 'ebpf-bcc' (0 xfails)

-- Added 14 tests to 'ebpf' (0 xfails)

-- Added 159 tests to 'p4' (0 xfails)

-- Added 478 tests to 'p4' (1 xfails)

-- Added 198 tests to 'p14_to_16' (0 xfails)

-- CTest parallel: -j 24

-- Configuring incomplete, errors occurred!

See also "/home/acanets/p4c/build/CMakeFiles/CMakeOutput.log".

See also "/home/acanets/p4c/build/CMakeFiles/CMakeError.log".

 

"

 

Then I checked the CMakeError.log, it says "

Determining if the pthread_create exist failed with the following output:

Change Dir: /home/acanets/p4c/build/CMakeFiles/CMakeTmp

 

Run Build Command:"/usr/bin/make" "cmTC_aae04/fast"

/usr/bin/make -f CMakeFiles/cmTC_aae04.dir/build.make
CMakeFiles/cmTC_aae04.dir/build

make[1]: Entering directory '/home/acanets/p4c/build/CMakeFiles/CMakeTmp'

Building C object CMakeFiles/cmTC_aae04.dir/CheckSymbolExists.c.o

/usr/bin/cc     -o CMakeFiles/cmTC_aae04.dir/CheckSymbolExists.c.o   -c
/home/acanets/p4c/build/CMakeFiles/CMakeTmp/CheckSymbolExists.c

Linking C executable cmTC_aae04

/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_aae04.dir/link.txt
--verbose=1

/usr/bin/cc       CMakeFiles/cmTC_aae04.dir/CheckSymbolExists.c.o  -o
cmTC_aae04 -rdynamic 

CMakeFiles/cmTC_aae04.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_aae04.dir/build.make:97: recipe for target 'cmTC_aae04'
failed

make[1]: *** [cmTC_aae04] Error 1

make[1]: Leaving directory '/home/acanets/p4c/build/CMakeFiles/CMakeTmp'

Makefile:126: recipe for target 'cmTC_aae04/fast' failed

make: *** [cmTC_aae04/fast] Error 2

 

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

 

Run Build Command:"/usr/bin/make" "cmTC_3db6b/fast"

/usr/bin/make -f CMakeFiles/cmTC_3db6b.dir/build.make
CMakeFiles/cmTC_3db6b.dir/build

make[1]: Entering directory '/home/acanets/p4c/build/CMakeFiles/CMakeTmp'

Building C object CMakeFiles/cmTC_3db6b.dir/CheckFunctionExists.c.o

/usr/bin/cc    -DCHECK_FUNCTION_EXISTS=pthread_create   -o
CMakeFiles/cmTC_3db6b.dir/CheckFunctionExists.c.o   -c
/usr/share/cmake-3.5/Modules/CheckFunctionExists.c

Linking C executable cmTC_3db6b

/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_3db6b.dir/link.txt
--verbose=1

/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create
CMakeFiles/cmTC_3db6b.dir/CheckFunctionExists.c.o  -o cmTC_3db6b -rdynamic
-lpthreads 

/usr/bin/ld: cannot find -lpthreads

collect2: error: ld returned 1 exit status

CMakeFiles/cmTC_3db6b.dir/build.make:97: recipe for target 'cmTC_3db6b'
failed

make[1]: *** [cmTC_3db6b] Error 1

make[1]: Leaving directory '/home/acanets/p4c/build/CMakeFiles/CMakeTmp'

Makefile:126: recipe for target 'cmTC_3db6b/fast' failed

make: *** [cmTC_3db6b/fast] Error 2

 

"

 

_______________________________________________
P4-dev mailing list
P4-dev at lists.p4.org <mailto:P4-dev at lists.p4.org> 
http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org
<https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.p4.org_mailman_li
stinfo_p4-2Ddev-5Flists.p4.org&d=DwMFAg&c=UycKcnKpT5zzKpcCVf29TA&r=NAfqbdZpY
io_GjgwEysEgS0WV4l9eSbIbehFm-ZuE3w&m=lpDLCvyDuz7VWdfRuZILKC5layjEZ_JEjXyUe0q
ZKBc&s=xYEfsEXEUDti70ewZgfxRcRq3jbxee_kvJ_htXDhe4o&e=> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20181226/d5bed3d2/attachment-0001.html>


More information about the P4-dev mailing list