From febe0937cf4394bc0f908e13fd0b6ab63b2c29c2 Mon Sep 17 00:00:00 2001 From: "Klaus T. Aehlig" Date: Fri, 13 Jun 2025 16:31:32 +0200 Subject: clang-tidy: use bundled header files A typical compiler implicitly adds some search directories for system headers; those might not be obvious for the bootstrapped clang-tidy. Therefore, use the bundled headers of the clang toolchain. This has the additional advantage, that everyone uses the same system headers for linting. --- lint/run_clang_tidy.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'lint/run_clang_tidy.py') diff --git a/lint/run_clang_tidy.py b/lint/run_clang_tidy.py index 3fb8a595..7f48e007 100755 --- a/lint/run_clang_tidy.py +++ b/lint/run_clang_tidy.py @@ -19,6 +19,7 @@ import shutil import subprocess import sys +CXX_LIB_VERSION = "13.3.0" def dump_meta(src, cmd): OUT = os.environ.get("OUT") @@ -31,7 +32,24 @@ def run_lint(src, cmd): dump_meta(src, cmd) config = os.environ.get("CONFIG") shutil.copyfile(os.path.join(config, ".clang-tidy"), ".clang-tidy") - extra = ["-Wno-unused-command-line-argument"] + extra = [ "-Wno-unused-command-line-argument"] + + # add include paths from the bundled toolchain + baseincludepath = os.path.join( + config, "toolchain", "include", "c++", CXX_LIB_VERSION + ) + # We're using the native toolchain, so arch-specific headers are + # only available for one arch. Hence we can try all supported candidates + # and add the ones found + for arch in ["x86_64", "arm"]: + idir = os.path.join(baseincludepath, + "%s-pc-linux-gnu" % (arch,)) + if os.path.exists(idir): + extra += ["-isystem", idir] + extra += [ + "-isystem", baseincludepath, + ] + if src.endswith(".tpp"): extra += ["-x", "c++"] db = [{ -- cgit v1.2.3