pytorch / glow

Compiler for Neural Network hardware accelerators

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CMake error related to pthread and stdc++

guanrenyang opened this issue · comments

After executing cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug ../glow, I encountered cmake errors related to pthread and stdc++.

I guess they are due to the version of clang, but I haved done all steps in readme file.

Here is the full CMakeError.md

Performing C++ SOURCE FILE Test HAS_W_NO_PSABI failed with the following output:
Change Dir: /home/renyang/build_Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_351e9"
[1/2] Building CXX object CMakeFiles/cmTC_351e9.dir/src.cxx.o
warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]
1 warning generated.
[2/2] Linking CXX executable cmTC_351e9

Source file was:
int main() { return 0; }
Determining if the pthread_create exist failed with the following output:
Change Dir: /home/renyang/build_Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_cdf35"
[1/2] Building C object CMakeFiles/cmTC_cdf35.dir/CheckSymbolExists.c.o
[2/2] Linking C executable cmTC_cdf35
FAILED: cmTC_cdf35 
: && /usr/bin/cc   -rdynamic CMakeFiles/cmTC_cdf35.dir/CheckSymbolExists.c.o  -o cmTC_cdf35   && :
CMakeFiles/cmTC_cdf35.dir/CheckSymbolExists.c.o: In function `main':
CheckSymbolExists.c:(.text+0x7): undefined reference to `pthread_create'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

File /home/renyang/build_Debug/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 ASN1_TIME_diff exists failed with the following output:
Change Dir: /home/renyang/build_Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_b7e05"
[1/2] Building C object CMakeFiles/cmTC_b7e05.dir/CheckFunctionExists.c.o
FAILED: CMakeFiles/cmTC_b7e05.dir/CheckFunctionExists.c.o 
/usr/bin/cc -DGFLAGS_IS_A_DLL=0 -D_GNU_SOURCE  -DCHECK_FUNCTION_EXISTS=ASN1_TIME_diff  -std=c++14 -fPIE   -pthread -o CMakeFiles/cmTC_b7e05.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-3.10/Modules/CheckFunctionExists.c
error: invalid argument '-std=c++14' not allowed with 'C'
ninja: build stopped: subcommand failed.


Determining if the BZ2_bzCompressInit exist failed with the following output:
Change Dir: /home/renyang/build_Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_9a9bb"
[1/2] Building C object CMakeFiles/cmTC_9a9bb.dir/CheckSymbolExists.c.o
FAILED: CMakeFiles/cmTC_9a9bb.dir/CheckSymbolExists.c.o 
/usr/bin/cc -D_GNU_SOURCE  -std=c++14 -fPIE -o CMakeFiles/cmTC_9a9bb.dir/CheckSymbolExists.c.o   -c CheckSymbolExists.c
error: invalid argument '-std=c++14' not allowed with 'C'
ninja: build stopped: subcommand failed.

File /home/renyang/build_Debug/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
/* */
#include <bzlib.h>

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

Performing C++ SOURCE FILE Test FOLLY_CPP_ATOMIC_BUILTIN failed with the following output:
Change Dir: /home/renyang/build_Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_7cee2"
[1/2] Building CXX object CMakeFiles/cmTC_7cee2.dir/src.cxx.o
[2/2] Linking CXX executable cmTC_7cee2
FAILED: cmTC_7cee2 
: && /usr/bin/c++  -DFOLLY_CPP_ATOMIC_BUILTIN  -std=c++14  -rdynamic CMakeFiles/cmTC_7cee2.dir/src.cxx.o  -o cmTC_7cee2  /usr/lib/x86_64-linux-gnu/libgflags.so.2.2.1 /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/libcrypto.so -ldl -pthread -lpthread && :
CMakeFiles/cmTC_7cee2.dir/src.cxx.o: In function `std::atomic<main::Test>::is_lock_free() const':
src.cxx:(.text+0x49): undefined reference to `__atomic_is_lock_free'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Source file was:

  #include <atomic>
  int main(int argc, char** argv) {
    struct Test { int val; };
    std::atomic<Test> s;
    return static_cast<int>(s.is_lock_free());
  }
Performing C++ SOURCE FILE Test COMPILER_HAS_W_SHADOW_LOCAL failed with the following output:
Change Dir: /home/renyang/build_Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_4c759"
[1/2] Building CXX object CMakeFiles/cmTC_4c759.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_4c759.dir/src.cxx.o 
/usr/bin/c++  -DGFLAGS_IS_A_DLL=0  -DCOMPILER_HAS_W_SHADOW_LOCAL  -std=c++14 -Werror=unknown-warning-option -fPIE   -Wshadow-local -pthread -o CMakeFiles/cmTC_4c759.dir/src.cxx.o -c src.cxx
error: unknown warning option '-Wshadow-local' [-Werror,-Wunknown-warning-option]
ninja: build stopped: subcommand failed.

Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test COMPILER_HAS_W_SHADOW_COMPATIBLE_LOCAL failed with the following output:
Change Dir: /home/renyang/build_Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_d39b3"
[1/2] Building CXX object CMakeFiles/cmTC_d39b3.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_d39b3.dir/src.cxx.o 
/usr/bin/c++  -DGFLAGS_IS_A_DLL=0  -DCOMPILER_HAS_W_SHADOW_COMPATIBLE_LOCAL  -std=c++14 -Werror=unknown-warning-option -fPIE   -Wshadow-compatible-local -pthread -o CMakeFiles/cmTC_d39b3.dir/src.cxx.o -c src.cxx
error: unknown warning option '-Wshadow-compatible-local'; did you mean '-Wshadow-uncaptured-local'? [-Werror,-Wunknown-warning-option]
ninja: build stopped: subcommand failed.

Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test HAVE_INT128_TRAITS failed with the following output:
Change Dir: /home/renyang/build_Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_12fdb"
[1/2] Building CXX object CMakeFiles/cmTC_12fdb.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_12fdb.dir/src.cxx.o 
/usr/bin/c++  -DGFLAGS_IS_A_DLL=0 -D_GNU_SOURCE  -DHAVE_INT128_TRAITS  -std=c++14 -Werror=unknown-warning-option -fPIE   -pthread -o CMakeFiles/cmTC_12fdb.dir/src.cxx.o -c src.cxx
In file included from src.cxx:2:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/functional:49:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/stl_function.h:60:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/move.h:54:
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/type_traits:1921:24: error: implicit instantiation of undefined template 'std::__make_signed_selector<unsigned __int128, false, false>'
    { typedef typename __make_signed_selector<_Tp>::__type type; };
                       ^
src.cxx:6:29: note: in instantiation of template class 'std::make_signed<unsigned __int128>' requested here
      ::std::is_same<::std::make_signed<unsigned __int128>::type,
                            ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/type_traits:1893:11: note: template is declared here
    class __make_signed_selector;
          ^
src.cxx:10:16: error: call to implicitly-deleted default constructor of '::std::hash<__int128>'
        sizeof(::std::hash<__int128>{}(0)) > 0,         "std::hash<__int128> is disabled.");
               ^                    ~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/functional_hash.h:101:19: note: default constructor of 'hash<__int128>' is implicitly deleted because base class '__hash_enum<__int128>' has no default constructor
    struct hash : __hash_enum<_Tp>
                  ^
2 errors generated.
ninja: build stopped: subcommand failed.

Source file was:

    #include <functional>
    #include <type_traits>
    #include <utility>
    static_assert(
      ::std::is_same<::std::make_signed<unsigned __int128>::type,
                     __int128>::value,
      "signed form of 'unsigned __uint128' must be '__int128'.");
    static_assert(
        sizeof(::std::hash<__int128>{}(0)) > 0,         "std::hash<__int128> is disabled.");
    int main() { return 0; }
Performing C++ SOURCE FILE Test FOLLY_USE_LIBCPP failed with the following output:
Change Dir: /home/renyang/build_Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_b2b66"
[1/2] Building CXX object CMakeFiles/cmTC_b2b66.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_b2b66.dir/src.cxx.o 
/usr/bin/c++  -DGFLAGS_IS_A_DLL=0 -D_GNU_SOURCE  -DFOLLY_USE_LIBCPP  -std=c++14 -Werror=unknown-warning-option -fPIE   -pthread -o CMakeFiles/cmTC_b2b66.dir/src.cxx.o -c src.cxx
src.cxx:4:4: error: No libc++
  #error No libc++
   ^
1 error generated.
ninja: build stopped: subcommand failed.

Source file was:

  #include <type_traits>
  #if !_LIBCPP_VERSION
  #error No libc++
  #endif
  int main() { return 0; }
Performing C++ SOURCE FILE Test HAVE_CXX_FLAG_WD654 failed with the following output:
Change Dir: /home/renyang/build_Debug/CMakeFiles/CMakeTmp

Run Build Command:"/usr/bin/ninja" "cmTC_7d3e3"
[1/2] Building CXX object CMakeFiles/cmTC_7d3e3.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_7d3e3.dir/src.cxx.o 
/usr/bin/c++    -Wall -Wnon-virtual-dtor  -std=c++11  -Wall  -Wextra  -Wshadow  -pedantic  -pedantic-errors  -Wshorten-64-to-32  -fstrict-aliasing  -Wno-deprecated-declarations  -Wstrict-aliasing -DHAVE_CXX_FLAG_WD654  -wd654 -fPIE   -wd654 -o CMakeFiles/cmTC_7d3e3.dir/src.cxx.o -c src.cxx
clang: error: unknown argument: '-wd654'
clang: error: unknown argument: '-wd654'
ninja: build stopped: subcommand failed.

Source file was:
int main() { return 0; }

I encountered the same issue when building with Docker from ubuntu:18.04

Has this been resolved?