cmd/link: skip c-archive tests if c-archive mode is not supported

Change-Id: If0e034d9ebf2baeb89cb52b22aedbe923cc703ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/463983
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/src/cmd/link/dwarf_test.go b/src/cmd/link/dwarf_test.go
index 53dc686..2ff35e4 100644
--- a/src/cmd/link/dwarf_test.go
+++ b/src/cmd/link/dwarf_test.go
@@ -10,6 +10,7 @@
 	"cmd/internal/objfile"
 	"cmd/internal/quoted"
 	"debug/dwarf"
+	"internal/platform"
 	"internal/testenv"
 	"os"
 	"os/exec"
@@ -192,6 +193,9 @@
 		if runtime.GOOS == "windows" {
 			t.Skip("skipping Windows/c-archive; see Issue 35512 for more.")
 		}
+		if !platform.BuildModeSupported(runtime.Compiler, "c-archive", runtime.GOOS, runtime.GOARCH) {
+			t.Skipf("skipping c-archive test on unsupported platform %s-%s", runtime.GOOS, runtime.GOARCH)
+		}
 		t.Run("c-archive", func(t *testing.T) {
 			testDWARF(t, "c-archive", true)
 		})