Merge pull request #2390 from ivan444/reenable_xrefs2

Re-enable Kythe xRefs publishing
diff --git a/.bazelrc b/.bazelrc
index eced6fc..04d1f38 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -10,23 +10,24 @@
 build --workspace_status_command="bash bazel/build-version.sh"
 
 # Systems with gcc or clang
-common:linux   --cxxopt=-xc++ --host_cxxopt=-xc++ --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --client_env=BAZEL_CXXOPTS=-std=c++17
-common:freebsd --cxxopt=-xc++ --host_cxxopt=-xc++ --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --client_env=BAZEL_CXXOPTS=-std=c++17 --linkopt=-lm --host_linkopt=-lm
-common:openbsd --cxxopt=-xc++ --host_cxxopt=-xc++ --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --client_env=BAZEL_CXXOPTS=-std=c++17 --linkopt=-lm --host_linkopt=-lm
-common:macos   --cxxopt=-xc++ --host_cxxopt=-xc++ --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --client_env=BAZEL_CXXOPTS=-std=c++17
+common:unix    --cxxopt=-xc++ --host_cxxopt=-xc++ --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --client_env=BAZEL_CXXOPTS=-std=c++17
+common:linux   --config=unix
+common:freebsd --config=unix --linkopt=-lm --host_linkopt=-lm
+common:openbsd --config=unix --linkopt=-lm --host_linkopt=-lm
+common:macos   --config=unix
 
 # https://github.com/abseil/abseil-cpp/issues/848
 # https://github.com/bazelbuild/bazel/issues/4341#issuecomment-758361769
 common:macos --features=-supports_dynamic_linker --linkopt=-framework --linkopt=CoreFoundation --host_linkopt=-framework --host_linkopt=CoreFoundation
 
-# Force the use clang-cl on Windows instead of MSVC. MSVC has some issues with
-# the codebase, so we focus the effort for now is to have a Windows Verible
-# compiled with clang-cl before fixing the issues unique to MSVC.
-# Since we use designated initializers (C99 ... but >= c++20), compiler really wants the c++20 mode
-common:windows --compiler=clang-cl --cxxopt=/std:c++20 --host_cxxopt=/std:c++20 --client_env=BAZEL_CXXOPTS=/std:c++20
+# Use clang-cl by default on Windows. MSVC has some issues with the codebase,
+# so we focus the effort for now is to have a Windows Verible compiled with
+# clang-cl before fixing the issues unique to MSVC.
+common:windows --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl --extra_execution_platforms=//:x64_windows-clang-cl
+common:windows --compiler=clang-cl --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 --client_env=BAZEL_CXXOPTS=/std:c++17
 
 build --cxxopt="-Wno-unknown-warning-option" --host_cxxopt="-Wno-unknown-warning-option"
-# TODO: this looks like benign where it happens but to be explored further
+# TODO: this looks like benign where it happens but to be explored further.
 build --cxxopt="-Wno-dangling-reference" --host_cxxopt="-Wno-dangling-reference"
 # Newer bisons create an unused label.
 build --cxxopt="-Wno-unused-label" --host_cxxopt="-Wno-unused-label"
diff --git a/.github/bin/build-and-test.sh b/.github/bin/build-and-test.sh
index 3321002..729732f 100755
--- a/.github/bin/build-and-test.sh
+++ b/.github/bin/build-and-test.sh
@@ -23,10 +23,8 @@
   export CXX=clang++
   export CC=clang
 
-  # clang versions supported. Starting with 13, we
-  # get some warnings in absl, so let's not go beyond
-  # 12 for now.
-  for version in 12 11 10 ; do
+  # clang versions that we have tested.
+  for version in 19 12 11 10 ; do
     if command -v clang++-${version}; then
       export CXX=clang++-${version}
       export CC=clang-${version}
diff --git a/.github/bin/install-bazel.sh b/.github/bin/install-bazel.sh
index 1f39b77..0f2d5b1 100755
--- a/.github/bin/install-bazel.sh
+++ b/.github/bin/install-bazel.sh
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+set -x
+
 if [ -z "${BAZEL_VERSION}" ]; then
         echo "Please set \$BAZEL_VERSION"
         exit 1
diff --git a/.github/bin/install-kythe.sh b/.github/bin/install-kythe.sh
index 4392b63..6b3bc3d 100755
--- a/.github/bin/install-kythe.sh
+++ b/.github/bin/install-kythe.sh
@@ -13,6 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+set -x
+
 if [ -z "${KYTHE_VERSION}" ]; then
         echo "Set \$KYTHE_VERSION"
         exit 1
@@ -42,5 +44,9 @@
     wget --no-verbose -O kythe.tar.gz \
       "https://github.com/kythe/kythe/releases/download/$KYTHE_VERSION/kythe-$KYTHE_VERSION.tar.gz"
     tar -xzf kythe.tar.gz
+    # Bazel renamed @com_google_protobuf to @protobuf while Kythe is still
+    # using it in their BUILD targets. Manually rename until the fixed Kythe is
+    # released.
+    sed -i 's/@com_google_protobuf/@protobuf/' "kythe-${KYTHE_VERSION}/BUILD"
   )
 fi
diff --git a/.github/bin/run-format.sh b/.github/bin/run-format.sh
index f8f5f44..e6bedd6 100755
--- a/.github/bin/run-format.sh
+++ b/.github/bin/run-format.sh
@@ -31,7 +31,20 @@
 
 FORMAT_OUT=${TMPDIR:-/tmp}/clang-format-diff.out
 
-CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
+# Use the provided Clang format binary, or try to fallback to clang-format-17
+# or clang-format.
+if [[ ! -v CLANG_FORMAT ]]; then
+  if command -v "clang-format-17" 2>&1 >/dev/null
+  then
+    CLANG_FORMAT="clang-format-17"
+  elif command -v "clang-format" 2>&1 >/dev/null
+  then
+    CLANG_FORMAT="clang-format"
+  else
+    (echo "-- Missing the clang-format binary! --"; exit 1)
+  fi
+fi
+
 BUILDIFIER=${BUILDIFIER:-buildifier}
 
 # Currently, we're using clang-format 17, as newer versions still have some
@@ -60,7 +73,7 @@
   if [ -s ${FORMAT_OUT} ]; then
     echo "Style not matching (see https://github.com/chipsalliance/verible/blob/master/CONTRIBUTING.md#style)"
     echo "Run"
-    echo "  .github/bin/run-clang-format.sh"
+    echo "  .github/bin/run-format.sh"
     echo "-------------------------------------------------"
     echo
     cat ${FORMAT_OUT}
diff --git a/.github/bin/run-kythe.sh b/.github/bin/run-kythe.sh
index d4c65bd..35c392c 100755
--- a/.github/bin/run-kythe.sh
+++ b/.github/bin/run-kythe.sh
@@ -37,10 +37,21 @@
     //...
 else
   # Use kythe's released tools.
+  cat >WORKSPACE.bzlmod <<EOL
+local_repository(
+    name = "kythe_release",
+    path = "${KYTHE_DIR_ABS}",
+)
+EOL
   # --override_repository kythe_release expects an absolute dir
   bazel \
-    --bazelrc="${KYTHE_DIR_ABS}/extractors.bazelrc" \
     build \
+    --keep_going \
+    --experimental_extra_action_top_level_only \
+    --cc_proto_library_header_suffixes=.pb.h,.pb.h.meta \
+    --proto_toolchain_for_cc=@kythe_release//:cc_native_proto_toolchain \
+    --experimental_action_listener=@kythe_release//:extract_kzip_cxx \
+    --experimental_action_listener=@kythe_release//:extract_kzip_protobuf \
     --override_repository kythe_release="${KYTHE_DIR_ABS}" \
     --define="kythe_corpus=github.com/chipsalliance/verible" \
     -- \
diff --git a/.github/settings.sh b/.github/settings.sh
index 4601e23..a6d4ae8 100644
--- a/.github/settings.sh
+++ b/.github/settings.sh
@@ -17,6 +17,9 @@
 # pass through things like Docker files which don't support bash arrays and
 # similar functionality.
 
+set -e
+set -x
+
 [[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0
 
 if [ $SOURCED -ne 1 ]; then
@@ -24,7 +27,7 @@
         exit 1
 fi
 
-export GIT_VERSION=${GIT_VERSION:-$(git describe --match=v*)}
+export GIT_VERSION=${GIT_VERSION:-$(git describe --match='v*')}
 
 export BAZEL_CXXOPTS="-std=c++17"
 
@@ -32,9 +35,9 @@
 export BAZEL_OPTS="-c opt --noshow_progress"
 
 # Used to fetch the BAZEL version where needed.
-export BAZEL_VERSION=6.5.0
+export BAZEL_VERSION=7.6.1
 
 # Kythe version for extracting xRefs
-export KYTHE_VERSION=v0.0.52
+export KYTHE_VERSION=v0.0.68
 # Kythe version for fetching tools (verification tools, etc.)
 export KYTHE_TOOLS_VERSION=${KYTHE_VERSION}
diff --git a/.github/workflows/verible-ci.yml b/.github/workflows/verible-ci.yml
index 016b4ec..f0afbd7 100644
--- a/.github/workflows/verible-ci.yml
+++ b/.github/workflows/verible-ci.yml
@@ -115,7 +115,7 @@
         path: "**/plot_*.svg"
 
   Check:
-    container: ubuntu:jammy
+    container: ubuntu:noble
     runs-on: [self-hosted, Linux, X64, gcp-custom-runners]
     strategy:
       fail-fast: false
@@ -183,11 +183,11 @@
         apt -qqy update
         apt -qq -y install build-essential wget git python3 python-is-python3 default-jdk cmake python3-pip ripgrep
         apt -qq -y install gcc-10 g++-10
-        apt -qq -y install gcc-12 g++-12
-        apt -qq -y install clang-12  # clang always a particular version.
+        apt -qq -y install gcc-14 g++-14
+        apt -qq -y install clang-19
         source ./.github/settings.sh
         # Use newer compiler for c++2x compilation. Also slang needs c++20
-        ./.github/bin/set-compiler.sh $([[ "$MODE" == test-c++2* || "$MODE" == "smoke-test-analyzer" ]] && echo 12 || echo 10)
+        ./.github/bin/set-compiler.sh $([[ "$MODE" == test-c++2* || "$MODE" == "smoke-test-analyzer" ]] && echo 14 || echo 10)
         ARCH="$ARCH" ./.github/bin/install-bazel.sh
 
     - name: Build Slang
@@ -276,8 +276,8 @@
 
 
   KytheXrefs:
-    runs-on: ubuntu-24.04
-    if: false   # Currently disabled, need to investigate failure.
+    container: ubuntu:noble
+    runs-on: [self-hosted, Linux, X64, gcp-custom-runners]
 
     steps:
 
@@ -289,8 +289,13 @@
 
     - name: Install Dependencies
       run: |
+        set -x
+        apt -qqy update
+        apt -qq -y install build-essential wget git python3 python-is-python3 default-jdk cmake python3-pip ripgrep
+        apt -qq -y install gcc-14 g++-14
+        pwd
         source ./.github/settings.sh
-        ./.github/bin/set-compiler.sh 10
+        ./.github/bin/set-compiler.sh 14
         ./.github/bin/install-bazel.sh
         ./.github/bin/install-kythe.sh
 
@@ -310,7 +315,7 @@
 
     - name: Install Dependencies
       run: |
-        echo "USE_BAZEL_VERSION=6.5.0" >> $GITHUB_ENV
+        echo "USE_BAZEL_VERSION=7.6.1" >> $GITHUB_ENV
 
     - name: Checkout code
       uses: actions/checkout@v4
@@ -391,9 +396,9 @@
 
     - name: Install dependencies
       run: |
-        choco install bazel --force --version=6.5.0
+        choco install bazel --force --version=7.6.1
         choco install winflexbison3
-        choco install llvm --allow-downgrade --version=17.0.6
+        choco install llvm --allow-downgrade --version=20.1.4
 
     - name: Debug bazel directory settings
       # We need to explicitly call the bazel binary from choco, otherwise
diff --git a/BUILD b/BUILD
index e4ec922..cd0cbb5 100644
--- a/BUILD
+++ b/BUILD
@@ -55,3 +55,14 @@
         "//verible/verilog/tools/lint:verible-verilog-lint",
     ],
 )
+
+# For building with clang-cl on Windows.
+# https://bazel.build/configure/windows#clang
+platform(
+    name = "x64_windows-clang-cl",
+    constraint_values = [
+        "@platforms//cpu:x86_64",
+        "@platforms//os:windows",
+        "@bazel_tools//tools/cpp:clang-cl",
+    ],
+)
diff --git a/MODULE.bazel b/MODULE.bazel
index d3f2d0f..700b4ae 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -17,7 +17,7 @@
 
 # Last versions compatible w/ bazel6 https://github.com/chipsalliance/verible/issues/2336
 bazel_dep(name = "abseil-cpp", version = "20240116.2")
-bazel_dep(name = "protobuf", version = "28.3")
+bazel_dep(name = "protobuf", version = "31.0-rc2")
 
 bazel_dep(name = "googletest", version = "1.14.0.bcr.1", dev_dependency = True)
 
diff --git a/verible/common/formatting/BUILD b/verible/common/formatting/BUILD
index 65b100a..fcef277 100644
--- a/verible/common/formatting/BUILD
+++ b/verible/common/formatting/BUILD
@@ -133,9 +133,6 @@
         "layout-optimizer-internal.h",
     ],
     hdrs = ["layout-optimizer.h"],
-    # Can only add @abseil-cpp//absl/log:vlog_is_on after > absl 20240116
-    # https://github.com/chipsalliance/verible/issues/2336
-    features = ["-layering_check"],
     deps = [
         ":basic-format-style",
         ":format-token",
@@ -150,6 +147,7 @@
         "@abseil-cpp//absl/base:config",
         "@abseil-cpp//absl/container:fixed_array",
         "@abseil-cpp//absl/log",
+        "@abseil-cpp//absl/log:vlog_is_on",
         "@abseil-cpp//absl/strings",
     ],
 )
diff --git a/verible/verilog/analysis/BUILD b/verible/verilog/analysis/BUILD
index 2b084e2..9e1426a 100644
--- a/verible/verilog/analysis/BUILD
+++ b/verible/verilog/analysis/BUILD
@@ -164,9 +164,6 @@
         "verilog-analyzer.h",
         "verilog-excerpt-parse.h",
     ],
-    # Can only add @abseil-cpp//absl/log:vlog_is_on after > absl 20240116
-    # https://github.com/chipsalliance/verible/issues/2336
-    features = ["-layering_check"],
     deps = [
         "//verible/common/analysis:file-analyzer",
         "//verible/common/lexer:token-stream-adapter",
@@ -190,6 +187,7 @@
         "//verible/verilog/preprocessor:verilog-preprocess",
         "@abseil-cpp//absl/base:config",
         "@abseil-cpp//absl/log",
+        "@abseil-cpp//absl/log:vlog_is_on",
         "@abseil-cpp//absl/status",
         "@abseil-cpp//absl/strings",
     ],
@@ -244,9 +242,6 @@
     name = "verilog-linter",
     srcs = ["verilog-linter.cc"],
     hdrs = ["verilog-linter.h"],
-    # Can only add @abseil-cpp//absl/log:vlog_is_on after > absl 20240116
-    # https://github.com/chipsalliance/verible/issues/2336
-    features = ["-layering_check"],
     deps = [
         ":default-rules",
         ":lint-rule-registry",
@@ -273,6 +268,7 @@
         "@abseil-cpp//absl/base:config",
         "@abseil-cpp//absl/flags:flag",
         "@abseil-cpp//absl/log",
+        "@abseil-cpp//absl/log:vlog_is_on",
         "@abseil-cpp//absl/status",
         "@abseil-cpp//absl/status:statusor",
         "@abseil-cpp//absl/strings",
diff --git a/verible/verilog/parser/BUILD b/verible/verilog/parser/BUILD
index 29c00ca..5fb15cb 100644
--- a/verible/verilog/parser/BUILD
+++ b/verible/verilog/parser/BUILD
@@ -132,6 +132,7 @@
             "-Wno-implicit-fallthrough",
             "-Wno-type-limits",
             "-Wno-unreachable-code",
+            "-Wno-unused-but-set-variable",
         ],
     }),
     deps = [
diff --git a/verible/verilog/tools/ls/BUILD b/verible/verilog/tools/ls/BUILD
index da370de..8ef3f82 100644
--- a/verible/verilog/tools/ls/BUILD
+++ b/verible/verilog/tools/ls/BUILD
@@ -168,9 +168,6 @@
     name = "symbol-table-handler",
     srcs = ["symbol-table-handler.cc"],
     hdrs = ["symbol-table-handler.h"],
-    # Can only add @abseil-cpp//absl/log:vlog_is_on after > absl 20240116
-    # https://github.com/chipsalliance/verible/issues/2336
-    features = ["-layering_check"],
     deps = [
         ":lsp-conversion",
         ":lsp-parse-buffer",
@@ -192,6 +189,7 @@
         "@abseil-cpp//absl/container:flat_hash_map",
         "@abseil-cpp//absl/flags:flag",
         "@abseil-cpp//absl/log",
+        "@abseil-cpp//absl/log:vlog_is_on",
         "@abseil-cpp//absl/status",
         "@abseil-cpp//absl/status:statusor",
         "@abseil-cpp//absl/strings:str_format",