Skip to content

Commit

Permalink
turn on -Wall with a few exceptions in Bazel build
Browse files Browse the repository at this point in the history
Summary:
We add the following exceptions:
 * sign-compare: this is heavily violated in our codebase
 * unknown-pragmas: we use this intentionally for some loop unrolling
   in CUDA

Because they are included in -Wall by default, we remove the following
warnings from our explicit list:
 * unused-function
 * unused-variable

Test Plan: Rely on CI.

Reviewers: alband, seemethere

Subscribers:

Tasks:

Tags:

Pull Request resolved: pytorch#79306

Approved by: https://github.com/malfet
  • Loading branch information
Michael Andreas Dagitses authored and pytorchmergebot committed Jun 13, 2022
1 parent 52a5266 commit 70810a3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,17 @@ build:cpu-only --@rules_cuda//cuda:enable_cuda=False
# macro-level opts will come earlier than target level overrides
build --per_file_copt='^//.*\.(cpp|cc)$'@-Werror=type-limits
build --per_file_copt='^//.*\.(cpp|cc)$'@-Werror=unused-but-set-variable
build --per_file_copt='^//.*\.(cpp|cc)$'@-Werror=unused-function
build --per_file_copt='^//.*\.(cpp|cc)$'@-Werror=unused-variable

build --per_file_copt='^//.*\.(cpp|cc)$'@-Werror=all
# The following warnings come from -Wall. We downgrade them from error
# to warnings here.
#
# sign-compare has a tremendous amount of violations in the
# codebase. It will be a lot of work to fix them, just disable it for
# now.
build --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-sign-compare
# We intentionally use #pragma unroll, which is compiler specific.
build --per_file_copt='^//.*\.(cpp|cc)$'@-Wno-error=unknown-pragmas

build --per_file_copt='//:aten/src/ATen/RegisterCompositeExplicitAutograd\.cpp$'@-Wno-error=unused-function
build --per_file_copt='//:aten/src/ATen/RegisterCompositeImplicitAutograd\.cpp$'@-Wno-error=unused-function
Expand Down
13 changes: 11 additions & 2 deletions tools/rules/cu.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@ NVCC_COPTS = [
"--expt-extended-lambda",
"--compiler-options=-Werror=type-limits",
"--compiler-options=-Werror=unused-but-set-variable",
"--compiler-options=-Werror=unused-function",
"--compiler-options=-Werror=unused-variable",

"--compiler-options=-Werror=all",
# The following warnings come from -Wall. We downgrade them from
# error to warnings here.
#
# sign-compare has a tremendous amount of violations in the
# codebase. It will be a lot of work to fix them, just disable it
# for now.
"--compiler-options=-Wno-sign-compare",
# We intentionally use #pragma unroll, which is compiler specific.
"--compiler-options=-Wno-error=unknown-pragmas",
]

def cu_library(name, srcs, copts = [], **kwargs):
Expand Down

0 comments on commit 70810a3

Please sign in to comment.