From 5200c9b627e4f0c6c8206cf68e58d7dc58667ea8 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Wed, 25 Oct 2023 14:35:09 +0200 Subject: [PATCH] Add clang resource share directory to search path This is needed e.g. when using `-fsanitize=address` which would otherwise fail with: ``` this rule is missing dependency declarations for the following files included by ... '/nix/store/9k6s3zmhj2pvkg8a5s8n7d2sbpffv8hv-clang-wrapper-16.0.1/resource-root/share/asan_ignorelist.txt' ``` Fixes #430 --- toolchains/cc/cc.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/toolchains/cc/cc.nix b/toolchains/cc/cc.nix index 77725e1a2..da7f21ae5 100644 --- a/toolchains/cc/cc.nix +++ b/toolchains/cc/cc.nix @@ -143,6 +143,12 @@ pkgs.runCommand "bazel-${cc.orignalName or cc.name}-toolchain" | xargs -0 -r realpath -ms } CXX_BUILTIN_INCLUDE_DIRECTORIES=($({ + if is_compiler_option_supported -print-resource-dir; then + resource_dir="$( $cc -print-resource-dir )" + if [ -d "$resource_dir/share" ]; then + echo "$resource_dir/share" + fi + fi include_dirs_for c include_dirs_for c++ if is_compiler_option_supported -fno-canonical-system-headers; then