From 1b4c37c38804559b5c1ade6f9c93501875e231b0 Mon Sep 17 00:00:00 2001 From: Andrew Suffield Date: Tue, 19 Feb 2019 03:46:48 -0800 Subject: [PATCH] Always set --no-canonical-prefixes if we can -no-canonical-prefixes should be enough in all cases except very old compilers. For those, we keep using -fno-canonical-system-headers Closes #7316. PiperOrigin-RevId: 234574545 --- tools/cpp/unix_cc_configure.bzl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl index 588e33ba398dac..38db2fc3ac9581 100644 --- a/tools/cpp/unix_cc_configure.bzl +++ b/tools/cpp/unix_cc_configure.bzl @@ -202,20 +202,21 @@ def _get_no_canonical_prefixes_opt(repository_ctx, cc): # If the compiler sometimes rewrites paths in the .d files without symlinks # (ie when they're shorter), it confuses Bazel's logic for verifying all # #included header files are listed as inputs to the action. + # We also rely on symlinks not being resolved for remote builds. - # The '-fno-canonical-system-headers' should be enough, but clang does not - # support it, so we also try '-no-canonical-prefixes' if first option does - # not work. + # The '-no-canonical-prefixes' flag is enough in most cases. + # In case this flag is not supported (older gcc versions), we try to add + # '-fno-canonical-system-headers' instead. opt = _add_compiler_option_if_supported( repository_ctx, cc, - "-fno-canonical-system-headers", + "-no-canonical-prefixes", ) if len(opt) == 0: return _add_compiler_option_if_supported( repository_ctx, cc, - "-no-canonical-prefixes", + "-fno-canonical-system-headers", ) return opt