diff --git a/tool/gocross/autoflags.go b/tool/gocross/autoflags.go index 405cad8b3..5b1537d2f 100644 --- a/tool/gocross/autoflags.go +++ b/tool/gocross/autoflags.go @@ -102,8 +102,14 @@ func autoflagsForTest(argv []string, env *Environment, goroot, nativeGOOS, nativ targetOS = "windows" cgo = true buildFlags = append(buildFlags, "-buildmode=c-shared") - ldflags = append(ldflags, "-H", "windows", "-s") + ldflags = append(ldflags, "-H", "windows") cgoLdflags = append(cgoLdflags, "-static") + if env.IsSet("TS_WINBUILD_WANT_SYMBOLS") { + cgoLdflags = append(cgoLdflags, "-g") + ldflags = append(ldflags, "-linkmode=external", fmt.Sprintf("'-extldflags=%s'", strings.Join("-s", " ")) + } else { + ldflags = append(ldflags, "-s") + } var mingwArch string switch targetArch { case "amd64": @@ -117,9 +123,15 @@ func autoflagsForTest(argv []string, env *Environment, goroot, nativeGOOS, nativ case "windowsgui": // Fake GOOS that translates to "windows, but building GUI .exes not console .exes" targetOS = "windows" - ldflags = append(ldflags, "-H", "windowsgui", "-s") + ldflags = append(ldflags, "-H", "windowsgui") + if !env.IsSet("TS_WINBUILD_WANT_SYMBOLS") { + ldflags = append(ldflags, "-s") + } case "windows": - ldflags = append(ldflags, "-H", "windows", "-s") + ldflags = append(ldflags, "-H", "windows") + if !env.IsSet("TS_WINBUILD_WANT_SYMBOLS") { + ldflags = append(ldflags, "-s") + } case "ios": failReflect = true fallthrough