Просмотр исходного кода

Update Bazel & protobufs, then narrow warnings to Carbon. (#2500)

Protobufs code hits a warning with the latest system headers on macOS.
I figured this may have been fixed so I updated protobufs and Bazel to
the latest releases. This generally cleaned things up.

However, it actually added *more* warnings. This clearly isn't a really
well tested path. In fact, we already have a disabled warning that we'd
like for Carbon code because LLVM isn't clean for that warning.

So I've switched our warning strategy to a more durable approach of
suppressing all warnings for external repository headers and source
files. This lets us re-enable the missing warning and should fix the
protobuf warning that started me down this twisty path.

Sadly, we *have* to update to Bazel 6 in order to have the necessary
flag to use this approach to suppressing warnings, so I couldn't do this
as two PRs cleanly. =/ That's why I've bundled both the Bazel (and
protobuf) updates with the warning strategy change.

Last but not least, I've fixed several unused parameters in Carbon's
code that our warnings now catch.
Chandler Carruth 3 лет назад
Родитель
Сommit
dd26ea6a15

+ 1 - 1
.bazeliskrc

@@ -4,4 +4,4 @@
 
 # Keep pinned to a recent release, listed at
 # https://github.com/bazelbuild/bazel.
-USE_BAZEL_VERSION=5.1.1
+USE_BAZEL_VERSION=6.0.0

+ 6 - 0
.bazelrc

@@ -29,6 +29,12 @@ build --experimental_guard_against_concurrent_changes
 # https://github.com/bazelbuild/bazel/issues/13315
 build --incompatible_dont_enable_host_nonhost_crosstool_features=false
 
+# Disable warnings for all external compilations. These involve code that isn't
+# developed as part of Carbon and may be difficult or impossible to patch, so
+# warnings aren't likely to be actionable.
+build --per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w
+build --host_per_file_copt=external/.*\.(c|cc|cpp|cxx)$@-w
+
 # Default dynamic linking to off. While this can help build performance in some
 # edge cases with very large linked executables and a slow linker, between using
 # fast linkers on all platforms (LLD and the Apple linker), as well as having

+ 9 - 12
WORKSPACE

@@ -215,24 +215,22 @@ bison_register_toolchains(extra_copts = ["-w"])
 # Protocol buffers - for structured fuzzer testing.
 ###############################################################################
 
-# TODO: `rules_proto` pulls in a version of `rules_cc` with a frozenset bug.
-rules_cc_version = "0.0.1"
+rules_cc_version = "0.0.4"
 
 http_archive(
     name = "rules_cc",
-    sha256 = "4dccbfd22c0def164c8f47458bd50e0c7148f3d92002cdb459c2a96a68498241",
+    sha256 = "af6cc82d87db94585bceeda2561cb8a9d55ad435318ccb4ddfee18a43580fb5d",
+    strip_prefix = "rules_cc-{0}".format(rules_cc_version),
     urls = ["https://github.com/bazelbuild/rules_cc/releases/download/{0}/rules_cc-{0}.tar.gz".format(rules_cc_version)],
 )
 
-rules_proto_version = "4.0.0-3.20.0"
+rules_proto_version = "5.3.0-21.7"
 
 http_archive(
     name = "rules_proto",
-    sha256 = "e017528fd1c91c5a33f15493e3a398181a9e821a804eb7ff5acdd1d2d6c2b18d",
+    sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
     strip_prefix = "rules_proto-{0}".format(rules_proto_version),
-    urls = [
-        "https://github.com/bazelbuild/rules_proto/archive/refs/tags/{0}.tar.gz".format(rules_proto_version),
-    ],
+    urls = ["https://github.com/bazelbuild/rules_proto/archive/refs/tags/{0}.tar.gz".format(rules_proto_version)],
 )
 
 load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
@@ -245,15 +243,14 @@ rules_proto_toolchains()
 # libprotobuf_mutator - for structured fuzzer testing.
 ###############################################################################
 
-# Head as of 2022-09-13.
-libprotobuf_mutator_version = "a304ec48dcf15d942607032151f7e9ee504b5dcf"
+libprotobuf_mutator_version = "1.1"
 
 http_archive(
     name = "com_google_libprotobuf_mutator",
     build_file = "@//:third_party/libprotobuf_mutator/BUILD.txt",
-    sha256 = "0ce80217393fe6b01dac9818127e664801d865fefd708b98183181c0ed457878",
+    sha256 = "fd299fd72c5cf664259d9bd43a72cb74dc6a8b9604d107fe2d2e90885aeb7c16",
     strip_prefix = "libprotobuf-mutator-{0}".format(libprotobuf_mutator_version),
-    urls = ["https://github.com/google/libprotobuf-mutator/archive/{0}.tar.gz".format(libprotobuf_mutator_version)],
+    urls = ["https://github.com/google/libprotobuf-mutator/archive/v{0}.tar.gz".format(libprotobuf_mutator_version)],
 )
 
 ###############################################################################

+ 3 - 2
bazel/cc_toolchains/clang_cc_toolchain_config.bzl

@@ -133,8 +133,9 @@ def _impl(ctx):
                             "-Wimplicit-fallthrough",
                             "-Wctad-maybe-unsupported",
                             "-Wnon-virtual-dtor",
-                            # Unfortunately, LLVM isn't clean for this warning.
-                            "-Wno-unused-parameter",
+                            # Don't warn on external code as we can't
+                            # necessarily patch it easily.
+                            "--system-header-prefix=external/",
                             # Compile actions shouldn't link anything.
                             "-c",
                         ],

+ 1 - 1
explorer/interpreter/type_checker.cpp

@@ -1565,7 +1565,7 @@ class TypeChecker::ConstraintTypeBuilder {
   // when simply forming a constraint type for later use in the type of a
   // declared name.
   auto Resolve(TypeChecker& type_checker, SourceLocation source_loc,
-               const ImplScope& impl_scope) -> ErrorOr<Success> {
+               const ImplScope& /*impl_scope*/) -> ErrorOr<Success> {
     CARBON_RETURN_IF_ERROR(DeduplicateRewrites(source_loc));
     CARBON_RETURN_IF_ERROR(ApplyRewritesToRewrites(type_checker, source_loc));
     ApplyRewritesToConstraints(type_checker);

+ 3 - 3
explorer/syntax/parse_and_lex_context.h

@@ -55,9 +55,9 @@ class ParseAndLexContext {
 }  // namespace Carbon
 
 // Gives flex the yylex prototype we want.
-#define YY_DECL                                                         \
-  auto yylex(Carbon::Nonnull<Carbon::Arena*> arena, yyscan_t yyscanner, \
-             Carbon::ParseAndLexContext& context)                       \
+#define YY_DECL                                                             \
+  auto yylex(Carbon::Nonnull<Carbon::Arena*> /*arena*/, yyscan_t yyscanner, \
+             Carbon::ParseAndLexContext& context)                           \
       ->Carbon::Parser::symbol_type
 
 // Declares yylex for the parser's sake.

+ 1 - 1
toolchain/diagnostics/null_diagnostics.h

@@ -23,7 +23,7 @@ inline auto NullDiagnosticLocationTranslator()
 
 inline auto NullDiagnosticConsumer() -> DiagnosticConsumer& {
   struct Consumer : DiagnosticConsumer {
-    auto HandleDiagnostic(Diagnostic d) -> void override {}
+    auto HandleDiagnostic(Diagnostic /*d*/) -> void override {}
   };
   static auto* consumer = new Consumer;
   return *consumer;