Update to Bazel 7 (#241)

* Only force clang, not clang-10

clang-10 isn't available on macOS. Before Bazel 7, this never applied
to macOS since the default toolchain used Xcode, ignoring the value of
`CC` alltogether.

Also move from `--action_env` to `--repo_env`, which doesn't leak into
all actions environment, and don't set `CXX`, which isn't read by Bazel.

* Do not use `rules_cc`

The core rules still live in Bazel and `rules_cc` in particular isn't
well maintained right now. It is better to switch to the external
rulesets when the Bzlmod migration has been completed and the rules are
starlarkified, with the external rulesets being the source of truth.

* Pin Java language and runtime version to 11

Targetting Java 8 is deprecated on a JDK 21, which Bazel 7 uses for
compilation by default.

As a side effect, this allows contributors to run all tests without a
local JDK.

* Do not depend on source directories

This has always been unsound and triggers a warning with Bazel 7.

* Disable Bzlmod

Enabled by default in Bazel 7, but rules_fuzzing isn't compatible with
it yet.

* Update to Bazel 7

This requires updating some dependencies.
diff --git a/.bazelrc b/.bazelrc
index f123ac7..49a9e99 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -12,9 +12,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# rules_fuzzing is not yet compatible with Bzlmod.
+# Use the experimental version of the flag for Bazel 5 compatibility.
+common --noexperimental_enable_bzlmod
+
 # Force the use of Clang for all builds.
-build --action_env=CC=clang-10
-build --action_env=CXX=clang++-10
+build --repo_env=CC=clang
 
 # Needed for abseil-cpp until https://github.com/bazelbuild/bazel/pull/19794 is released.
 build --cxxopt=-std=c++14
@@ -25,6 +28,12 @@
 # Strict dependency check for C++ includes.
 build --features=layering_check
 
+# Target Java 11 to squelch warnings about Java 8 being deprecated.
+build --java_language_version=11
+build --java_runtime_version=remotejdk_11
+build --tool_java_language_version=11
+build --tool_java_runtime_version=remotejdk_11
+
 # The ASAN configuration suitable for C++ unit tests.
 build:asan --copt=-fsanitize=address
 build:asan --linkopt=-fsanitize=address
@@ -111,8 +120,8 @@
 coverage --@rules_fuzzing//fuzzing:cc_engine_sanitizer=none
 coverage --instrument_test_targets
 coverage --action_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=1
-coverage --action_env=GCOV=llvm-profdata-10
-coverage --action_env=BAZEL_LLVM_COV=llvm-cov-10
+coverage --action_env=GCOV=llvm-profdata
+coverage --action_env=BAZEL_LLVM_COV=llvm-cov
 coverage --combined_report=lcov
 coverage --experimental_use_llvm_covmap
 coverage --experimental_generate_llvm_lcov
diff --git a/.bazelversion b/.bazelversion
index 8a30e8f..66ce77b 100644
--- a/.bazelversion
+++ b/.bazelversion
@@ -1 +1 @@
-5.4.0
+7.0.0
diff --git a/.github/workflows/bazel_test.yml b/.github/workflows/bazel_test.yml
index 3f694e0..79fa5c5 100644
--- a/.github/workflows/bazel_test.yml
+++ b/.github/workflows/bazel_test.yml
@@ -40,7 +40,7 @@
       - name: Install dependencies
         run: |
           sudo apt-get update && sudo apt-get install -yq \
-            clang-10 \
+            clang \
             libunwind-dev \
             libblocksruntime-dev
       - name: Run unit tests
@@ -67,7 +67,7 @@
       - name: Install dependencies
         run: |
           sudo apt-get update && sudo apt-get install -yq \
-            clang-10 \
+            clang \
             libunwind-dev \
             libblocksruntime-dev
       - name: Run smoke test
@@ -86,7 +86,7 @@
       - name: Install dependencies
         run: |
           sudo apt-get update && sudo apt-get install -yq \
-            clang-10 \
+            clang \
             libunwind-dev \
             libblocksruntime-dev
       - name: Run regression tests
@@ -104,7 +104,8 @@
       - name: Install dependencies
         run: |
           sudo apt-get update && sudo apt-get install -yq \
-            clang-10 \
+            clang \
+            llvm \
             libunwind-dev \
             libblocksruntime-dev
       - name: Gather coverage
@@ -125,7 +126,7 @@
       - name: Checkout repository
         uses: actions/checkout@v2
       - name: Install dependencies
-        run: sudo apt-get update && sudo apt-get install -yq clang-10
+        run: sudo apt-get update && sudo apt-get install -yq clang
       - name: Run smoke test
         run: |
           bazel run ${{ matrix.target }} --config=${{ matrix.config }} -- --clean --timeout_secs=5
@@ -140,7 +141,7 @@
       - name: Checkout repository
         uses: actions/checkout@v2
       - name: Install dependencies
-        run: sudo apt-get update && sudo apt-get install -yq clang-10
+        run: sudo apt-get update && sudo apt-get install -yq clang
       - name: Run regression tests
         run: |
           bazel test --verbose_failures --test_output=all \
diff --git a/WORKSPACE b/WORKSPACE
index a0cf5a9..c31ac1e 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -45,9 +45,9 @@
 
 http_archive(
     name = "com_google_googletest",
-    sha256 = "763e20249e76417bed7ebc44aa85fedf5fbac6f9fb6d30bddb628ab07ebf04f5",
-    strip_prefix = "googletest-389cb68b87193358358ae87cc56d257fd0d80189",
-    urls = ["https://github.com/google/googletest/archive/389cb68b87193358358ae87cc56d257fd0d80189.zip"],
+    integrity = "sha256-itWYxzrXluDYKAsILOvYKmMNc+c808cAV5OKZQG7pdc=",
+    strip_prefix = "googletest-1.14.0",
+    urls = ["https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz"],
 )
 
 # Stardoc dependencies.
diff --git a/docs/BUILD b/docs/BUILD
index e21fb9b..905e229 100644
--- a/docs/BUILD
+++ b/docs/BUILD
@@ -22,18 +22,6 @@
 load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
 
 bzl_library(
-    name = "rules_cc",
-    srcs = [
-        "@rules_cc//cc:action_names.bzl",
-        "@rules_cc//cc:defs.bzl",
-        "@rules_cc//cc:find_cc_toolchain.bzl",
-        "@rules_cc//cc/private/rules_impl:cc_flags_supplier.bzl",
-        "@rules_cc//cc/private/rules_impl:cc_flags_supplier_lib.bzl",
-        "@rules_cc//cc/private/rules_impl:compiler_flag.bzl",
-    ],
-)
-
-bzl_library(
     name = "bazel_skylib",
     deps = [
         "@bazel_skylib//lib:dicts",
@@ -61,7 +49,6 @@
     ],
     deps = [
         ":bazel_skylib",
-        ":rules_cc",
     ],
 )
 
diff --git a/examples/BUILD b/examples/BUILD
index e4a4eef..52b9663 100644
--- a/examples/BUILD
+++ b/examples/BUILD
@@ -38,8 +38,7 @@
     corpus = [
         "corpus_0.txt",
         ":corpus_filegroup",
-        "test_corpus_dir",
-    ],
+    ] + glob(["test_corpus_dir/**"]),
 )
 
 # This target shows how to create a fuzz test target with dictionaries.
@@ -49,8 +48,7 @@
     corpus = [
         "corpus_0.txt",
         ":corpus_filegroup",
-        "test_corpus_dir",
-    ],
+    ] + glob(["test_corpus_dir/**"]),
     dicts = [
         "dictionaries/valid_part1.dict",
         "dictionaries/valid_part2.dict",
diff --git a/fuzzing/engines/BUILD b/fuzzing/engines/BUILD
index 040aaa3..8f99fba 100644
--- a/fuzzing/engines/BUILD
+++ b/fuzzing/engines/BUILD
@@ -12,7 +12,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-load("@rules_cc//cc:defs.bzl", "cc_library")
 load("//fuzzing:cc_defs.bzl", "cc_fuzzing_engine")
 load("//fuzzing:java_defs.bzl", "java_fuzzing_engine")
 
diff --git a/fuzzing/private/engine_test.bzl b/fuzzing/private/engine_test.bzl
index dee789b..4202c6a 100644
--- a/fuzzing/private/engine_test.bzl
+++ b/fuzzing/private/engine_test.bzl
@@ -16,14 +16,13 @@
 
 load("@bazel_skylib//lib:new_sets.bzl", "sets")
 load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
-load("@rules_cc//cc:defs.bzl", "cc_library")
 load(":engine.bzl", "FuzzingEngineInfo", "cc_fuzzing_engine")
 load(":util.bzl", "generate_file")
 
 # Shared fixtures.
 
 def _setup_common_stubs():
-    cc_library(
+    native.cc_library(
         name = "library_stub",
         srcs = [],
         testonly = 1,
diff --git a/fuzzing/private/fuzz_test.bzl b/fuzzing/private/fuzz_test.bzl
index 7f65701..e25898d 100644
--- a/fuzzing/private/fuzz_test.bzl
+++ b/fuzzing/private/fuzz_test.bzl
@@ -14,12 +14,8 @@
 
 """The implementation of the {cc, java}_fuzz_test rules."""
 
-load("@rules_cc//cc:defs.bzl", "cc_binary")
 load("@rules_fuzzing_oss_fuzz//:instrum.bzl", "native_library_sanitizer")
 load("//fuzzing/private:binary.bzl", "fuzzing_binary", "fuzzing_binary_uninstrumented")
-
-# FIXME: Including this leads to a Stardoc error since defs.bzl is not visible. As a workaround, use native.java_binary.
-#load("@rules_java//java:defs.bzl", "java_binary")
 load("//fuzzing/private:common.bzl", "fuzzing_corpus", "fuzzing_dictionary", "fuzzing_launcher")
 load("//fuzzing/private:java_utils.bzl", "determine_primary_class", "jazzer_fuzz_binary")
 load("//fuzzing/private:regression.bzl", "fuzzing_regression_test")
@@ -196,7 +192,7 @@
 
     # tags is not configurable and can thus use append.
     binary_kwargs.setdefault("tags", []).append("manual")
-    cc_binary(
+    native.cc_binary(
         name = raw_binary_name,
         **binary_kwargs
     )
diff --git a/fuzzing/private/oss_fuzz/BUILD.tpl b/fuzzing/private/oss_fuzz/BUILD.tpl
index 2082067..790821f 100644
--- a/fuzzing/private/oss_fuzz/BUILD.tpl
+++ b/fuzzing/private/oss_fuzz/BUILD.tpl
@@ -14,7 +14,6 @@
 
 load("@rules_fuzzing//fuzzing:cc_defs.bzl", "cc_fuzzing_engine")
 load("@rules_fuzzing//fuzzing:java_defs.bzl", "java_fuzzing_engine")
-load("@rules_cc//cc:defs.bzl", "cc_library")
 
 cc_fuzzing_engine(
     name = "oss_fuzz_engine",
diff --git a/fuzzing/replay/BUILD b/fuzzing/replay/BUILD
index b3e0478..eff44a3 100644
--- a/fuzzing/replay/BUILD
+++ b/fuzzing/replay/BUILD
@@ -14,8 +14,6 @@
 
 # Tools for replaying test files.
 
-load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
-
 package(default_visibility = ["//fuzzing:__subpackages__"])
 
 # Libraries.
diff --git a/fuzzing/repositories.bzl b/fuzzing/repositories.bzl
index a94d84f..a807bc6 100644
--- a/fuzzing/repositories.bzl
+++ b/fuzzing/repositories.bzl
@@ -31,10 +31,10 @@
         http_archive,
         name = "platforms",
         urls = [
-            "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.4/platforms-0.0.4.tar.gz",
-            "https://github.com/bazelbuild/platforms/releases/download/0.0.4/platforms-0.0.4.tar.gz",
+            "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz",
+            "https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz",
         ],
-        sha256 = "079945598e4b6cc075846f7fd6a9d0857c33a7afc0de868c2ccb96405225135d",
+        sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74",
     )
     maybe(
         http_archive,
diff --git a/honggfuzz.BUILD b/honggfuzz.BUILD
index c62bda2..29d9fca 100644
--- a/honggfuzz.BUILD
+++ b/honggfuzz.BUILD
@@ -22,8 +22,6 @@
 # Disable the layering check for including the external headers.
 package(features = ["-layering_check"])
 
-load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
-
 HF_ARCH = select({
     "@platforms//os:osx": ["-D_HF_ARCH_DARWIN"],
     "//conditions:default": ["-D_HF_ARCH_LINUX"],