diff options
author | 2018-01-02 08:59:34 -0800 | |
---|---|---|
committer | 2018-01-02 09:01:06 -0800 | |
commit | e99279bcce475249e58543a5330fa35e59acd7e8 (patch) | |
tree | 965d4bbfa9caafefbcb27731d75cf90d2e863012 /tools | |
parent | a3fd5e76be71988035388c7e09c3257c8cbb2dd3 (diff) |
Use -no-canonical-prefixes when -fno-canonical-system-headers is not available
Bazel's autoconf script adds -fno-canonical-system-headers to gcc's crosstool
in order to get output in '.d' files that can be properly verified by bazel.
To workaround the same issue in clang we have to use a different flag:
'-no-canonical-prefixes'.
The same issue arises with clang if it resides in the configured repository
(e.g., when it is downloaded via 'repository_ctx.download').
PiperOrigin-RevId: 180552155
Diffstat (limited to 'tools')
-rw-r--r-- | tools/cpp/unix_cc_configure.bzl | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tools/cpp/unix_cc_configure.bzl b/tools/cpp/unix_cc_configure.bzl index 719756eab3..82f47f8783 100644 --- a/tools/cpp/unix_cc_configure.bzl +++ b/tools/cpp/unix_cc_configure.bzl @@ -197,6 +197,20 @@ def _is_gold_supported(repository_ctx, cc): ]) return result.return_code == 0 +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. + + # 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. + opt = _add_option_if_supported(repository_ctx, cc, + "-fno-canonical-system-headers") + if len(opt) == 0: + return _add_option_if_supported(repository_ctx, cc, + "-no-canonical-prefixes") + return opt def _crosstool_content(repository_ctx, cc, cpu_value, darwin): """Return the content for the CROSSTOOL file, in a dictionary.""" @@ -253,10 +267,7 @@ def _crosstool_content(repository_ctx, cc, cpu_value, darwin): "cxx_builtin_include_directory": get_escaped_cxx_inc_directories(repository_ctx, cc), "objcopy_embed_flag": ["-I", "binary"], "unfiltered_cxx_flag": - # 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. - _add_option_if_supported(repository_ctx, cc, "-fno-canonical-system-headers") + [ + _get_no_canonical_prefixes_opt(repository_ctx, cc) + [ # Make C++ compilation deterministic. Use linkstamping instead of these # compiler symbols. "-Wno-builtin-macro-redefined", |