pgreco / rpms / golang

Forked from rpms/golang 5 years ago
Clone

Blame SOURCES/use-buildmode-pie-for-pie-testing.patch

864f2d
diff -up go/src/cmd/dist/test.go.pie go/src/cmd/dist/test.go
864f2d
--- go/src/cmd/dist/test.go.pie	2017-10-25 20:30:21.000000000 +0200
864f2d
+++ go/src/cmd/dist/test.go	2017-11-03 16:47:55.290829798 +0100
864f2d
@@ -852,6 +852,16 @@ func (t *tester) supportedBuildmode(mode
864f2d
 			return true
864f2d
 		}
864f2d
 		return false
864f2d
+	case "pie":
864f2d
+		switch pair {
864f2d
+		case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-s390x",
864f2d
+			"android-amd64", "android-arm", "android-arm64", "android-386":
864f2d
+			return true
864f2d
+		case "darwin-amd64":
864f2d
+			return true
864f2d
+		}
864f2d
+		return false
864f2d
+
864f2d
 	default:
864f2d
 		log.Fatalf("internal error: unknown buildmode %s", mode)
864f2d
 		return false
864f2d
@@ -953,24 +963,16 @@ func (t *tester) cgoTest(dt *distTest) e
864f2d
 				}
864f2d
 			}
864f2d
 
864f2d
-			if pair != "freebsd-amd64" { // clang -pie fails to link misc/cgo/test
864f2d
-				cmd := t.dirCmd("misc/cgo/test",
864f2d
-					cc, "-xc", "-o", "/dev/null", "-pie", "-")
864f2d
+			if t.supportedBuildmode("pie") {
864f2d
+				cmd = t.addCmd(dt, "misc/cgo/test", "go", "test", "-buildmode=pie")
864f2d
 				cmd.Env = env
864f2d
-				cmd.Stdin = strings.NewReader("int main() {}")
864f2d
-				if err := cmd.Run(); err != nil {
864f2d
-					fmt.Println("No support for -pie found, skip cgo PIE test.")
864f2d
-				} else {
864f2d
-					cmd = t.addCmd(dt, "misc/cgo/test", "go", "test", "-ldflags", `-linkmode=external -extldflags "-pie"`)
864f2d
-					cmd.Env = env
864f2d
 
864f2d
-					cmd = t.addCmd(dt, "misc/cgo/testtls", "go", "test", "-ldflags", `-linkmode=external -extldflags "-pie"`)
864f2d
-					cmd.Env = env
864f2d
+				cmd = t.addCmd(dt, "misc/cgo/testtls", "go", "test", "-buildmode=pie")
864f2d
+				cmd.Env = env
864f2d
 
864f2d
-					cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-ldflags", `-linkmode=external -extldflags "-pie"`)
864f2d
-					cmd.Env = env
864f2d
+				cmd = t.addCmd(dt, "misc/cgo/nocgo", "go", "test", "-buildmode=pie")
864f2d
+				cmd.Env = env
864f2d
 
864f2d
-				}
864f2d
 			}
864f2d
 		}
864f2d
 	}