},
}
- // The generated main also imports testing, regexp, and os.
+ // The generated main also imports testing, regexp, os, and maybe runtime/cgo.
stk.Push("testmain")
+ forceCgo := false
+ if cfg.BuildContext.GOOS == "darwin" {
+ if cfg.BuildContext.GOARCH == "arm" || cfg.BuildContext.GOARCH == "arm64" {
+ forceCgo = true
+ }
+ }
deps := testMainDeps
- if cfg.ExternalLinkingForced() {
+ if cfg.ExternalLinkingForced() || forceCgo {
deps = str.StringList(deps, "runtime/cgo")
}
for _, dep := range deps {
recompileForTest(pmain, p, ptest, testDir)
}
- if cfg.BuildContext.GOOS == "darwin" {
- if cfg.BuildContext.GOARCH == "arm" || cfg.BuildContext.GOARCH == "arm64" {
- t.NeedCgo = true
- }
- }
+ t.NeedCgo = forceCgo
for _, cp := range pmain.Internal.Imports {
if len(cp.Internal.CoverVars) > 0 {