From 172c29862c2bad21fff84e2798cc3fd16822ec57 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Tue, 10 Jun 2025 11:05:20 +0200 Subject: Add IWYU support to clang 20 toolchain --- README.md | 2 +- etc/repos.json | 12 ++++++++++++ src/compilers/clang-20-native.TARGETS | 12 ++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 64a1614..9a33264 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,7 @@ Fields for building the toolchains: - `INCLUDE_LINTER`: Add linter to toolchain if supported. (default: `false`) Currently this option is only supported by `clang` toolchains, adding - `clang-tidy`. Additionally, Clang versions `18` and `19` will also include + `clang-tidy`. Additionally, Clang versions `18` and newer will also include the *external project* [Include What You Use](https://github.com/include-what-you-use/include-what-you-use). diff --git a/etc/repos.json b/etc/repos.json index c77def8..3aab324 100644 --- a/etc/repos.json +++ b/etc/repos.json @@ -525,6 +525,7 @@ { "rules": "rules/clang_with_gcc14" , "binutils": "imports/binutils-latest" , "patches": "patches" + , "iwyu": "iwyu-20" } } , "tools/busybox-1.36.1": @@ -904,6 +905,17 @@ , "target_file_name": "iwyu.TARGETS" , "target_root": "imports" } + , "iwyu-20": + { "repository": + { "type": "archive" + , "content": "7fc1e96d2aaab23daa3783c82a9214db4dbb3c52" + , "fetch": "https://github.com/include-what-you-use/include-what-you-use/archive/refs/tags/0.24.tar.gz" + , "sha256": "897b4c864a983f493c8efef4a1a9a2d429fd7ead1011f7a41743ed7b6dbe8c2e" + , "subdir": "include-what-you-use-0.24" + } + , "target_file_name": "iwyu.TARGETS" + , "target_root": "imports" + } , "patches/busybox-1593": { "repository": { "type": "foreign file" diff --git a/src/compilers/clang-20-native.TARGETS b/src/compilers/clang-20-native.TARGETS index 838106c..047f7c8 100644 --- a/src/compilers/clang-20-native.TARGETS +++ b/src/compilers/clang-20-native.TARGETS @@ -65,7 +65,7 @@ { "type": ["@", "rules", "CC/foreign/shell", "data"] , "arguments_config": ["TOOLCHAIN_CONFIG"] , "project": ["patched_sources"] - , "localbase": ["binutils_dir"] + , "localbase": ["binutils_dir", ["@", "iwyu", "", "sources"]] , "cmds": [ { "type": "join" , "$1": @@ -161,7 +161,15 @@ , "default": {"type": "empty_map"} } } - , "then": "-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra'" + , "then": + { "type": "join" + , "separator": " " + , "$1": + [ "-DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra'" + , "-DLLVM_EXTERNAL_PROJECTS=iwyu" + , "-DLLVM_EXTERNAL_IWYU_SOURCE_DIR=${LOCALBASE}/iwyu" + ] + } , "else": "-DLLVM_ENABLE_PROJECTS=clang" } , "-DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind'" -- cgit v1.2.3