Repository: pytorch
Issue: Error installing on source: "src.cxx:1:10: fatal error: glog/stl_logging.h: No such file or directory"
Labels: module: build,triaged

## 🐛 Bug

I tried to build Pytorch from source. The build failed immediately with C compiler errors.

## To Reproduce

Follow the [README instructions](https://github.com/pytorch/pytorch#from-source).

The CMakeError.log is as follows.

```
Performing C++ SOURCE FILE Test CAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING failed with the following output:
Change Dir: /home/wmcneill/src/pytorch/build/CMakeFiles/CMakeTmp

Run Build Command(s):/home/wmcneill/anaconda3/envs/layoutlm/bin/ninja cmTC_43213 && [1/2] Building CXX object CMakeFiles/cmTC_43213.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_43213.dir/src.cxx.o 
/home/wmcneill/anaconda3/envs/layoutlm/bin/c++   -DCAFFE2_NEED_TO_TURN_OFF_DEPRECATION_WARNING -std=c++14 -o CMakeFiles/cmTC_43213.dir/src.cxx.o -c src.cxx
src.cxx:1:10: fatal error: glog/stl_logging.h: No such file or directory
 #include <glog/stl_logging.h>
          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.


Source file was:
#include <glog/stl_logging.h>
    int main(int argc, char** argv) {
      return 0;
    }
Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/wmcneill/src/pytorch/build/CMakeFiles/CMakeTmp

Run Build Command(s):/home/wmcneill/anaconda3/envs/layoutlm/bin/ninja cmTC_c7774 && [1/2] Building C object CMakeFiles/cmTC_c7774.dir/src.c.o
[2/2] Linking C executable cmTC_c7774
FAILED: cmTC_c7774 
: && /home/wmcneill/anaconda3/envs/layoutlm/bin/cc -DCMAKE_HAVE_LIBC_PTHREAD -rdynamic CMakeFiles/cmTC_c7774.dir/src.c.o -o cmTC_c7774   && :
CMakeFiles/cmTC_c7774.dir/src.c.o: In function `main':
src.c:(.text+0x2f): undefined reference to `pthread_create'
src.c:(.text+0x3b): undefined reference to `pthread_detach'
src.c:(.text+0x47): undefined reference to `pthread_cancel'
src.c:(.text+0x58): undefined reference to `pthread_join'
src.c:(.text+0x6c): undefined reference to `pthread_atfork'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.


Source file was:
#include <pthread.h>

void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Performing C SOURCE FILE Test NNPACK_ARCH_IS_X86_32 failed with the following output:
Change Dir: /home/wmcneill/src/pytorch/build/CMakeFiles/CMakeTmp

Run Build Command(s):/home/wmcneill/anaconda3/envs/layoutlm/bin/ninja cmTC_6f7a1 && [1/2] Building C object CMakeFiles/cmTC_6f7a1.dir/src.c.o
FAILED: CMakeFiles/cmTC_6f7a1.dir/src.c.o 
/home/wmcneill/anaconda3/envs/layoutlm/bin/cc   -DNNPACK_ARCH_IS_X86_32 -o CMakeFiles/cmTC_6f7a1.dir/src.c.o -c src.c
src.c:3:10: error: #error AVX only on x86_64
         #error AVX only on x86_64
          ^~~~~
ninja: build stopped: subcommand failed.


Source file was:

      #if ! (defined(__i386) || defined(_M_IX86))
        #error AVX only on x86_64
      #endif
      int main() {
        return 0;
      }
Performing C++ SOURCE FILE Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32 failed with the following output:
Change Dir: /home/wmcneill/src/pytorch/build/CMakeFiles/CMakeTmp

Run Build Command(s):/home/wmcneill/anaconda3/envs/layoutlm/bin/ninja cmTC_b8470 && [1/2] Building CXX object CMakeFiles/cmTC_b8470.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_b8470.dir/src.cxx.o 
/home/wmcneill/anaconda3/envs/layoutlm/bin/c++   -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL  -std=c++11  -Wall  -Wextra  -Wshadow  -pedantic  -pedantic-errors -DHAVE_CXX_FLAG_WSHORTEN_64_TO_32  -Wshorten-64-to-32   -Wshorten-64-to-32 -o CMakeFiles/cmTC_b8470.dir/src.cxx.o -c src.cxx
c++: error: unrecognized command line option '-Wshorten-64-to-32'
c++: error: unrecognized command line option '-Wshorten-64-to-32'
ninja: build stopped: subcommand failed.


Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test HAVE_CXX_FLAG_WD654 failed with the following output:
Change Dir: /home/wmcneill/src/pytorch/build/CMakeFiles/CMakeTmp

Run Build Command(s):/home/wmcneill/anaconda3/envs/layoutlm/bin/ninja cmTC_37d00 && [1/2] Building CXX object CMakeFiles/cmTC_37d00.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_37d00.dir/src.cxx.o 
/home/wmcneill/anaconda3/envs/layoutlm/bin/c++   -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL  -std=c++11  -Wall  -Wextra  -Wshadow  -pedantic  -pedantic-errors  -Wfloat-equal  -fstrict-aliasing  -Wno-deprecated-declarations  -Wstrict-aliasing -DHAVE_CXX_FLAG_WD654  -wd654   -wd654 -o CMakeFiles/cmTC_37d00.dir/src.cxx.o -c src.cxx
c++: error: unrecognized command line option '-wd654'
c++: error: unrecognized command line option '-wd654'
ninja: build stopped: subcommand failed.


Source file was:
int main() { return 0; }
Performing C++ SOURCE FILE Test HAVE_CXX_FLAG_WTHREAD_SAFETY failed with the following output:
Change Dir: /home/wmcneill/src/pytorch/build/CMakeFiles/CMakeTmp

Run Build Command(s):/home/wmcneill/anaconda3/envs/layoutlm/bin/ninja cmTC_db35a && [1/2] Building CXX object CMakeFiles/cmTC_db35a.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_db35a.dir/src.cxx.o 
/home/wmcneill/anaconda3/envs/layoutlm/bin/c++   -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL  -std=c++11  -Wall  -Wextra  -Wshadow  -pedantic  -pedantic-errors  -Wfloat-equal  -fstrict-aliasing  -Wno-deprecated-declarations  -Wstrict-aliasing -DHAVE_CXX_FLAG_WTHREAD_SAFETY  -Wthread-safety   -Wthread-safety -o CMakeFiles/cmTC_db35a.dir/src.cxx.o -c src.cxx
c++: error: unrecognized command line option '-Wthread-safety'; did you mean '-fthread-jumps'?
c++: error: unrecognized command line option '-Wthread-safety'; did you mean '-fthread-jumps'?
ninja: build stopped: subcommand failed.


Source file was:
int main() { return 0; }
```

## Expected behavior

Build and install PyTorch.

## Environment

 - PyTorch Version (e.g., 1.0): Installing from commit `acca11b89808c8d57e914057a6c0e60cb66cea46`
 - OS (e.g., Linux): CentOS Linux release 7.6.1810 (Core)
 - How you installed PyTorch (`conda`, `pip`, source): source
 - Build command you used (if compiling from source): `python setup.py install`
 - Python version: 3.7.8
 - CUDA/cuDNN version: 10.1.168
 - GPU models and configuration: NVIDIA-SMI 450.57       Driver Version: 450.57


cc @malfet @seemethere @walterddr