@@ -30,9 +30,6 @@ const (
30
30
// Set implements flag.Value to set the build mode based on the argument
31
31
// to the -buildmode flag.
32
32
func (mode * BuildMode ) Set (s string ) error {
33
- badmode := func () error {
34
- return fmt .Errorf ("buildmode %s not supported on %s/%s" , s , buildcfg .GOOS , buildcfg .GOARCH )
35
- }
36
33
switch s {
37
34
default :
38
35
return fmt .Errorf ("invalid buildmode: %q" , s )
@@ -44,81 +41,21 @@ func (mode *BuildMode) Set(s string) error {
44
41
* mode = BuildModeExe
45
42
}
46
43
case "pie" :
47
- switch buildcfg .GOOS {
48
- case "aix" , "android" , "linux" , "windows" , "darwin" , "ios" :
49
- case "freebsd" :
50
- switch buildcfg .GOARCH {
51
- case "amd64" :
52
- default :
53
- return badmode ()
54
- }
55
- default :
56
- return badmode ()
57
- }
58
44
* mode = BuildModePIE
59
45
case "c-archive" :
60
- switch buildcfg .GOOS {
61
- case "aix" , "darwin" , "ios" , "linux" :
62
- case "freebsd" :
63
- switch buildcfg .GOARCH {
64
- case "amd64" :
65
- default :
66
- return badmode ()
67
- }
68
- case "windows" :
69
- switch buildcfg .GOARCH {
70
- case "amd64" , "386" , "arm" , "arm64" :
71
- default :
72
- return badmode ()
73
- }
74
- default :
75
- return badmode ()
76
- }
77
46
* mode = BuildModeCArchive
78
47
case "c-shared" :
79
- switch buildcfg .GOARCH {
80
- case "386" , "amd64" , "arm" , "arm64" , "ppc64le" , "riscv64" , "s390x" :
81
- default :
82
- return badmode ()
83
- }
84
48
* mode = BuildModeCShared
85
49
case "shared" :
86
- switch buildcfg .GOOS {
87
- case "linux" :
88
- switch buildcfg .GOARCH {
89
- case "386" , "amd64" , "arm" , "arm64" , "ppc64le" , "s390x" :
90
- default :
91
- return badmode ()
92
- }
93
- default :
94
- return badmode ()
95
- }
96
50
* mode = BuildModeShared
97
51
case "plugin" :
98
- switch buildcfg .GOOS {
99
- case "linux" :
100
- switch buildcfg .GOARCH {
101
- case "386" , "amd64" , "arm" , "arm64" , "s390x" , "ppc64le" :
102
- default :
103
- return badmode ()
104
- }
105
- case "darwin" :
106
- switch buildcfg .GOARCH {
107
- case "amd64" , "arm64" :
108
- default :
109
- return badmode ()
110
- }
111
- case "freebsd" :
112
- switch buildcfg .GOARCH {
113
- case "amd64" :
114
- default :
115
- return badmode ()
116
- }
117
- default :
118
- return badmode ()
119
- }
120
52
* mode = BuildModePlugin
121
53
}
54
+
55
+ if ! platform .BuildModeSupported ("gc" , s , buildcfg .GOOS , buildcfg .GOARCH ) {
56
+ return fmt .Errorf ("buildmode %s not supported on %s/%s" , s , buildcfg .GOOS , buildcfg .GOARCH )
57
+ }
58
+
122
59
return nil
123
60
}
124
61
0 commit comments