diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-04-29 15:31:23 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-04-29 16:32:33 +0200 |
| commit | 3b93a8e0034a8109125737a9019e6e787f81ec2b (patch) | |
| tree | 70da3f3111a10b3127c3acb0e4c0ab2b12618334 /tools/syz-env | |
| parent | 08bed8d76911c9f004a2997c550687351faa52ce (diff) | |
sys/targets: better detection for missing/broken cross-compilers
1. Detect when compiler is present, but is not functioning
(can't build a simple program, common for Linux distros).
2. Be more strict with skipping tests due to missing/broken compilers on CI
(on CI they should work, so fail loudly if not).
3. Dedup this logic across syz-env and pkg/csource tests.
4. Add better error reporting for syz-env.
Fixes #1606
Diffstat (limited to 'tools/syz-env')
| -rw-r--r-- | tools/syz-env/env.go | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/tools/syz-env/env.go b/tools/syz-env/env.go index aa0143ab9..81a40af8a 100644 --- a/tools/syz-env/env.go +++ b/tools/syz-env/env.go @@ -6,7 +6,6 @@ package main import ( "fmt" "os" - "os/exec" "runtime" "strconv" "strings" @@ -16,6 +15,22 @@ import ( ) func main() { + vars, err := impl() + if err != nil { + fmt.Printf("export SYZERROR=%v\n", err) + os.Exit(1) + } + for _, v := range vars { + fmt.Printf("export %v=%v\\n", v.Name, v.Val) + } +} + +type Var struct { + Name string + Val string +} + +func impl() ([]Var, error) { hostOS := or(os.Getenv("HOSTOS"), runtime.GOOS) hostArch := or(os.Getenv("HOSTARCH"), runtime.GOARCH) targetOS := or(os.Getenv("TARGETOS"), hostOS) @@ -23,12 +38,7 @@ func main() { targetVMArch := or(os.Getenv("TARGETVMARCH"), targetArch) target := targets.Get(targetOS, targetArch) if target == nil { - fmt.Printf("unknown target %v/%v\n", targetOS, targetArch) - os.Exit(1) - } - type Var struct { - Name string - Val string + return nil, fmt.Errorf("unknown target %v/%v", targetOS, targetArch) } parallelism := runtime.NumCPU() if mem := osutil.SystemMemorySize(); mem != 0 { @@ -53,15 +63,9 @@ func main() { {"NCORES", strconv.Itoa(parallelism)}, {"EXE", target.ExeExtension}, {"NATIVEBUILDOS", target.BuildOS}, + {"NO_CROSS_COMPILER", target.BrokenCrossCompiler}, } - 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) - } + return vars, nil } func or(s1, s2 string) string { |
