From 91d8a6f6a774ace46aab8c982b9cb44539a5b74a Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Tue, 18 Oct 2016 20:08:41 -0800 Subject: [PATCH] Suppress many compiler warnings This includes ~200 -Wsign-compare warnings in TensorFlow, 15 -Wimplicit-function-declaration warnings in zlib, and more. I'm also working on getting rid of 400 protobuf warnings here: google/protobuf#2261 Change: 136555503 --- tensorflow/contrib/metrics/kernels/BUILD | 1 + .../contrib/tfprof/tools/tfprof/internal/BUILD | 2 ++ tensorflow/core/kernels/BUILD | 2 ++ tensorflow/core/platform/default/build_config.bzl | 1 + tensorflow/core/util/tensor_bundle/BUILD | 1 + tensorflow/python/BUILD | 2 ++ tensorflow/tensorflow.bzl | 13 ++++++++----- zlib.BUILD | 1 + 8 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tensorflow/contrib/metrics/kernels/BUILD b/tensorflow/contrib/metrics/kernels/BUILD index 8b82bab53d6..967c98ad60e 100644 --- a/tensorflow/contrib/metrics/kernels/BUILD +++ b/tensorflow/contrib/metrics/kernels/BUILD @@ -10,6 +10,7 @@ package(default_visibility = ["//tensorflow:__subpackages__"]) cc_library( name = "set_kernels", srcs = ["set_kernels.cc"], + copts = ["-Wno-sign-compare"], deps = [ "//tensorflow/core:framework_headers_lib", "//third_party/eigen3", diff --git a/tensorflow/contrib/tfprof/tools/tfprof/internal/BUILD b/tensorflow/contrib/tfprof/tools/tfprof/internal/BUILD index 7ca95cf0cde..7a4b4c0c98f 100644 --- a/tensorflow/contrib/tfprof/tools/tfprof/internal/BUILD +++ b/tensorflow/contrib/tfprof/tools/tfprof/internal/BUILD @@ -122,6 +122,7 @@ cc_library( name = "tfprof_utils", srcs = ["tfprof_utils.cc"], hdrs = ["tfprof_utils.h"], + copts = ["-Wno-sign-compare"], deps = [ ":tfprof_options", "//tensorflow/core:lib", @@ -182,6 +183,7 @@ cc_library( name = "tfprof_tensor", srcs = ["tfprof_tensor.cc"], hdrs = ["tfprof_tensor.h"], + copts = ["-Wno-sign-compare"], deps = [ "//tensorflow/contrib/tfprof/tools/tfprof:protos_all_cc", "//tensorflow/core:framework", diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD index b90a5586934..27719faaa67 100644 --- a/tensorflow/core/kernels/BUILD +++ b/tensorflow/core/kernels/BUILD @@ -205,6 +205,7 @@ cc_library( name = "ops_util", srcs = ["ops_util.cc"], hdrs = ["ops_util.h"], + copts = ["-Wno-sign-compare"], deps = [ "//tensorflow/core:framework", "//tensorflow/core:lib", @@ -288,6 +289,7 @@ cc_library( name = "save_restore_tensor", srcs = ["save_restore_tensor.cc"], hdrs = ["save_restore_tensor.h"], + copts = ["-Wno-sign-compare"], deps = [ ":bounds_check", "//tensorflow/core:framework", diff --git a/tensorflow/core/platform/default/build_config.bzl b/tensorflow/core/platform/default/build_config.bzl index 23404cd4240..534561a0087 100644 --- a/tensorflow/core/platform/default/build_config.bzl +++ b/tensorflow/core/platform/default/build_config.bzl @@ -46,6 +46,7 @@ def tf_proto_library_cc(name, srcs = [], has_services = None, srcs = srcs + tf_deps(deps, "_proto_srcs"), deps = deps + ["@protobuf//:cc_wkt_protos"], cc_libs = cc_libs + ["@protobuf//:protobuf"], + copts = ["-Wno-unused-but-set-variable", "-Wno-sign-compare"], protoc = "@protobuf//:protoc", default_runtime = "@protobuf//:protobuf", use_grpc_plugin = use_grpc_plugin, diff --git a/tensorflow/core/util/tensor_bundle/BUILD b/tensorflow/core/util/tensor_bundle/BUILD index 6b2c37fe392..f1c6f2056f1 100644 --- a/tensorflow/core/util/tensor_bundle/BUILD +++ b/tensorflow/core/util/tensor_bundle/BUILD @@ -24,6 +24,7 @@ cc_library( name = "tensor_bundle", srcs = ["tensor_bundle.cc"], hdrs = ["tensor_bundle.h"], + copts = ["-Wno-sign-compare"], deps = [ ":naming", "//tensorflow/core:core_cpu_internal", diff --git a/tensorflow/python/BUILD b/tensorflow/python/BUILD index 8288bb201b5..27a362ecdbd 100644 --- a/tensorflow/python/BUILD +++ b/tensorflow/python/BUILD @@ -175,6 +175,7 @@ cc_library( cc_binary( name = "framework/test_file_system.so", srcs = ["framework/test_file_system.cc"], + copts = ["-Wno-sign-compare"], linkopts = select({ "//conditions:default": [ "-lm", @@ -217,6 +218,7 @@ cc_library( name = "cpp_shape_inference", srcs = ["framework/cpp_shape_inference.cc"], hdrs = ["framework/cpp_shape_inference.h"], + copts = ["-Wno-sign-compare"], visibility = ["//visibility:public"], deps = [ ":numpy_lib", diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index d510089effc..44d75e9ce35 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -142,9 +142,10 @@ def if_not_mobile(a): }) def tf_copts(): - return (["-fno-exceptions", - "-DEIGEN_AVOID_STL_ARRAY", - "-Iexternal/gemmlowp",] + + return (["-DEIGEN_AVOID_STL_ARRAY", + "-Iexternal/gemmlowp", + "-Wno-sign-compare", + "-fno-exceptions"] + if_cuda(["-DGOOGLE_CUDA=1"]) + if_android_arm(["-mfpu=neon"]) + select({ @@ -155,7 +156,7 @@ def tf_copts(): "-O2", ], "//tensorflow:darwin": [], - "//tensorflow:ios": ["-std=c++11",], + "//tensorflow:ios": ["-std=c++11"], "//conditions:default": ["-pthread"]})) def tf_opts_nortti_if_android(): @@ -770,7 +771,9 @@ def tf_py_wrap_cc(name, srcs, swig_includes=[], deps=[], copts=[], **kwargs): native.cc_binary( name=cc_library_name, srcs=[module_name + ".cc"], - copts=(copts + ["-Wno-self-assign", "-Wno-write-strings"] + copts=(copts + ["-Wno-self-assign", + "-Wno-sign-compare", + "-Wno-write-strings"] + tf_extension_copts()), linkopts=tf_extension_linkopts() + extra_linkopts, linkstatic=1, diff --git a/zlib.BUILD b/zlib.BUILD index edb77fdf8ee..4c443dfe6ea 100644 --- a/zlib.BUILD +++ b/zlib.BUILD @@ -32,5 +32,6 @@ cc_library( "zutil.h", ], hdrs = ["zlib.h"], + copts = ["-Wno-implicit-function-declaration"], includes = ["."], )