Guard -pass-exit-codes to support clang

Currently using CC=clang will fail because -pass-exit-codes is an
unsupported option (Github issue #2121).

This is a minimal fix to add a guard for this option.

--
Change-Id: I86c3415ea7280a3af1d5579c1374bfa74ce31b5d
Reviewed-on: https://cr.bazel.build/8070
PiperOrigin-RevId: 142829737
MOS_MIGRATED_REVID=142829737
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl
index 8d33a67..787cb82 100644
--- a/tools/cpp/cc_configure.bzl
+++ b/tools/cpp/cc_configure.bzl
@@ -229,15 +229,16 @@
               "-B" + str(repository_ctx.path(cc).dirname),
               # Always have -B/usr/bin, see https://github.com/bazelbuild/bazel/issues/760.
               "-B/usr/bin",
-              # Have gcc return the exit code from ld.
-              "-pass-exit-codes",
               # Stamp the binary with a unique identifier.
               "-Wl,--build-id=md5",
               "-Wl,--hash-style=gnu"
               # Gold linker only? Can we enable this by default?
               # "-Wl,--warn-execstack",
               # "-Wl,--detect-odr-violations"
-          ]
+          ] + _add_option_if_supported(
+              # Have gcc return the exit code from ld.
+              repository_ctx, cc, "-pass-exit-codes"
+          )
       ),
       "ar_flag": ["-static", "-s", "-o"] if darwin else [],
       "cxx_builtin_include_directory": _get_cxx_inc_directories(repository_ctx, cc),