@@ -175,10 +175,11 @@ func importWithSrcDir(bctx build.Context, path string, srcDir string, mode build
175
175
switch path {
176
176
case "os" :
177
177
pkg .GoFiles = excludeExecutable (pkg .GoFiles ) // Need to exclude executable implementation files, because some of them contain package scope variables that perform (indirectly) syscalls on init.
178
- // Prefer dirent_js.go version, since it targets a similar environment to
179
- // ours. Arguably this file should be excluded by the build tags (see
180
- // https://github.com/gopherjs/gopherjs/issues/693).
181
- pkg .GoFiles = exclude (pkg .GoFiles , "dirent_linux.go" )
178
+ // Prefer the dirent_${GOOS}.go version, to make the build pass on both linux
179
+ // and darwin.
180
+ // In the long term, our builds should produce the same output regardless
181
+ // of the host OS: https://github.com/gopherjs/gopherjs/issues/693.
182
+ pkg .GoFiles = exclude (pkg .GoFiles , "dirent_js.go" )
182
183
case "runtime" :
183
184
pkg .GoFiles = []string {} // Package sources are completely replaced in natives.
184
185
case "runtime/internal/sys" :
@@ -194,6 +195,16 @@ func importWithSrcDir(bctx build.Context, path string, srcDir string, mode build
194
195
case "crypto/rand" :
195
196
pkg .GoFiles = []string {"rand.go" , "util.go" }
196
197
pkg .TestGoFiles = exclude (pkg .TestGoFiles , "rand_linux_test.go" ) // Don't want linux-specific tests (since linux-specific package files are excluded too).
198
+ case "crypto/x509" :
199
+ // GopherJS doesn't support loading OS root certificates regardless of the
200
+ // OS. The substitution below allows to avoid build dependency on Mac OS
201
+ // implementation, which won't be used anyway.
202
+ //
203
+ // Just like above, https://github.com/gopherjs/gopherjs/issues/693 is
204
+ // probably the best long-term option.
205
+ pkg .GoFiles = include (
206
+ exclude (pkg .GoFiles , fmt .Sprintf ("root_%s.go" , bctx .GOOS )),
207
+ "root_unix.go" , "root_js.go" )
197
208
}
198
209
199
210
if len (pkg .CgoFiles ) > 0 {
@@ -249,6 +260,12 @@ Outer:
249
260
return s
250
261
}
251
262
263
+ func include (files []string , includes ... string ) []string {
264
+ files = exclude (files , includes ... ) // Ensure there won't be duplicates.
265
+ files = append (files , includes ... )
266
+ return files
267
+ }
268
+
252
269
// ImportDir is like Import but processes the Go package found in the named
253
270
// directory.
254
271
func ImportDir (dir string , mode build.ImportMode , installSuffix string , buildTags []string ) (* PackageData , error ) {
0 commit comments