Skip to content

Commit

Permalink
Makefile: don't cross-compile executor if cross-compiler is missing
Browse files Browse the repository at this point in the history
We started building netbsd executor on linux.
This fails on CI since cross-compiler is missing.
But we don't want to exclude netbsd from presubmit entirely.
So check if cross-compiler is missing and just produce a warning.
This should unbreak CI and humans will see the warning.
  • Loading branch information
dvyukov committed Jan 24, 2019
1 parent f4e42ca commit fa3d6b0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 7 additions & 0 deletions tools/syz-env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main
import (
"fmt"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fa3d6b0

Please sign in to comment.