Ignore more compiler warnings, unify WERROR options (#56630)

Summary:
This adds some more compiler warnings ignores for everything that happens on a standard CPU build (CUDA builds still have a bunch of warnings so we can't turn on `-Werror` everywhere yet).
](https://our.intern.facebook.com/intern/diff/28005063/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56630

Pulled By: driazati

Reviewed By: malfet

Differential Revision: D28005063

fbshipit-source-id: 541ed415eb0470ddf7e08c22c5eb6da9db26e9a0
This commit is contained in:
davidriazati@fb.com 2021-04-29 21:18:59 -07:00 committed by Facebook GitHub Bot
parent 65968ab817
commit c44cbc63cc
6 changed files with 22 additions and 3 deletions

View file

@ -287,6 +287,7 @@ cmake_dependent_option(
USE_DEPLOY "Build embedded torch::deploy interpreter. See torch/csrc/deploy/README.md for more info." OFF
"BUILD_PYTHON" OFF)
cmake_dependent_option(USE_CCACHE "Attempt using CCache to wrap the compilation" ON "UNIX" OFF)
option(WERROR "Build with -Werror supported by the compiler" OFF)
if(USE_CCACHE)
find_program(CCACHE_PROGRAM ccache)

View file

@ -523,6 +523,9 @@ if(NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
append_filelist("libtorch_cmake_sources" LIBTORCH_CMAKE_SRCS)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# TODO: Delete this line once https://github.com/pytorch/pytorch/pull/55889 lands
set_source_files_properties(../torch/csrc/jit/serialization/export.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
# TODO: Delete this when https://github.com/pytorch/pytorch/issues/35026 is fixed
set_source_files_properties(../torch/csrc/autograd/record_function_ops.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
endif()
@ -1743,6 +1746,11 @@ if(BUILD_PYTHON)
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80947 in EmbeddingBag.cpp
set_source_files_properties(../aten/src/ATen/native/EmbeddingBag.cpp PROPERTIES COMPILE_FLAGS -Wno-attributes)
set_source_files_properties(${TORCH_SRC_DIR}/../caffe2/operators/box_with_nms_limit_op.cc PROPERTIES COMPILE_FLAGS -Wno-attributes)
endif()
# Allow different install locations for libcaffe2
# For setuptools installs (that all build Python), install libcaffe2 into
# site-packages, alongside the torch libraries. The pybind11 library needs

View file

@ -1461,6 +1461,10 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
caffe2_interface_library(onnx onnx_library)
endif()
list(APPEND Caffe2_DEPENDENCY_WHOLE_LINK_LIBS onnx_library)
# TODO: Delete this line once https://github.com/pytorch/pytorch/pull/55889 lands
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(onnx PRIVATE -Wno-deprecated-declarations)
endif()
else()
add_library(onnx SHARED IMPORTED)
find_library(ONNX_LIBRARY onnx)

View file

@ -211,7 +211,7 @@ import sysconfig
from tools.build_pytorch_libs import build_caffe2
from tools.setup_helpers.env import (IS_WINDOWS, IS_DARWIN, IS_LINUX,
check_env_flag, build_type)
build_type)
from tools.setup_helpers.cmake import CMake
from tools.generate_torch_version import get_torch_version
@ -731,8 +731,6 @@ def configure_extension_build():
# https://bugs.llvm.org/show_bug.cgi?id=21629
'-Wno-missing-braces',
]
if check_env_flag('WERROR'):
extra_compile_args.append('-Werror')
library_dirs.append(lib_path)

View file

@ -255,6 +255,11 @@ if(USE_NUMPY)
list(APPEND TORCH_PYTHON_COMPILE_DEFINITIONS USE_NUMPY)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80947 in EmbeddingBag.cpp
set_source_files_properties(${TORCH_SRC_DIR}/csrc/utils/throughput_benchmark.cpp PROPERTIES COMPILE_FLAGS -Wno-attributes)
endif()
if(USE_DISTRIBUTED)
list(APPEND TORCH_PYTHON_COMPILE_DEFINITIONS USE_DISTRIBUTED)
if(WIN32)

View file

@ -67,6 +67,9 @@ endif()
if(USE_C10D_MPI)
list(APPEND C10D_SRCS ProcessGroupMPI.cpp)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_source_files_properties(ProcessGroupMPI.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
endif()
list(APPEND C10D_LIBS ${MPI_LIBRARIES})
endif()