C++: Adds clang resource-dir to include paths to be searched
Fixes #10510
RELNOTES:none
PiperOrigin-RevId: 297089846
Change-Id: I06e0c6557fd83698a096b2b23a78895b1ec78500
diff --git a/cc/private/toolchain/unix_cc_configure.bzl b/cc/private/toolchain/unix_cc_configure.bzl
index cbe6f91..cacc29c 100644
--- a/cc/private/toolchain/unix_cc_configure.bzl
+++ b/cc/private/toolchain/unix_cc_configure.bzl
@@ -149,11 +149,19 @@
else:
inc_dirs = result.stderr[index1 + 1:index2].strip()
- return [
+ inc_directories = [
_prepare_include_path(repository_ctx, _cxx_inc_convert(p))
for p in inc_dirs.split("\n")
]
+ if _is_compiler_option_supported(repository_ctx, cc, "-print-resource-dir"):
+ resource_dir = repository_ctx.execute(
+ [cc, "-print-resource-dir"],
+ ).stdout.strip() + "/share"
+ inc_directories.append(_prepare_include_path(repository_ctx, resource_dir))
+
+ return inc_directories
+
def _is_compiler_option_supported(repository_ctx, cc, option):
"""Checks that `option` is supported by the C compiler. Doesn't %-escape the option."""
result = repository_ctx.execute([