@@ -1136,79 +1136,14 @@ func (t *tester) internalLinkPIE() bool {
1136
1136
1137
1137
// supportedBuildMode reports whether the given build mode is supported.
1138
1138
func (t * tester ) supportedBuildmode (mode string ) bool {
1139
- pair := goos + "-" + goarch
1140
1139
switch mode {
1141
- case "c-archive" :
1142
- if ! t .extLink () {
1143
- return false
1144
- }
1145
- switch goos {
1146
- case "aix" , "darwin" , "ios" , "windows" :
1147
- return true
1148
- case "linux" :
1149
- switch goarch {
1150
- case "386" , "amd64" , "arm" , "armbe" , "arm64" , "arm64be" , "ppc64" , "ppc64le" , "riscv64" , "s390x" :
1151
- return true
1152
- default :
1153
- // Other targets do not support -shared,
1154
- // per ParseFlags in
1155
- // cmd/compile/internal/base/flag.go.
1156
- // For c-archive the Go tool passes -shared,
1157
- // so that the result is suitable for inclusion
1158
- // in a PIE or shared library.
1159
- return false
1160
- }
1161
- case "freebsd" :
1162
- return goarch == "amd64"
1163
- }
1164
- return false
1165
- case "c-shared" :
1166
- switch pair {
1167
- case "linux-386" , "linux-amd64" , "linux-arm" , "linux-arm64" , "linux-ppc64le" , "linux-riscv64" , "linux-s390x" ,
1168
- "darwin-amd64" , "darwin-arm64" ,
1169
- "freebsd-amd64" ,
1170
- "android-arm" , "android-arm64" , "android-386" , "android-amd64" ,
1171
- "windows-amd64" , "windows-386" , "windows-arm64" :
1172
- return true
1173
- }
1174
- return false
1175
- case "shared" :
1176
- switch pair {
1177
- case "linux-386" , "linux-amd64" , "linux-arm" , "linux-arm64" , "linux-ppc64le" , "linux-s390x" :
1178
- return true
1179
- }
1180
- return false
1181
- case "plugin" :
1182
- switch pair {
1183
- case "linux-386" , "linux-amd64" , "linux-arm" , "linux-arm64" , "linux-s390x" , "linux-ppc64le" :
1184
- return true
1185
- case "android-386" , "android-amd64" :
1186
- return true
1187
- case "darwin-amd64" , "darwin-arm64" :
1188
- return true
1189
- case "freebsd-amd64" :
1190
- return true
1191
- }
1192
- return false
1193
- case "pie" :
1194
- switch pair {
1195
- case "aix-ppc64" ,
1196
- "linux-386" , "linux-amd64" , "linux-arm" , "linux-arm64" , "linux-ppc64le" , "linux-riscv64" , "linux-s390x" ,
1197
- "android-amd64" , "android-arm" , "android-arm64" , "android-386" :
1198
- return true
1199
- case "darwin-amd64" , "darwin-arm64" , "ios-amd64" , "ios-arm64" :
1200
- return true
1201
- case "windows-amd64" , "windows-386" , "windows-arm" , "windows-arm64" :
1202
- return true
1203
- case "freebsd-amd64" :
1204
- return true
1205
- }
1206
- return false
1207
-
1140
+ case "c-archive" , "c-shared" , "shared" , "plugin" , "pie" :
1208
1141
default :
1209
1142
fatalf ("internal error: unknown buildmode %s" , mode )
1210
1143
return false
1211
1144
}
1145
+
1146
+ return buildModeSupported ("gc" , mode , goos , goarch )
1212
1147
}
1213
1148
1214
1149
func (t * tester ) registerCgoTests () {
@@ -1737,6 +1672,96 @@ func raceDetectorSupported(goos, goarch string) bool {
1737
1672
}
1738
1673
}
1739
1674
1675
+ // buildModeSupports is a copy of the function
1676
+ // internal/platform.BuildModeSupported, which can't be used here
1677
+ // because cmd/dist can not import internal packages during bootstrap.
1678
+ func buildModeSupported (compiler , buildmode , goos , goarch string ) bool {
1679
+ if compiler == "gccgo" {
1680
+ return true
1681
+ }
1682
+
1683
+ platform := goos + "/" + goarch
1684
+
1685
+ switch buildmode {
1686
+ case "archive" :
1687
+ return true
1688
+
1689
+ case "c-archive" :
1690
+ switch goos {
1691
+ case "aix" , "darwin" , "ios" , "windows" :
1692
+ return true
1693
+ case "linux" :
1694
+ switch goarch {
1695
+ case "386" , "amd64" , "arm" , "armbe" , "arm64" , "arm64be" , "ppc64le" , "riscv64" , "s390x" :
1696
+ // linux/ppc64 not supported because it does
1697
+ // not support external linking mode yet.
1698
+ return true
1699
+ default :
1700
+ // Other targets do not support -shared,
1701
+ // per ParseFlags in
1702
+ // cmd/compile/internal/base/flag.go.
1703
+ // For c-archive the Go tool passes -shared,
1704
+ // so that the result is suitable for inclusion
1705
+ // in a PIE or shared library.
1706
+ return false
1707
+ }
1708
+ case "freebsd" :
1709
+ return goarch == "amd64"
1710
+ }
1711
+ return false
1712
+
1713
+ case "c-shared" :
1714
+ switch platform {
1715
+ case "linux/amd64" , "linux/arm" , "linux/arm64" , "linux/386" , "linux/ppc64le" , "linux/riscv64" , "linux/s390x" ,
1716
+ "android/amd64" , "android/arm" , "android/arm64" , "android/386" ,
1717
+ "freebsd/amd64" ,
1718
+ "darwin/amd64" , "darwin/arm64" ,
1719
+ "windows/amd64" , "windows/386" , "windows/arm64" :
1720
+ return true
1721
+ }
1722
+ return false
1723
+
1724
+ case "default" :
1725
+ return true
1726
+
1727
+ case "exe" :
1728
+ return true
1729
+
1730
+ case "pie" :
1731
+ switch platform {
1732
+ case "linux/386" , "linux/amd64" , "linux/arm" , "linux/arm64" , "linux/ppc64le" , "linux/riscv64" , "linux/s390x" ,
1733
+ "android/amd64" , "android/arm" , "android/arm64" , "android/386" ,
1734
+ "freebsd/amd64" ,
1735
+ "darwin/amd64" , "darwin/arm64" ,
1736
+ "ios/amd64" , "ios/arm64" ,
1737
+ "aix/ppc64" ,
1738
+ "windows/386" , "windows/amd64" , "windows/arm" , "windows/arm64" :
1739
+ return true
1740
+ }
1741
+ return false
1742
+
1743
+ case "shared" :
1744
+ switch platform {
1745
+ case "linux/386" , "linux/amd64" , "linux/arm" , "linux/arm64" , "linux/ppc64le" , "linux/s390x" :
1746
+ return true
1747
+ }
1748
+ return false
1749
+
1750
+ case "plugin" :
1751
+ switch platform {
1752
+ case "linux/amd64" , "linux/arm" , "linux/arm64" , "linux/386" , "linux/s390x" , "linux/ppc64le" ,
1753
+ "android/amd64" , "android/386" ,
1754
+ "darwin/amd64" , "darwin/arm64" ,
1755
+ "freebsd/amd64" :
1756
+ return true
1757
+ }
1758
+ return false
1759
+
1760
+ default :
1761
+ return false
1762
+ }
1763
+ }
1764
+
1740
1765
// isUnsupportedVMASize reports whether the failure is caused by an unsupported
1741
1766
// VMA for the race detector (for example, running the race detector on an
1742
1767
// arm64 machine configured with 39-bit VMA)
0 commit comments