Repository: pytorch
Issue: _run_ninja_build failing with clang
Labels: module: build,triaged

### 🐛 Describe the bug

test_timer_tiny_fast_snippet, test_cpp_timer, and test_collect_cpp_callgrind (from test/benchmark_utils/test_benchmark_utils.py) are failing on clang builds in CI:

```
======================================================================
ERROR [0.093s]: test_collect_cpp_callgrind (__main__.TestBenchmarkUtils)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1795, in _run_ninja_build
    env=env)
  File "/opt/conda/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v', '-j', '6']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/site-packages/torch/testing/_internal/common_utils.py", line 1061, in wrapper
    fn(*args, **kwargs)
  File "benchmark_utils/test_benchmark_utils.py", line 559, in test_collect_cpp_callgrind
    for _ in range(3)
  File "benchmark_utils/test_benchmark_utils.py", line 559, in <listcomp>
    for _ in range(3)
  File "/opt/conda/lib/python3.7/site-packages/torch/utils/benchmark/utils/timer.py", line 483, in collect_callgrind
    self._timeit(1)
  File "/opt/conda/lib/python3.7/site-packages/torch/utils/benchmark/utils/timer.py", line 256, in _timeit
    return max(self._timer.timeit(number), 1e-9)
  File "/opt/conda/lib/python3.7/site-packages/torch/utils/benchmark/utils/timer.py", line 61, in timeit
    global_setup=self._global_setup,
  File "/opt/conda/lib/python3.7/site-packages/torch/utils/benchmark/utils/cpp_jit.py", line 156, in compile_timeit_template
    module = _compile_template(stmt=stmt, setup=setup, global_setup=global_setup, src=src, is_standalone=False)
  File "/opt/conda/lib/python3.7/site-packages/torch/utils/benchmark/utils/cpp_jit.py", line 147, in _compile_template
    is_standalone=is_standalone,
  File "/opt/conda/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1205, in load
    keep_intermediates=keep_intermediates)
  File "/opt/conda/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1416, in _jit_compile
    is_standalone=is_standalone)
  File "/opt/conda/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1521, in _write_ninja_file_and_build_library
    error_prefix=f"Error building extension '{name}'")
  File "/opt/conda/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1805, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error building extension 'timer_cpp_2381802786933856683': [1/2] c++ -MMD -MF timer_src.o.d -DTORCH_EXTENSION_NAME=timer_cpp_2381802786933856683 -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_clang\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1002\" -I/opt/conda/lib/python3.7/site-packages/torch/utils/benchmark/utils/valgrind_wrapper -isystem /opt/conda/lib/python3.7/site-packages/torch/include -isystem /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -isystem /opt/conda/lib/python3.7/site-packages/torch/include/TH -isystem /opt/conda/lib/python3.7/site-packages/torch/include/THC -isystem /opt/conda/include/python3.7m -D_GLIBCXX_USE_CXX11_ABI=1 -fPIC -std=c++14 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp=libomp -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -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-range-loop-analysis -Wno-pass-failed -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-typedef-redefinition -Wno-unknown-warning-option -Wno-unused-private-field -Wno-inconsistent-missing-override -Wno-aligned-allocation-unavailable -Wno-c++14-extensions -Wno-constexpr-not-const -Wno-missing-braces -Qunused-arguments -fcolor-diagnostics -Werror -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -g -c /tmp/benchmark_utils_jit_build__1647557193__0c7ff896-7a57-4e2c-a00f-a1e693e2fdc8/timer_cpp_2381802786933856683/timer_src.cpp -o timer_src.o 
FAILED: timer_src.o 
c++ -MMD -MF timer_src.o.d -DTORCH_EXTENSION_NAME=timer_cpp_2381802786933856683 -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_clang\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1002\" -I/opt/conda/lib/python3.7/site-packages/torch/utils/benchmark/utils/valgrind_wrapper -isystem /opt/conda/lib/python3.7/site-packages/torch/include -isystem /opt/conda/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -isystem /opt/conda/lib/python3.7/site-packages/torch/include/TH -isystem /opt/conda/lib/python3.7/site-packages/torch/include/THC -isystem /opt/conda/include/python3.7m -D_GLIBCXX_USE_CXX11_ABI=1 -fPIC -std=c++14 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp=libomp -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -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-range-loop-analysis -Wno-pass-failed -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-typedef-redefinition -Wno-unknown-warning-option -Wno-unused-private-field -Wno-inconsistent-missing-override -Wno-aligned-allocation-unavailable -Wno-c++14-extensions -Wno-constexpr-not-const -Wno-missing-braces -Qunused-arguments -fcolor-diagnostics -Werror -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -g -c /tmp/benchmark_utils_jit_build__1647557193__0c7ff896-7a57-4e2c-a00f-a1e693e2fdc8/timer_cpp_2381802786933856683/timer_src.cpp -o timer_src.o 
c++: error: unrecognized command line option ‘-fopenmp=libomp’; did you mean ‘-fopenmp-simd’?
c++: error: unrecognized command line option ‘-Qunused-arguments’; did you mean ‘-Wunused-parameter’?
c++: error: unrecognized command line option ‘-fcolor-diagnostics’
ninja: build stopped: subcommand failed.
```

### Versions

with clang, see https://github.com/pytorch/pytorch/runs/5593154288?check_suite_focus=true

cc @malfet @seemethere