From 1ecb069f0e95a740181fb7fc7b89ae79ce11ae58 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 9 Aug 2019 18:05:51 +0200 Subject: sys/targets: fix build on darwin Currently build on darwin crashes when we try to access host.CCompiler/CPP (there is no darwin target). Check that we have the host target before using it, otherwise use default gcc/cpp. --- sys/targets/targets.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'sys') diff --git a/sys/targets/targets.go b/sys/targets/targets.go index d5eb388a6..3299e52b5 100644 --- a/sys/targets/targets.go +++ b/sys/targets/targets.go @@ -311,7 +311,6 @@ var oses = map[string]osCommon{ ExecutorUsesShmem: true, ExecutorUsesForkServer: true, KernelObject: "vmlinux", - CPP: "cpp", }, "freebsd": { SyscallNumbers: true, @@ -328,7 +327,6 @@ var oses = map[string]osCommon{ ExecutorUsesShmem: true, ExecutorUsesForkServer: true, KernelObject: "netbsd.gdb", - CPP: "cpp", }, "openbsd": { SyscallNumbers: true, @@ -344,7 +342,6 @@ var oses = map[string]osCommon{ ExecutorUsesShmem: false, ExecutorUsesForkServer: false, KernelObject: "zircon.elf", - CPP: "cpp", }, "windows": { SyscallNumbers: false, @@ -352,7 +349,6 @@ var oses = map[string]osCommon{ ExecutorUsesForkServer: false, ExeExtension: ".exe", KernelObject: "vmlinux", - CPP: "cpp", }, "akaros": { BuildOS: "linux", @@ -361,12 +357,10 @@ var oses = map[string]osCommon{ ExecutorUsesShmem: false, ExecutorUsesForkServer: true, KernelObject: "akaros-kernel-64b", - CPP: "cpp", }, "trusty": { SyscallNumbers: true, SyscallPrefix: "__NR_", - CPP: "cpp", }, } @@ -397,8 +391,12 @@ func init() { goos = "linux" } for _, target := range List["test"] { - target.CCompiler = List[goos][runtime.GOARCH].CCompiler - target.CPP = List[goos][runtime.GOARCH].CPP + if List[goos] != nil { + if host := List[goos][runtime.GOARCH]; host != nil { + target.CCompiler = host.CCompiler + target.CPP = host.CPP + } + } target.BuildOS = goos if runtime.GOOS == "freebsd" && runtime.GOARCH == "amd64" && target.PtrSize == 4 { // -m32 alone does not work on freebsd with gcc. @@ -430,6 +428,9 @@ func initTarget(target *Target, OS, arch string) { if target.CCompiler == "" { target.CCompiler = target.CCompilerPrefix + "gcc" } + if target.CPP == "" { + target.CPP = "cpp" + } if target.BuildOS == "" { target.BuildOS = OS } -- cgit mrf-deployment