diff --git a/cc/private/toolchain/unix_cc_configure.bzl b/cc/private/toolchain/unix_cc_configure.bzl index fe485d81f..5aed02659 100644 --- a/cc/private/toolchain/unix_cc_configure.bzl +++ b/cc/private/toolchain/unix_cc_configure.bzl @@ -276,7 +276,13 @@ 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 cc_stdout = repository_ctx.execute([cc, "--version"]).stdout - return cc_stdout.startswith("gcc ") or cc_stdout.startswith("gcc-") + if cc_stdout.startswith("gcc ") or cc_stdout.startswith("gcc-"): + return True + + # As a fallback, also check specs output in case argv[0] was a symlink. + specs = repository_ctx.execute([cc, "-v"]).stderr + last_line = specs.rstrip("\n").split("\n")[-1] + return "gcc version " in last_line def _get_compiler_name(repository_ctx, cc): if _is_clang(repository_ctx, cc):