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
This commit is contained in:
Lexi Winter
2025-07-06 21:42:58 +01:00
parent 2d6185cf87
commit d3c06bed2c
4 changed files with 54 additions and 0 deletions
+6
View File
@@ -841,6 +841,11 @@ SRCS_MIN+= Tooling/ArgumentsAdjusters.cpp
SRCS_MIN+= Tooling/CommonOptionsParser.cpp SRCS_MIN+= Tooling/CommonOptionsParser.cpp
SRCS_MIN+= Tooling/CompilationDatabase.cpp SRCS_MIN+= Tooling/CompilationDatabase.cpp
SRCS_MIN+= Tooling/Core/Replacement.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/ExpandResponseFilesCompilationDatabase.cpp
SRCS_MIN+= Tooling/FileMatchTrie.cpp SRCS_MIN+= Tooling/FileMatchTrie.cpp
SRCS_MIN+= Tooling/GuessTargetAndModeCompilationDatabase.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/Inclusions/IncludeStyle.cpp
SRCS_MIN+= Tooling/InterpolatingCompilationDatabase.cpp SRCS_MIN+= Tooling/InterpolatingCompilationDatabase.cpp
SRCS_MIN+= Tooling/JSONCompilationDatabase.cpp SRCS_MIN+= Tooling/JSONCompilationDatabase.cpp
SRCS_MIN+= Tooling/LocateToolCompilationDatabase.cpp
SRCS_MIN+= Tooling/Refactoring.cpp SRCS_MIN+= Tooling/Refactoring.cpp
SRCS_MIN+= Tooling/RefactoringCallbacks.cpp SRCS_MIN+= Tooling/RefactoringCallbacks.cpp
SRCS_MIN+= Tooling/Tooling.cpp SRCS_MIN+= Tooling/Tooling.cpp
+4
View File
@@ -5,6 +5,10 @@ SUBDIR+= clang
.endif .endif
.if !defined(TOOLS_PREFIX) .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 # 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 # by default if clang is enabled. If MK_LLVM_BINUTILS is set, we also use them
# as the default binutils (ar,nm,addr2line, etc.). # as the default binutils (ar,nm,addr2line, etc.).
+26
View File
@@ -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"
@@ -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});
}