I simply didn't consider this case when I submitted https://github.com/bazelbuild/bazel/commit/ef3f05852b3bf542903f091184da96b96354a13d. Happy to (pre-)review a PR. A fix for this issue has been included in [Bazel 7.1.0 RC1](https://releases.bazel.build/7.1.0/rc1/index.html). Please test out the release candidate and report any issues as soon as possible. Thanks!
This should not be changed.
@bazel_tools//tools/cpp:compiler:gcc detection does not handle `gcc-10`
### Description of the bug:


Bazel's detection of GCC only works if the compiler executable name is exactly "gcc":

https://github.com/bazelbuild/bazel/blob/f06d00b8060b3b50f5dbc4a03b957c269ef62670/tools/cpp/unix_cc_configure.bzl#L273

Consequently, it fails to detect common variations like `gcc-10` as GCC.

### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.


CC=gcc-10 bazel ...

### Which operating system are you running Bazel on?


Linux

### What is the output of `bazel info release`?


release 6.1.0

### If `bazel info release` returns `development version` or `(@non-git)`, tell us how you built Bazel.


_No response_

### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?


_No response_

### Have you found anything relevant by searching the web?

_No response_

### Any other information, logs, or outputs that you want to share?

_No response_
MODULE.bazel.lock tools/cpp/unix_cc_configure.bzl
MODULE.bazel.lock tools/cpp/unix_cc_configure.bzl
src/test/tools/bzlmod/MODULE.bazel.lock
diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock
index 00927dd2728418..b290989d4724ac 100644
--- a/MODULE.bazel.lock
+++ b/MODULE.bazel.lock
@@ -2293,7 +2293,7 @@
       "general": {
         "bzlTransitiveDigest": "TaEUQXsOyJBUS1hp5pqPajfzBJlceug58PemF8nCEa8=",
         "accumulatedFileDigests": {
-          "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "0398b2a48c58023e0736fcb5b0937f39a3a95b4ed34941f482deb898ca3d21e1",
+          "@@//src/test/tools/bzlmod:MODULE.bazel.lock": "c61fe9fb628aaae087bfa754fc5d1f7a7d19b0d5debaf9bf84eb37fc1a365e71",
           "@@//:MODULE.bazel": "f0f6c040c50ad1d3555157b29dea32260bdaf5cc7205dfc346d4b1b6b008baca"
         },
         "envVariables": {},
diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl
index 5e7b3b79f427c9..ca8c1ba8ff7763 100644
--- a/tools/cpp/unix_cc_configure.bzl
+++ b/tools/cpp/unix_cc_configure.bzl
@@ -272,7 +272,8 @@ def _is_clang(repository_ctx, cc):
 def _is_gcc(repository_ctx, cc):
     # GCC's version output uses the basename of argv[0] as the program name:
     # https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/gcc.cc;h=158461167951c1b9540322fb19be6a89d6da07fc;hb=HEAD#l8728
-    return repository_ctx.execute([cc, "--version"]).stdout.startswith("gcc ")
+    cc_stdout = repository_ctx.execute([cc, "--version"]).stdout
+    return cc_stdout.startswith("gcc ") or cc_stdout.startswith("gcc-")
 
 def _get_compiler_name(repository_ctx, cc):
     if _is_clang(repository_ctx, cc):

diff --git a/src/test/tools/bzlmod/MODULE.bazel.lock b/src/test/tools/bzlmod/MODULE.bazel.lock
index 7b3d08135fdfed..58783496a694af 100644
--- a/src/test/tools/bzlmod/MODULE.bazel.lock
+++ b/src/test/tools/bzlmod/MODULE.bazel.lock
@@ -1002,7 +1002,7 @@
     },
     "@@bazel_tools//tools/cpp:cc_configure.bzl%cc_configure_extension": {
       "general": {
-        "bzlTransitiveDigest": "mcsWHq3xORJexV5/4eCvNOLxFOQKV6eli3fkr+tEaqE=",
+        "bzlTransitiveDigest": "PHpT2yqMGms2U4L3E/aZ+WcQalmZWm+ILdP3yiLsDhA=",
         "accumulatedFileDigests": {},
         "envVariables": {},
         "generatedRepoSpecs": {
