diff options
author | 2017-04-10 06:44:08 +0000 | |
---|---|---|
committer | 2017-04-10 11:48:44 +0200 | |
commit | 6ac454a99672547a8d9709e326e573fd51b6bf8a (patch) | |
tree | c1285bd06cff99fce774ba74ad531ce3d5065f15 | |
parent | fe913c11dcbad2a65ac4626cf7d943af1642e742 (diff) |
Provide more information regarding compiler
This addresses #2761, to provide a minor improvement if neither `gcc` or `CC` are found on the path.
Let me know if you would like anything changed!
Local qualification steps:
```
$ cd bazel
$ git rebase 0.4.5 # Did not want to spend too much time synchronizing derived stuff in master
$ ln -s ~/Downloads/bazel-0.4.5-dist/derived .
$ ./compile.sh
$ export PATH=~+/output/bazel;$PATH
$ cd .../someproject
$ CC=clang-9000 bazel build //package:test
Cannot find gcc or CC (clang-9000), either correct your path or set the CC environment variable.
```
Closes #2773.
PiperOrigin-RevId: 152658002
-rw-r--r-- | tools/cpp/cc_configure.bzl | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl index cf49718485..73653e9d10 100644 --- a/tools/cpp/cc_configure.bzl +++ b/tools/cpp/cc_configure.bzl @@ -388,18 +388,21 @@ def _get_system_root(repository_ctx): def _find_cc(repository_ctx): """Find the C++ compiler.""" cc_name = "gcc" - if "CC" in repository_ctx.os.environ: - cc_name = repository_ctx.os.environ["CC"].strip() - if not cc_name: - cc_name = "gcc" + cc_environ = repository_ctx.os.environ.get("CC") + cc_paren = "" + if cc_environ != None: + cc_environ = cc_environ.strip() + if cc_environ: + cc_name = cc_environ + cc_paren = " (%s)" % cc_environ if cc_name.startswith("/"): # Absolute path, maybe we should make this suported by our which function. return cc_name cc = repository_ctx.which(cc_name) if cc == None: fail( - "Cannot find gcc, either correct your path or set the CC" + - " environment variable") + ("Cannot find gcc or CC%s, either correct your path or set the CC" + + " environment variable") % cc_paren) return cc |