diff --git a/Makefile b/Makefile index 8cc293c50787..af304033db33 100644 --- a/Makefile +++ b/Makefile @@ -110,14 +110,20 @@ target: # executor uses stacks of limited size, so no jumbo frames. executor: -ifeq ($(BUILDOS),$(NATIVEBUILDOS)) - mkdir -p ./bin/$(TARGETOS)_$(TARGETARCH) - $(CC) -o ./bin/$(TARGETOS)_$(TARGETARCH)/syz-executor$(EXE) executor/executor.cc \ - $(ADDCFLAGS) $(CFLAGS) -DGOOS_$(TARGETOS)=1 -DGOARCH_$(TARGETARCH)=1 -DGIT_REVISION=\"$(REV)\" -else +ifneq ("$(BUILDOS)", "$(NATIVEBUILDOS)") $(info ************************************************************************************) $(info Building executor for ${TARGETOS} is not supported on ${BUILDOS}. Executor will not be built.) $(info ************************************************************************************) +else +ifneq ("$(NO_CROSS_COMPILER)", "") + $(info ************************************************************************************) + $(info Native cross-compiler $(CC) is missing. Executor will not be built.) + $(info ************************************************************************************) +else + mkdir -p ./bin/$(TARGETOS)_$(TARGETARCH) + $(CC) -o ./bin/$(TARGETOS)_$(TARGETARCH)/syz-executor$(EXE) executor/executor.cc \ + $(ADDCFLAGS) $(CFLAGS) -DGOOS_$(TARGETOS)=1 -DGOARCH_$(TARGETARCH)=1 -DGIT_REVISION=\"$(REV)\" +endif endif manager: diff --git a/tools/syz-env/env.go b/tools/syz-env/env.go index a5fc4fbb121c..cae88c5a9b03 100644 --- a/tools/syz-env/env.go +++ b/tools/syz-env/env.go @@ -6,6 +6,7 @@ package main import ( "fmt" "os" + "os/exec" "runtime" "strconv" "strings" @@ -40,6 +41,12 @@ func main() { {"ADDCFLAGS", strings.Join(target.CrossCFlags, " ")}, {"NCORES", strconv.Itoa(runtime.NumCPU())}, {"EXE", target.ExeExtension}, + {"NATIVEBUILDOS", target.BuildOS}, + } + if targetOS != runtime.GOOS { + if _, err := exec.LookPath(target.CCompiler); err != nil { + vars = append(vars, Var{"NO_CROSS_COMPILER", "yes"}) + } } for _, v := range vars { fmt.Printf("export %v=%v\\n", v.Name, v.Val)