diff options
| author | Florent Revest <revest@chromium.org> | 2026-01-12 18:58:23 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2026-01-20 19:22:54 +0000 |
| commit | cf20fe98a57b940f293234cb22c3cd51a1c9fa9d (patch) | |
| tree | 7078798cbd69c2c1fbdf50a54c99c32edd8336a7 | |
| parent | 4aba25c79aa71d1a21427a5be778198d9d0b698f (diff) | |
tools/clang/codesearch: support building with make
Currently, clang tools are built by copying their code into a
llvm-project repository and adding build rule to LLVM's CMake. This
allows pinning a specific LLVM hash which is convenient but it's also a
bit painful to copy code across repositories.
This adds a rule to make that can build syz-codesearch with a simple g++
invocation that uses llvm-config to get the LLVM compiler and linker
flags and hardcodes some clang libraries to link against since I could
not find a better way. (llvm-config does not have "components" for
clang)
| -rw-r--r-- | Makefile | 11 | ||||
| -rw-r--r-- | tools/clang/codesearch/README.md | 3 |
2 files changed, 12 insertions, 2 deletions
@@ -114,7 +114,7 @@ endif check_copyright check_language check_whitespace check_links check_diff check_commits check_shebang check_html \ presubmit presubmit_aux presubmit_build presubmit_arch_linux presubmit_arch_freebsd \ presubmit_arch_netbsd presubmit_arch_openbsd presubmit_arch_darwin presubmit_arch_windows \ - presubmit_arch_executor presubmit_dashboard presubmit_race presubmit_race_dashboard presubmit_old + presubmit_arch_executor presubmit_dashboard presubmit_race presubmit_race_dashboard presubmit_old codesearch all: host target host: manager repro mutate prog2c db upgrade @@ -240,6 +240,15 @@ extract: bin/syz-extract bin/syz-extract: GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o $@ ./sys/syz-extract +codesearch: bin/syz-codesearch + +bin/syz-codesearch: tools/clang/codesearch/codesearch.cpp + $(CXX) -Itools/clang $(shell llvm-config --cxxflags) -o $@ $< \ + -lclangTooling -lclangFrontend -lclangSerialization -lclangDriver \ + -lclangToolingCore -lclangParse -lclangSema -lclangAPINotes -lclangAnalysis \ + -lclangASTMatchers -lclangRewrite -lclangEdit -lclangAST -lclangLex -lclangBasic -lclangSupport \ + $(shell llvm-config --ldflags --libs --system-libs) + # `generate` does *not* depend on any kernel sources, and generates everything # in one pass, for all arches. It can be run on a bare syzkaller checkout. generate: diff --git a/tools/clang/codesearch/README.md b/tools/clang/codesearch/README.md index 3f444f61d..6d876c78e 100644 --- a/tools/clang/codesearch/README.md +++ b/tools/clang/codesearch/README.md @@ -5,4 +5,5 @@ Clang-based tool that indexes kernel source code to power agentic tool. The tool can be built following the procedure described for -[syz-declextract tool](/tools/syz-declextract/README.md). +[syz-declextract tool](/tools/syz-declextract/README.md) or with `make +codesearch`. |
