git: d3c06bed2c16 - main - clang: install clang-scan-deps
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 06 Jul 2025 21:02:58 UTC
The branch main has been updated by ivy:
URL: https://cgit.FreeBSD.org/src/commit/?id=d3c06bed2c16b434dd49958dee5de8c55ad00b85
commit d3c06bed2c16b434dd49958dee5de8c55ad00b85
Author: Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2025-07-06 20:42:58 +0000
Commit: Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2025-07-06 21:02:52 +0000
clang: install clang-scan-deps
clang-scan-deps is used to generate dependency information from C++20
modules according to proposed standard ISO/IEC WG21 P1689R5[0]. It is
required by common build tools (e.g., CMake) to build C++ sources
that use modules.
Since this is a core build tool, install it by default, not gated
behind MK_CLANG_EXTRAS.
[0] https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2022/p1689r5.html
MFC after: 3 days
Reviewed by: kevans, dim
Approved by: kevans (mentor)
Requested by: jbo
Differential Revision: https://reviews.freebsd.org/D51044
---
lib/clang/libclang/Makefile | 6 +++++
usr.bin/clang/Makefile | 4 ++++
usr.bin/clang/clang-scan-deps/Makefile | 26 ++++++++++++++++++++++
.../clang-scan-deps/clang-scan-deps-driver.cpp | 18 +++++++++++++++
4 files changed, 54 insertions(+)
diff --git a/lib/clang/libclang/Makefile b/lib/clang/libclang/Makefile
index dc9e0010e309..7eb2c99b25c8 100644
--- a/lib/clang/libclang/Makefile
+++ b/lib/clang/libclang/Makefile
@@ -841,6 +841,11 @@ SRCS_MIN+= Tooling/ArgumentsAdjusters.cpp
SRCS_MIN+= Tooling/CommonOptionsParser.cpp
SRCS_MIN+= Tooling/CompilationDatabase.cpp
SRCS_MIN+= Tooling/Core/Replacement.cpp
+SRCS_MIN+= Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+SRCS_MIN+= Tooling/DependencyScanning/DependencyScanningService.cpp
+SRCS_MIN+= Tooling/DependencyScanning/DependencyScanningTool.cpp
+SRCS_MIN+= Tooling/DependencyScanning/DependencyScanningWorker.cpp
+SRCS_MIN+= Tooling/DependencyScanning/ModuleDepCollector.cpp
SRCS_MIN+= Tooling/ExpandResponseFilesCompilationDatabase.cpp
SRCS_MIN+= Tooling/FileMatchTrie.cpp
SRCS_MIN+= Tooling/GuessTargetAndModeCompilationDatabase.cpp
@@ -848,6 +853,7 @@ SRCS_MIN+= Tooling/Inclusions/HeaderIncludes.cpp
SRCS_MIN+= Tooling/Inclusions/IncludeStyle.cpp
SRCS_MIN+= Tooling/InterpolatingCompilationDatabase.cpp
SRCS_MIN+= Tooling/JSONCompilationDatabase.cpp
+SRCS_MIN+= Tooling/LocateToolCompilationDatabase.cpp
SRCS_MIN+= Tooling/Refactoring.cpp
SRCS_MIN+= Tooling/RefactoringCallbacks.cpp
SRCS_MIN+= Tooling/Tooling.cpp
diff --git a/usr.bin/clang/Makefile b/usr.bin/clang/Makefile
index a0cc015590f0..e2debfb8c582 100644
--- a/usr.bin/clang/Makefile
+++ b/usr.bin/clang/Makefile
@@ -5,6 +5,10 @@ SUBDIR+= clang
.endif
.if !defined(TOOLS_PREFIX)
+.if ${MK_CLANG} != "no"
+SUBDIR+= clang-scan-deps
+.endif
+
# LLVM binutils are needed to support features such as LTO, so we build them
# by default if clang is enabled. If MK_LLVM_BINUTILS is set, we also use them
# as the default binutils (ar,nm,addr2line, etc.).
diff --git a/usr.bin/clang/clang-scan-deps/Makefile b/usr.bin/clang/clang-scan-deps/Makefile
new file mode 100644
index 000000000000..16fecdb88867
--- /dev/null
+++ b/usr.bin/clang/clang-scan-deps/Makefile
@@ -0,0 +1,26 @@
+.include <src.opts.mk>
+
+PROG_CXX= clang-scan-deps
+MAN=
+
+SRCDIR= clang/tools/clang-scan-deps
+SRCS+= ClangScanDeps.cpp \
+ clang-scan-deps-driver.cpp
+
+.include "${SRCTOP}/lib/clang/clang.pre.mk"
+
+CFLAGS+= -I${.OBJDIR}
+TDFILE= Opts.td
+INCFILE= ${TDFILE:.td=.inc}
+GENOPT= -gen-opt-parser-defs
+
+${INCFILE}: ${TDFILE}
+ ${LLVM_TBLGEN} ${GENOPT} -I ${LLVM_SRCS}/include -d ${.TARGET:C/$/.d/} \
+ -o ${.TARGET} ${.ALLSRC}
+TGHDRS+= ${INCFILE}
+
+DEPENDFILES+= ${TGHDRS:C/$/.d/}
+DPSRCS+= ${TGHDRS}
+CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}
+
+.include "../clang.prog.mk"
diff --git a/usr.bin/clang/clang-scan-deps/clang-scan-deps-driver.cpp b/usr.bin/clang/clang-scan-deps/clang-scan-deps-driver.cpp
new file mode 100644
index 000000000000..f941cc434ff6
--- /dev/null
+++ b/usr.bin/clang/clang-scan-deps/clang-scan-deps-driver.cpp
@@ -0,0 +1,18 @@
+//===-- driver-template.cpp -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/LLVMDriver.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/InitLLVM.h"
+
+int clang_scan_deps_main(int argc, char **, const llvm::ToolContext &);
+
+int main(int argc, char **argv) {
+ llvm::InitLLVM X(argc, argv);
+ return clang_scan_deps_main(argc, argv, {argv[0], nullptr, false});
+}