aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2016-04-22 21:13:48 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-04-22 21:21:05 +0000
commit810d60a7dcd4ea5c2e346d795b904a3231d53609 (patch)
treec90e318d40c916d8e2a6368d9fdecc4a3d1897f7 /tools
parent2036dbd666a3e6430480bcbe333c77376d35bc63 (diff)
cc_configure: Add -B to compiler flag too
On some target platform gcc invokes external tools during compilation, see #1152. Also support absolute path when looking for gcc. This needs to be cherry-picked to fix #1177. -- MOS_MIGRATED_REVID=120581887
Diffstat (limited to 'tools')
-rw-r--r--tools/cpp/cc_configure.bzl8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl
index f2a1d40f2c..27f4089881 100644
--- a/tools/cpp/cc_configure.bzl
+++ b/tools/cpp/cc_configure.bzl
@@ -213,7 +213,10 @@ def _crosstool_content(repository_ctx, cc, cpu_value, darwin):
# Enable a few more warnings that aren't part of -Wall.
] + (["-Wthread-safety", "-Wself-assign"] if darwin else [
# Disable some that are problematic.
- "-Wl,-z,-relro,-z,now"
+ "-Wl,-z,-relro,-z,now",
+ "-B" + str(repository_ctx.path(cc).dirname),
+ # Always have -B/usr/bin, see https://github.com/bazelbuild/bazel/issues/760.
+ "-B/usr/bin",
]) + (
_add_option_if_supported(repository_ctx, cc, "-Wunused-but-set-parameter") +
# has false positives
@@ -264,6 +267,9 @@ def _find_cc(repository_ctx):
cc_name = "gcc"
if "CC" in repository_ctx.os.environ:
cc_name = repository_ctx.os.environ["CC"]
+ 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(