From 810d60a7dcd4ea5c2e346d795b904a3231d53609 Mon Sep 17 00:00:00 2001 From: Damien Martin-Guillerez Date: Fri, 22 Apr 2016 21:13:48 +0000 Subject: [PATCH] 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 --- tools/cpp/cc_configure.bzl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl index f2a1d40f2c8426..27f4089881aa2e 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(