aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-08-02 19:07:22 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-08-02 19:07:22 +0200
commitd9a893a554d6077f5cab4aa8a81f24213443232e (patch)
treead7c6ccd2373fe3fd36183f7d9be114e8503b7ac /Makefile
parent5cbdd9f4445514cbacadc362c2891e40b7f36072 (diff)
Makefile: don't compile all targets into target binaries
Currently target binaries contain support for all OS/arch combinations. However, obviously a fuchsia target binary won't test windows. For target binaries we need support only for a single target (with the exception of 386/arm target in amd64/arm64 binaries). So compile in only _the_ target into target binaries. This reduces akaros/amd64 fuzzer binary from 33 to 7 MB and execprog from 28 to 2 MB.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile43
1 files changed, 23 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index bdfe36938..f23eb3214 100644
--- a/Makefile
+++ b/Makefile
@@ -49,11 +49,6 @@ ifeq ("$(TARGETOS)", "fuchsia")
GO = "$(SOURCEDIR)/scripts/devshell/go"
endif
-ifeq ("$(TARGETOS)", "akaros")
- TARGETGOOS := $(HOSTOS)
- TARGETGOARCH := $(HOSTARCH)
-endif
-
GITREV=$(shell git rev-parse HEAD)
ifeq ("$(shell git diff --shortstat)", "")
REV=$(GITREV)
@@ -66,8 +61,16 @@ endif
# That's only needed if you use gdb or nm.
# If you need that, build manually without these flags.
GOFLAGS := "-ldflags=-s -w -X github.com/google/syzkaller/sys.GitRevision=$(REV)"
+GOHOSTFLAGS := $(GOFLAGS)
+GOTARGETFLAGS := $(GOFLAGS)
ifneq ("$(GOTAGS)", "")
- GOFLAGS += "-tags=$(GOTAGS)"
+ GOHOSTFLAGS += "-tags=$(GOTAGS)"
+endif
+GOTARGETFLAGS += "-tags=syz_target syz_os_$(TARGETOS) syz_arch_$(TARGETVMARCH) $(GOTAGS)"
+
+ifeq ("$(TARGETOS)", "akaros")
+ TARGETGOOS := $(HOSTOS)
+ TARGETGOARCH := $(HOSTARCH)
endif
.PHONY: all host target \
@@ -103,42 +106,42 @@ executor:
-DGOOS_$(TARGETOS)=1 -DGOARCH_$(TARGETARCH)=1 -DGIT_REVISION=\"$(REV)\"
manager:
- GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOFLAGS) -o ./bin/syz-manager github.com/google/syzkaller/syz-manager
+ GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-manager github.com/google/syzkaller/syz-manager
fuzzer:
- GOOS=$(TARGETGOOS) GOARCH=$(TARGETGOARCH) $(GO) build $(GOFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-fuzzer$(EXE) github.com/google/syzkaller/syz-fuzzer
+ GOOS=$(TARGETGOOS) GOARCH=$(TARGETGOARCH) $(GO) build $(GOTARGETFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-fuzzer$(EXE) github.com/google/syzkaller/syz-fuzzer
execprog:
- GOOS=$(TARGETGOOS) GOARCH=$(TARGETGOARCH) $(GO) build $(GOFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-execprog$(EXE) github.com/google/syzkaller/tools/syz-execprog
+ GOOS=$(TARGETGOOS) GOARCH=$(TARGETGOARCH) $(GO) build $(GOTARGETFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-execprog$(EXE) github.com/google/syzkaller/tools/syz-execprog
ci:
- GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOFLAGS) -o ./bin/syz-ci github.com/google/syzkaller/syz-ci
+ GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-ci github.com/google/syzkaller/syz-ci
hub:
- GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOFLAGS) -o ./bin/syz-hub github.com/google/syzkaller/syz-hub
+ GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-hub github.com/google/syzkaller/syz-hub
repro:
- GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOFLAGS) -o ./bin/syz-repro github.com/google/syzkaller/tools/syz-repro
+ GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-repro github.com/google/syzkaller/tools/syz-repro
mutate:
- GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOFLAGS) -o ./bin/syz-mutate github.com/google/syzkaller/tools/syz-mutate
+ GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-mutate github.com/google/syzkaller/tools/syz-mutate
prog2c:
- GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOFLAGS) -o ./bin/syz-prog2c github.com/google/syzkaller/tools/syz-prog2c
+ GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-prog2c github.com/google/syzkaller/tools/syz-prog2c
stress:
- GOOS=$(TARGETGOOS) GOARCH=$(TARGETGOARCH) $(GO) build $(GOFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-stress$(EXE) github.com/google/syzkaller/tools/syz-stress
+ GOOS=$(TARGETGOOS) GOARCH=$(TARGETGOARCH) $(GO) build $(GOTARGETFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-stress$(EXE) github.com/google/syzkaller/tools/syz-stress
db:
- GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOFLAGS) -o ./bin/syz-db github.com/google/syzkaller/tools/syz-db
+ GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-db github.com/google/syzkaller/tools/syz-db
upgrade:
- GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOFLAGS) -o ./bin/syz-upgrade github.com/google/syzkaller/tools/syz-upgrade
+ GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o ./bin/syz-upgrade github.com/google/syzkaller/tools/syz-upgrade
extract: bin/syz-extract
bin/syz-extract -build -os=$(TARGETOS) -sourcedir=$(SOURCEDIR) $(FILES)
bin/syz-extract:
- GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOFLAGS) -o $@ ./sys/syz-extract
+ GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(HOSTGO) build $(GOHOSTFLAGS) -o $@ ./sys/syz-extract
generate: generate_go generate_sys
$(MAKE) format
@@ -150,7 +153,7 @@ generate_sys: bin/syz-sysgen
bin/syz-sysgen
bin/syz-sysgen:
- $(GO) build $(GOFLAGS) -o $@ ./sys/syz-sysgen
+ $(GO) build $(GOHOSTFLAGS) -o $@ ./sys/syz-sysgen
format: format_go format_cpp format_sys
@@ -170,7 +173,7 @@ format_sys: bin/syz-fmt
bin/syz-fmt sys/windows
bin/syz-fmt:
- $(GO) build $(GOFLAGS) -o $@ ./tools/syz-fmt
+ $(GO) build $(GOHOSTFLAGS) -o $@ ./tools/syz-fmt
tidy:
# A single check is enabled for now. But it's always fixable and proved to be useful.