Maratyszcza / NNPACK

Acceleration package for neural networks on multi-core CPUs
BSD 2-Clause "Simplified" License
1.67k stars 316 forks source link

Build error #132

Open klshrinidhi opened 6 years ago

klshrinidhi commented 6 years ago

I am building nnpack from sources (Debian Jessie / gcc 4.9.2) as follows:

git clone https://github.com/Maratyszcza/NNPACK.git .
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON ..
make install

I am getting following error:

[ 23%] Building C object CMakeFiles/nnpack.dir/src/convolution-inference.c.o
In file included from /opt/nnpack/src/convolution-inference.c:11:0:
/opt/nnpack/include/nnpack/system.h: In function 'read_timer':
/opt/nnpack/include/nnpack/system.h:21:18: error: storage size of 'ts' isn't known
  struct timespec ts;
                  ^
/opt/nnpack/include/nnpack/system.h:22:2: warning: implicit declaration of function 'clock_gettime' [-Wimplicit-function-declaration]
  int result = clock_gettime(CLOCK_MONOTONIC, &ts);
  ^
/opt/nnpack/include/nnpack/system.h:22:29: error: 'CLOCK_MONOTONIC' undeclared (first use in this function)
  int result = clock_gettime(CLOCK_MONOTONIC, &ts);
                             ^
/opt/nnpack/include/nnpack/system.h:22:29: note: each undeclared identifier is reported only once for each function it appears in
/opt/nnpack/include/nnpack/system.h: In function 'allocate_memory':
/opt/nnpack/include/nnpack/system.h:99:86: error: 'MAP_ANONYMOUS' undeclared (first use in this function)
   void* memory_block = mmap(NULL, memory_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE | MAP_HUGETLB, -1, 0);
                                                                                      ^
/opt/nnpack/include/nnpack/system.h:99:102: error: 'MAP_POPULATE' undeclared (first use in this function)
   void* memory_block = mmap(NULL, memory_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE | MAP_HUGETLB, -1, 0);
                                                                                                      ^
/opt/nnpack/include/nnpack/system.h:99:117: error: 'MAP_HUGETLB' undeclared (first use in this function)
   void* memory_block = mmap(NULL, memory_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE | MAP_HUGETLB, -1, 0);
                                                                                                                     ^
CMakeFiles/nnpack.dir/build.make:208: recipe for target 'CMakeFiles/nnpack.dir/src/convolution-inference.c.o' failed

I have been able to build nnpack multiple times until few days ago.

klshrinidhi commented 6 years ago

I just checked that the commit 1f37f806f9a2856a6f9c03f845894b1157f017de made my build fail. The previous commit builds successfully. Hope this helps. 👍

Maratyszcza commented 6 years ago

Couldn't reproduce it on Ubuntu 14.04 LTS. Are the declarations of clock_gettime and other functions/structures in the error message guarded by some #ifdef in the system headers?

ostrokach commented 6 years ago

I am having similar errors building on CentOS 6 using devtoolset-2-toolchain. You can see the build log here.

This StackOverflow question seems to be related: Ubuntu Linux C++ error: undefined reference to 'clock_gettime' and 'clock_settime'.