crypto/x509: restore support for ios tag on darwin/amd64

Fixes #38710

Change-Id: I9b210e95fd997ff53ec704c5f61110045aaa94bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/239559
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index e1cd496..2dc9459 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -461,6 +461,18 @@
 		})
 	}
 
+	// Test the ios build tag on darwin/amd64 for the iOS simulator.
+	if goos == "darwin" && !t.iOS() {
+		t.tests = append(t.tests, distTest{
+			name:    "amd64ios",
+			heading: "ios tag on darwin/amd64",
+			fn: func(dt *distTest) error {
+				t.addCmd(dt, "src", t.goTest(), t.timeout(300), "-tags=ios", "-run=SystemRoots", "crypto/x509")
+				return nil
+			},
+		})
+	}
+
 	if t.race {
 		return
 	}
diff --git a/src/crypto/x509/root.go b/src/crypto/x509/root.go
index 8606a0f..da5e91b 100644
--- a/src/crypto/x509/root.go
+++ b/src/crypto/x509/root.go
@@ -4,7 +4,7 @@
 
 package x509
 
-//go:generate go run root_darwin_arm64_gen.go -version 55161.80.1
+//go:generate go run root_darwin_ios_gen.go -version 55161.80.1
 
 import "sync"
 
diff --git a/src/crypto/x509/root_cgo_darwin_amd64.go b/src/crypto/x509/root_cgo_darwin_amd64.go
index bec57eb..15c72cc 100644
--- a/src/crypto/x509/root_cgo_darwin_amd64.go
+++ b/src/crypto/x509/root_cgo_darwin_amd64.go
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build !ios
+
 package x509
 
 // This cgo implementation exists only to support side-by-side testing by
diff --git a/src/crypto/x509/root_darwin_amd64.go b/src/crypto/x509/root_darwin_amd64.go
index 8ad5a96..ccc37b8 100644
--- a/src/crypto/x509/root_darwin_amd64.go
+++ b/src/crypto/x509/root_darwin_amd64.go
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build !ios
+
 package x509
 
 import (
diff --git a/src/crypto/x509/root_darwin_arm64.go b/src/crypto/x509/root_darwin_ios.go
similarity index 99%
rename from src/crypto/x509/root_darwin_arm64.go
rename to src/crypto/x509/root_darwin_ios.go
index 4d9af12..5ecc491 100644
--- a/src/crypto/x509/root_darwin_arm64.go
+++ b/src/crypto/x509/root_darwin_ios.go
@@ -1,6 +1,7 @@
-// Code generated by root_darwin_arm64_gen.go -version 55161.80.1; DO NOT EDIT.
+// Code generated by root_darwin_ios_gen.go -version 55161.80.1; DO NOT EDIT.
 // Update the version in root.go and regenerate with "go generate".
 
+// +build darwin,arm64 darwin,amd64,ios
 // +build !x509omitbundledroots
 
 package x509
diff --git a/src/crypto/x509/root_darwin_arm64_gen.go b/src/crypto/x509/root_darwin_ios_gen.go
similarity index 94%
rename from src/crypto/x509/root_darwin_arm64_gen.go
rename to src/crypto/x509/root_darwin_ios_gen.go
index baad8a2..7a42466 100644
--- a/src/crypto/x509/root_darwin_arm64_gen.go
+++ b/src/crypto/x509/root_darwin_ios_gen.go
@@ -4,7 +4,7 @@
 
 // +build ignore
 
-// Generates root_darwin_arm64.go.
+// Generates root_darwin_ios.go.
 //
 // As of iOS 13, there is no API for querying the system trusted X.509 root
 // certificates.
@@ -37,7 +37,7 @@
 )
 
 func main() {
-	var output = flag.String("output", "root_darwin_arm64.go", "file name to write")
+	var output = flag.String("output", "root_darwin_ios.go", "file name to write")
 	var version = flag.String("version", "", "security_certificates version")
 	flag.Parse()
 	if *version == "" {
@@ -156,9 +156,10 @@
 	}
 }
 
-const header = `// Code generated by root_darwin_arm64_gen.go -version %s; DO NOT EDIT.
+const header = `// Code generated by root_darwin_ios_gen.go -version %s; DO NOT EDIT.
 // Update the version in root.go and regenerate with "go generate".
 
+// +build darwin,arm64 darwin,amd64,ios
 // +build !x509omitbundledroots
 
 package x509
diff --git a/src/crypto/x509/root_omit.go b/src/crypto/x509/root_omit.go
index b757ea8..175d716 100644
--- a/src/crypto/x509/root_omit.go
+++ b/src/crypto/x509/root_omit.go
@@ -2,7 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin,arm64,x509omitbundledroots
+// +build darwin,arm64 darwin,amd64,ios
+// +build x509omitbundledroots
 
 // This file provides the loadSystemRoots func when the
 // "x509omitbundledroots" build tag has disabled bundling a copy,
diff --git a/src/crypto/x509/root_omit_test.go b/src/crypto/x509/root_omit_test.go
index 2a9fb3f..5ab6c93 100644
--- a/src/crypto/x509/root_omit_test.go
+++ b/src/crypto/x509/root_omit_test.go
@@ -2,7 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin,arm64,x509omitbundledroots
+// +build darwin,arm64 darwin,amd64,ios
+// +build x509omitbundledroots
 
 package x509