Fail to install torch for source
Labels: module: build, triaged

### 🐛 Describe the bug

Hi, I try to install PyTorch from source, but I met some error.

Here is the env:
PyTorch-1.11.0 + CUDA10.2 + cudnn7.6.5 + GCC6.5 + CMAKE 3.22.1 + Ubuntu 14.04
Note: I set `CC` and `CXX` to `gcc-6` and `g++-6`. It seems the `collect_env.py` doesn't collect a right gcc version.

I follow the instructions from the README doc, that is
```
conda install astunparse numpy ninja pyyaml setuptools cmake cffi typing_extensions future six requests dataclasses
conda install mkl mkl-include
conda install -c pytorch magma-cuda102

git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
# if you are updating an existing checkout
git submodule sync
git submodule update --init --recursive

export CMAKE_PREFIX_PATH=${CONDA_PREFIX:-"$(dirname $(which conda))/../"}
python setup.py install 
```

Log sumary:
```
[1/1783] Linking CXX executable bin/c10_Device_test
FAILED: bin/c10_Device_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_Device_test.dir/core/Device_test.cpp.o -o bin/c10_Device_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[2/1783] Linking CXX executable bin/c10_TypeList_test
[3/1783] Linking CXX executable bin/c10_Half_test
[4/1783] Linking CXX executable bin/c10_Array_test
[5/1783] Linking CXX executable bin/c10_ConstexprCrc_test
[6/1783] Linking CXX executable bin/c10_TypeIndex_test
[7/1783] Linking CXX executable bin/c10_Bitset_test
[8/1783] Linking CXX executable bin/c10_InlineStreamGuard_test
FAILED: bin/c10_InlineStreamGuard_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_InlineStreamGuard_test.dir/core/impl/InlineStreamGuard_test.cpp.o -o bin/c10_InlineStreamGuard_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[9/1783] Linking CXX executable bin/c10_C++17_test
[10/1783] Linking CXX executable bin/c10_LeftRight_test
FAILED: bin/c10_LeftRight_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o -o bin/c10_LeftRight_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<LeftRightTest_readsCanBeConcurrent_Test::TestBody()::{lambda()#1} ()> >::~_State_impl()':
LeftRight_test.cpp:(.text+0x5f): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<LeftRightTest_readsCanBeConcurrent_Test::TestBody()::{lambda()#2} ()> >::~_State_impl()':
LeftRight_test.cpp:(.text+0x9f): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<LeftRightTest_writesCanBeConcurrentWithReads_readThenWrite_Test::TestBody()::{lambda()#1} ()> >::~_State_impl()':
LeftRight_test.cpp:(.text+0xdf): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<LeftRightTest_writesCanBeConcurrentWithReads_readThenWrite_Test::TestBody()::{lambda()#2} ()> >::~_State_impl()':
LeftRight_test.cpp:(.text+0x11f): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<LeftRightTest_writesCanBeConcurrentWithReads_writeThenRead_Test::TestBody()::{lambda()#1} ()> >::~_State_impl()':
LeftRight_test.cpp:(.text+0x15f): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o:LeftRight_test.cpp:(.text+0x19f): more undefined references to `std::thread::_State::~_State()' follow
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `LeftRightTest_readsCanBeConcurrent_Test::TestBody()':
LeftRight_test.cpp:(.text+0x888): undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
LeftRight_test.cpp:(.text+0x8d7): undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `LeftRightTest_writesCanBeConcurrentWithReads_readThenWrite_Test::TestBody()':
LeftRight_test.cpp:(.text+0xab2): undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
LeftRight_test.cpp:(.text+0xb05): undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `LeftRightTest_writesCanBeConcurrentWithReads_writeThenRead_Test::TestBody()':
LeftRight_test.cpp:(.text+0xce2): undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o:LeftRight_test.cpp:(.text+0xd35): more undefined references to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())' follow
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<LeftRightTest_readsCanBeConcurrent_Test::TestBody()::{lambda()#1} ()> >::~_State_impl()':
LeftRight_test.cpp:(.text+0x4b): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<LeftRightTest_readsCanBeConcurrent_Test::TestBody()::{lambda()#2} ()> >::~_State_impl()':
LeftRight_test.cpp:(.text+0x8b): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<LeftRightTest_writesCanBeConcurrentWithReads_readThenWrite_Test::TestBody()::{lambda()#1} ()> >::~_State_impl()':
LeftRight_test.cpp:(.text+0xcb): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<LeftRightTest_writesCanBeConcurrentWithReads_readThenWrite_Test::TestBody()::{lambda()#2} ()> >::~_State_impl()':
LeftRight_test.cpp:(.text+0x10b): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<LeftRightTest_writesCanBeConcurrentWithReads_writeThenRead_Test::TestBody()::{lambda()#1} ()> >::~_State_impl()':
LeftRight_test.cpp:(.text+0x14b): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o:LeftRight_test.cpp:(.text+0x18b): more undefined references to `std::thread::_State::~_State()' follow
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o:(.data.rel.ro+0x28): undefined reference to `typeinfo for std::thread::_State'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o:(.data.rel.ro+0x40): undefined reference to `typeinfo for std::thread::_State'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o:(.data.rel.ro+0x58): undefined reference to `typeinfo for std::thread::_State'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o:(.data.rel.ro+0x70): undefined reference to `typeinfo for std::thread::_State'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o:(.data.rel.ro+0x88): undefined reference to `typeinfo for std::thread::_State'
c10/test/CMakeFiles/c10_LeftRight_test.dir/util/LeftRight_test.cpp.o:(.data.rel.ro+0xa0): more undefined references to `typeinfo for std::thread::_State' follow
collect2: error: ld returned 1 exit status
[11/1783] Linking CXX executable bin/c10_DeviceGuard_test
FAILED: bin/c10_DeviceGuard_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_DeviceGuard_test.dir/core/DeviceGuard_test.cpp.o -o bin/c10_DeviceGuard_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[12/1783] Linking CXX executable bin/c10_accumulate_test
FAILED: bin/c10_accumulate_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_accumulate_test.dir/util/accumulate_test.cpp.o -o bin/c10_accumulate_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[13/1783] Linking CXX executable bin/c10_DispatchKeySet_test
FAILED: bin/c10_DispatchKeySet_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_DispatchKeySet_test.dir/core/DispatchKeySet_test.cpp.o -o bin/c10_DispatchKeySet_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[14/1783] Linking CXX executable bin/c10_ordered_preserving_dict_test
FAILED: bin/c10_ordered_preserving_dict_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_ordered_preserving_dict_test.dir/util/ordered_preserving_dict_test.cpp.o -o bin/c10_ordered_preserving_dict_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[15/1783] Linking CXX executable bin/c10_flags_test
FAILED: bin/c10_flags_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_flags_test.dir/util/flags_test.cpp.o -o bin/c10_flags_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[16/1783] Linking CXX executable bin/c10_complex_math_test
[17/1783] Linking CXX executable bin/c10_bfloat16_test
[18/1783] Linking CXX executable bin/c10_SizesAndStrides_test
FAILED: bin/c10_SizesAndStrides_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_SizesAndStrides_test.dir/core/impl/SizesAndStrides_test.cpp.o -o bin/c10_SizesAndStrides_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[19/1783] Linking CXX executable bin/c10_TypeTraits_test
[20/1783] Linking CXX executable bin/c10_complex_test
[21/1783] Linking CXX executable bin/c10_irange_test
[22/1783] Linking CXX executable bin/c10_Metaprogramming_test
[23/1783] Linking CXX static library lib/libfbgemm.a
[24/1783] Linking CXX executable bin/c10_either_test
[25/1783] Linking CXX executable bin/c10_intrusive_ptr_test
[26/1783] Linking CXX executable bin/c10_exception_test
FAILED: bin/c10_exception_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_exception_test.dir/util/exception_test.cpp.o -o bin/c10_exception_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[27/1783] Linking CXX executable bin/c10_SmallVectorTest
FAILED: bin/c10_SmallVectorTest 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_SmallVectorTest.dir/util/SmallVectorTest.cpp.o -o bin/c10_SmallVectorTest  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[28/1783] Linking CXX executable bin/c10_logging_test
FAILED: bin/c10_logging_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_logging_test.dir/util/logging_test.cpp.o -o bin/c10_logging_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[29/1783] Linking CXX executable bin/c10_InlineDeviceGuard_test
FAILED: bin/c10_InlineDeviceGuard_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_InlineDeviceGuard_test.dir/core/impl/InlineDeviceGuard_test.cpp.o -o bin/c10_InlineDeviceGuard_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
lib/libc10.so: undefined reference to `typeinfo for std::thread::_State'
lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
lib/libc10.so: undefined reference to `std::thread::_State::~_State()'
collect2: error: ld returned 1 exit status
[30/1783] Linking CXX executable bin/c10_ThreadLocal_test
FAILED: bin/c10_ThreadLocal_test 
: && /usr/bin/g++-6 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -O3 -DNDEBUG -DNDEBUG -rdynamic -L/usr/lib/openmpi/lib -pthread c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o -o bin/c10_ThreadLocal_test  -Wl,-rpath,/home/duanjiangfei/pytorch/build/lib:  lib/libc10.so  lib/libgmock.a  lib/libgtest.a  lib/libgtest_main.a  lib/libgtest.a  -pthread && :
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<(anonymous namespace)::ThreadLocalTest_TestThreadWithLocalScopeVar_Test::TestBody()::{lambda()#2} ()> >::~_State_impl()':
ThreadLocal_test.cpp:(.text+0x85f): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<(anonymous namespace)::ThreadLocalTest_TestThreadWithGlobalScopeVar_Test::TestBody()::{lambda()#1} ()> >::~_State_impl()':
ThreadLocal_test.cpp:(.text+0x89f): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<(anonymous namespace)::ThreadLocalTest_TestObjectsAreReleased_Test::TestBody()::{lambda()#2} ()> >::~_State_impl()':
ThreadLocal_test.cpp:(.text+0x8df): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<(anonymous namespace)::ThreadLocalTest_TestObjectsAreReleasedByNonstaticThreadLocal_Test::TestBody()::{lambda()#1} ()> >::~_State_impl()':
ThreadLocal_test.cpp:(.text+0x91f): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `(anonymous namespace)::ThreadLocalTest_TestThreadWithLocalScopeVar_Test::TestBody()':
ThreadLocal_test.cpp:(.text+0x2aae): undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `(anonymous namespace)::ThreadLocalTest_TestThreadWithGlobalScopeVar_Test::TestBody()':
ThreadLocal_test.cpp:(.text+0x2e7c): undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `(anonymous namespace)::ThreadLocalTest_TestObjectsAreReleased_Test::TestBody()':
ThreadLocal_test.cpp:(.text+0x4d41): undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `(anonymous namespace)::ThreadLocalTest_TestObjectsAreReleasedByNonstaticThreadLocal_Test::TestBody()':
ThreadLocal_test.cpp:(.text+0x5202): undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<(anonymous namespace)::ThreadLocalTest_TestThreadWithLocalScopeVar_Test::TestBody()::{lambda()#2} ()> >::~_State_impl()':
ThreadLocal_test.cpp:(.text+0x84b): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<(anonymous namespace)::ThreadLocalTest_TestThreadWithGlobalScopeVar_Test::TestBody()::{lambda()#1} ()> >::~_State_impl()':
ThreadLocal_test.cpp:(.text+0x88b): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<(anonymous namespace)::ThreadLocalTest_TestObjectsAreReleased_Test::TestBody()::{lambda()#2} ()> >::~_State_impl()':
ThreadLocal_test.cpp:(.text+0x8cb): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o: In function `std::thread::_State_impl<std::_Bind_simple<(anonymous namespace)::ThreadLocalTest_TestObjectsAreReleasedByNonstaticThreadLocal_Test::TestBody()::{lambda()#1} ()> >::~_State_impl()':
ThreadLocal_test.cpp:(.text+0x90b): undefined reference to `std::thread::_State::~_State()'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o:(.data.rel.ro+0x250): undefined reference to `typeinfo for std::thread::_State'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o:(.data.rel.ro+0x268): undefined reference to `typeinfo for std::thread::_State'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o:(.data.rel.ro+0x280): undefined reference to `typeinfo for std::thread::_State'
c10/test/CMakeFiles/c10_ThreadLocal_test.dir/util/ThreadLocal_test.cpp.o:(.data.rel.ro+0x298): undefined reference to `typeinfo for std::thread::_State'
collect2: error: ld returned 1 exit status
[31/1783] Linking CXX static library lib/libdnnl.a
[32/1783] Building NVCC (Device) object third_party/gloo/gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda_private.cu.o
[33/1783] Building NVCC (Device) object third_party/gloo/gloo/CMakeFiles/gloo_cuda.dir/gloo_cuda_generated_cuda.cu.o
[34/1783] Building NVCC (Device) object third_party/gloo/gloo/CMakeFiles/gloo_cuda.dir/nccl/gloo_cuda_generated_nccl.cu.o
ninja: build stopped: subcommand failed.
Building wheel torch-1.11.0a0+gitbc2c6ed
-- Building version 1.11.0a0+gitbc2c6ed
cmake --build . --target install --config Release
```

Here is the detailed error log:
https://gist.github.com/JF-D/dc2507af41343e78478261ee10c68aa8


### Versions

```
Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: Ubuntu 14.04.6 LTS (x86_64)
GCC version: (Ubuntu 4.8.4-2ubuntu1~14.04.4) 4.8.4
Clang version: Could not collect
CMake version: version 3.22.1
Libc version: glibc-2.19

Python version: 3.8.0 (default, Nov  6 2019, 21:49:08)  [GCC 7.3.0] (64-bit runtime)
Python platform: Linux-4.15.0-041500-generic-x86_64-with-glibc2.10
Is CUDA available: N/A
CUDA runtime version: 10.2.89
GPU models and configuration:
GPU 0: GeForce GTX TITAN X
GPU 1: GeForce GTX TITAN X
GPU 2: GeForce GTX TITAN X
GPU 3: GeForce GTX TITAN X
GPU 4: GeForce GTX TITAN X
GPU 5: GeForce GTX TITAN X
GPU 6: GeForce GTX TITAN X
GPU 7: GeForce GTX TITAN X

Nvidia driver version: 440.44
cuDNN version: /usr/local/cuda-10.2/targets/x86_64-linux/lib/libcudnn.so.7
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

Versions of relevant libraries:
[pip3] numpy==1.22.3
[conda] blas                      1.0                         mkl
[conda] magma-cuda102             2.5.2                         1    pytorch
[conda] mkl                       2021.4.0           h06a4308_640
[conda] mkl-include               2022.0.1           h06a4308_117
[conda] mkl-service               2.4.0            py38h7f8727e_0
[conda] mkl_fft                   1.3.1            py38hd3c417c_0
[conda] mkl_random                1.2.2            py38h51133e4_0
[conda] numpy                     1.22.3                   pypi_0    pypi
```

cc @malfet @seemethere