Repository: pytorch
Issue: c++: error: unrecognized command line option '-Wthread-safety'
Labels: module: build,triaged

## 🐛 Bug

Attempting to build pytorch on RHEL7 using gcc 9.2.0  Get error
Run Build Command(s):/foo/miniconda3/bin/ninja cmTC_d3507 
[1/2] Building CXX object CMakeFiles/cmTC_d3507.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_d3507.dir/src.cxx.o 
/foo/gcc/9.2.0/bin/c++    -Wno-deprecated -fvisibility-inlines-hidden  -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_d3507.dir/src.cxx.o -c src.cxx
c++: error: unrecognized command line option '-Wthread-safety'
c++: error: unrecognized command line option '-Wthread-safety'
ninja: build stopped: subcommand failed.


## To Reproduce

Steps to reproduce the behavior:

1. gcc: 9.2.0
1. python: 3.7.5
1. conda: 4.8.3
1. Follow directions at https://github.com/pytorch/pytorch#from-source
1. python setup.py install

Run Build Command(s):/foo/miniconda3/bin/ninja cmTC_d3507 
[1/2] Building CXX object CMakeFiles/cmTC_d3507.dir/src.cxx.o
FAILED: CMakeFiles/cmTC_d3507.dir/src.cxx.o 
/foo/gcc/9.2.0/bin/c++    -Wno-deprecated -fvisibility-inlines-hidden  -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_d3507.dir/src.cxx.o -c src.cxx
c++: error: unrecognized command line option '-Wthread-safety'
c++: error: unrecognized command line option '-Wthread-safety'
ninja: build stopped: subcommand failed.

## Expected behavior

PyTorch to build

## Environment

Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

You can get the script and run it with:
```
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```

 - PyTorch Version (e.g., 1.0): 1.4
 - OS (e.g., Linux): Linux
 - How you installed PyTorch (`conda`, `pip`, source): source
 - Build command you used (if compiling from source): python setup.py install
 - Python version: 3.7.5
 - CUDA/cuDNN version: 10.2
 - GPU models and configuration:
 - Any other relevant information: gcc 9.2.0

Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A

OS: Red Hat Enterprise Linux Server release 7.7 (Maipo)
GCC version: (GCC) 9.2.0
CMake version: version 3.14.0

Python version: 3.7
Is CUDA available: N/A
CUDA runtime version: 10.2.89
GPU models and configuration: GPU 0: Tesla T4
Nvidia driver version: 440.33.01
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.18.1
[conda] magma-cuda102             2.5.2                         1    pytorch
[conda] mkl                       2020.0                      166  
[conda] mkl-include               2020.0                      166    conda-forge
[conda] numpy                     1.18.1           py37h8960a57_1    conda-forge

## Additional context

<!-- Add any other context about the problem here. -->