diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2026-02-05 13:59:08 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2026-02-06 09:29:18 +0000 |
| commit | fd36daf55d7f9e8ab412fcbf0441658a8d8be727 (patch) | |
| tree | 6d0a982741820007d1a15212e0227df85eb1b501 /Makefile | |
| parent | f03c419189ef8ed823e306a342ee4d330fb2c394 (diff) | |
tools/clang: compile clang tools into the binary
Compiled clang tools into Go binaries using cgo.
This significantly simplifies building and deployment.
This also enables unit testing of clang tools.
Now raw go test for clang tools will build them, run,
and verify output.
Each clang tool is still started as a subprocess.
I've experimented with running them in-process,
but this makes stdout/stderr interception extremly complicated,
and it seems that clang tools still use unsynchronized global state,
which breaks when invoked multiple times.
Subprocesses also make it safer in the face of potential memory leaks,
or memory corruptions in clang tools.
Fixes #6645
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 18 |
1 files changed, 5 insertions, 13 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 codesearch + presubmit_arch_executor presubmit_dashboard presubmit_race presubmit_race_dashboard presubmit_old all: host target host: manager repro mutate prog2c db upgrade @@ -173,7 +173,8 @@ hub: descriptions GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-hub github.com/google/syzkaller/syz-hub agent: descriptions - GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-agent github.com/google/syzkaller/syz-agent + # syz-agent uses codesearch clang tool which requires cgo. + CGO_ENABLED=1 GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-agent github.com/google/syzkaller/syz-agent repro: descriptions GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-repro github.com/google/syzkaller/tools/syz-repro @@ -240,16 +241,6 @@ 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/* tools/clang/* - mkdir -p bin - $(CXX) -Itools/clang $(shell llvm-config --cxxflags) -O2 -o $@ tools/clang/codesearch/codesearch.cpp \ - -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: @@ -407,7 +398,8 @@ presubmit_gvisor: host target ./tools/gvisor-smoke-test.sh test: descriptions - $(GO) test -short -coverprofile=.coverage.txt ./... + # Clang tools require cgo. + CGO_ENABLED=1 $(GO) test -short -coverprofile=.coverage.txt ./... clean: rm -rf ./bin .descriptions executor/defs.h executor/syscalls.h sys/gen sys/register.go |
