From ada7557073de86aa26dc6304bceeae76f212486a Mon Sep 17 00:00:00 2001 From: Stefan Wiehler Date: Fri, 8 Aug 2025 17:42:58 +0200 Subject: Makefile: consider GOHOSTFLAGS for ENV variable and descriptions target When building with the Yocto go-mod class, the -modcacherw flag appended to GOHOSTFLAGS must be considered in all build steps to make the go cache writeable (deletable). --- Makefile | 58 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5118cefe1..6fc9c1c51 100644 --- a/Makefile +++ b/Makefile @@ -32,11 +32,38 @@ $(warning $(RED)run command via tools/syz-env for best compatibility, see:$(RESE $(warning $(RED)https://github.com/google/syzkaller/blob/master/docs/contributing.md#using-syz-env$(RESET)) endif +GITREV=$(shell git rev-parse HEAD) +ifeq ("$(shell git diff --shortstat)", "") + REV=$(GITREV) +else + REV=$(GITREV)+ +endif +GITREVDATE=$(shell git log -n 1 --format="%cd" --date=format:%Y%m%d-%H%M%S) + +# Don't generate symbol table and DWARF debug info. +# Reduces build time and binary sizes considerably. +# That's only needed if you use gdb or nm. +# If you need that, build manually with DEBUG=true env. +GLFLAGS := +GGFLAGS := +ifeq ("$(DEBUG)", "true") + GGFLAGS := -gcflags="all=-N -l" +else + GLFLAGS := -s -w +endif +GOFLAGS := -ldflags="$(GLFLAGS) -X github.com/google/syzkaller/prog.GitRevision=$(REV) -X github.com/google/syzkaller/prog.gitRevisionDate=$(GITREVDATE)" $(GGFLAGS) +ifneq ("$(GOTAGS)", "") + GOFLAGS += " -tags=$(GOTAGS)" +endif + +GOHOSTFLAGS ?= $(GOFLAGS) +GOTARGETFLAGS ?= $(GOFLAGS) + ENV := $(subst \n,$(newline),$(shell CI=$(CI)\ SOURCEDIR=$(SOURCEDIR) HOSTOS=$(HOSTOS) HOSTARCH=$(HOSTARCH) \ TARGETOS=$(TARGETOS) TARGETARCH=$(TARGETARCH) TARGETVMARCH=$(TARGETVMARCH) \ SYZ_CLANG=$(SYZ_CLANG) \ - go run tools/syz-make/make.go)) + go run $(GOHOSTFLAGS) tools/syz-make/make.go)) # Uncomment in case of emergency. # $(info $(ENV)) $(eval $(ENV)) @@ -61,33 +88,6 @@ TARGETGOARCH := $(TARGETVMARCH) export GO111MODULE=on export GOBIN=$(shell pwd -P)/bin -GITREV=$(shell git rev-parse HEAD) -ifeq ("$(shell git diff --shortstat)", "") - REV=$(GITREV) -else - REV=$(GITREV)+ -endif -GITREVDATE=$(shell git log -n 1 --format="%cd" --date=format:%Y%m%d-%H%M%S) - -# Don't generate symbol table and DWARF debug info. -# Reduces build time and binary sizes considerably. -# That's only needed if you use gdb or nm. -# If you need that, build manually with DEBUG=true env. -GLFLAGS := -GGFLAGS := -ifeq ("$(DEBUG)", "true") - GGFLAGS := -gcflags="all=-N -l" -else - GLFLAGS := -s -w -endif -GOFLAGS := -ldflags="$(GLFLAGS) -X github.com/google/syzkaller/prog.GitRevision=$(REV) -X github.com/google/syzkaller/prog.gitRevisionDate=$(GITREVDATE)" $(GGFLAGS) -ifneq ("$(GOTAGS)", "") - GOFLAGS += " -tags=$(GOTAGS)" -endif - -GOHOSTFLAGS ?= $(GOFLAGS) -GOTARGETFLAGS ?= $(GOFLAGS) - ifeq ("$(TARGETOS)", "test") TARGETGOOS := $(HOSTOS) TARGETGOARCH := $(HOSTARCH) @@ -150,7 +150,7 @@ endif # syz-sysgen generates them all at once, so we can't make each of them an independent target. .PHONY: descriptions descriptions: - go list -f '{{.Stale}}' ./sys/syz-sysgen | grep -q false || go install ./sys/syz-sysgen + go list -f '{{.Stale}}' $(GOHOSTFLAGS) ./sys/syz-sysgen | grep -q false || go install $(GOHOSTFLAGS) ./sys/syz-sysgen $(MAKE) .descriptions .descriptions: sys/*/*.txt sys/*/*.const bin/syz-sysgen -- cgit mrf-deployment