diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-06-03 10:42:15 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-06-03 10:30:06 +0000 |
| commit | c25b84828149a4957a795b08eb70caf5e89f8d9b (patch) | |
| tree | 6957ae7f3d14d7499d0f149301c972ed0d17dde3 /sys/targets/targets.go | |
| parent | 720b7efa99d7f3b4069af440ea7d004a6f27467d (diff) | |
sys/targets: test that C++ compiler works as well
debian:bookworm has broken C++ arm64->amd64 cross-compiler:
x86_64-linux-gnu-g++ -static-pie fails with:
cannot find /usr/lib/x86_64-linux-gnu/libm-2.36.a: No such file or directory
cannot find /usr/lib/x86_64-linux-gnu/libmvec.a: No such file or directory
collect2: error: ld returned 1 exit status
These are installed in a different dif in the image.
Test that C++ compiler works as well.
Diffstat (limited to 'sys/targets/targets.go')
| -rw-r--r-- | sys/targets/targets.go | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/sys/targets/targets.go b/sys/targets/targets.go index afc21d545..8e07b9aad 100644 --- a/sys/targets/targets.go +++ b/sys/targets/targets.go @@ -906,9 +906,11 @@ func (target *Target) lazyInit() { // On CI we want to fail loudly if cross-compilation breaks. // Also fail if SOURCEDIR_GOOS is set b/c in that case user probably assumes it will work. if (target.OS != runtime.GOOS || !runningOnCI) && getSourceDir(target) == "" { - if _, err := exec.LookPath(target.CCompiler); err != nil { - target.BrokenCompiler = fmt.Sprintf("%v is missing (%v)", target.CCompiler, err) - return + for _, comp := range []string{target.CCompiler, target.CxxCompiler} { + if _, err := exec.LookPath(comp); err != nil { + target.BrokenCompiler = fmt.Sprintf("%v is missing (%v)", comp, err) + return + } } } @@ -967,13 +969,19 @@ func (target *Target) lazyInit() { if runningOnCI || getSourceDir(target) != "" { return // On CI all compilers are expected to work, so we don't do the following check. } - args := []string{"-x", "c++", "-", "-o", "/dev/null"} - args = append(args, target.CFlags...) - cmd := exec.Command(target.CCompiler, args...) - cmd.Stdin = strings.NewReader(simpleProg) - if out, err := cmd.CombinedOutput(); err != nil { - target.BrokenCompiler = string(out) - return + for _, cxx := range []bool{false, true} { + lang, comp, flags := "c", target.CCompiler, target.CFlags + if cxx { + lang, comp, flags = "c++", target.CxxCompiler, target.CxxFlags + } + args := []string{"-x", lang, "-", "-o", "/dev/null"} + args = append(args, flags...) + cmd := exec.Command(comp, args...) + cmd.Stdin = strings.NewReader(simpleProg) + if out, err := cmd.CombinedOutput(); err != nil { + target.BrokenCompiler = string(out) + return + } } } |
