hughesjr / rpms / golang

Forked from rpms/golang 5 years ago
Clone

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

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