mirror of https://github.com/golang/go.git
cmd/go: build test binaries with -s in addition to -w
Fixes #19753. Change-Id: Ib20a69b1d0bcc42aa9e924918bcb578d6a560a31 Reviewed-on: https://go-review.googlesource.com/38742 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
6983b9a579
commit
94c95d3e52
|
|
@ -89,16 +89,25 @@ func testAddr2Line(t *testing.T, exepath, addr string) {
|
|||
func TestAddr2Line(t *testing.T) {
|
||||
testenv.MustHaveGoBuild(t)
|
||||
|
||||
syms := loadSyms(t)
|
||||
|
||||
tmpDir, err := ioutil.TempDir("", "TestAddr2Line")
|
||||
if err != nil {
|
||||
t.Fatal("TempDir failed: ", err)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
|
||||
exepath := filepath.Join(tmpDir, "testaddr2line.exe")
|
||||
out, err := exec.Command(testenv.GoToolPath(t), "build", "-o", exepath, "cmd/addr2line").CombinedOutput()
|
||||
// Build copy of test binary with debug symbols,
|
||||
// since the one running now may not have them.
|
||||
exepath := filepath.Join(tmpDir, "testaddr2line_test.exe")
|
||||
out, err := exec.Command(testenv.GoToolPath(t), "test", "-c", "-o", exepath, "cmd/addr2line").CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("go test -c -o %v cmd/addr2line: %v\n%s", exepath, err, string(out))
|
||||
}
|
||||
os.Args[0] = exepath
|
||||
|
||||
syms := loadSyms(t)
|
||||
|
||||
exepath = filepath.Join(tmpDir, "testaddr2line.exe")
|
||||
out, err = exec.Command(testenv.GoToolPath(t), "build", "-o", exepath, "cmd/addr2line").CombinedOutput()
|
||||
if err != nil {
|
||||
t.Fatalf("go build -o %v cmd/addr2line: %v\n%s", exepath, err, string(out))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ type PackageInternal struct {
|
|||
ExeName string // desired name for temporary executable
|
||||
CoverMode string // preprocess Go source files with the coverage tool in this mode
|
||||
CoverVars map[string]*CoverVar // variables created by coverage analysis
|
||||
OmitDWARF bool // tell linker not to write DWARF information
|
||||
OmitDebug bool // tell linker not to write debug information
|
||||
BuildID string // expected build ID for generated package
|
||||
GobinSubdir bool // install target would be subdir of GOBIN
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ func runRun(cmd *base.Command, args []string) {
|
|||
if p.Error != nil {
|
||||
base.Fatalf("%s", p.Error)
|
||||
}
|
||||
p.Internal.OmitDWARF = true
|
||||
p.Internal.OmitDebug = true
|
||||
if len(p.DepsErrors) > 0 {
|
||||
// Since these are errors in dependencies,
|
||||
// the same error might show up multiple times,
|
||||
|
|
|
|||
|
|
@ -862,7 +862,7 @@ func builderTest(b *work.Builder, p *load.Package) (buildAction, runAction, prin
|
|||
Build: &build.Package{Name: "main"},
|
||||
Pkgdir: testDir,
|
||||
Fake: true,
|
||||
OmitDWARF: !testC && !testNeedBinary,
|
||||
OmitDebug: !testC && !testNeedBinary,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2417,8 +2417,8 @@ func (gcToolchain) ld(b *Builder, root *Action, out string, allactions []*Action
|
|||
if cfg.BuildContext.InstallSuffix != "" {
|
||||
ldflags = append(ldflags, "-installsuffix", cfg.BuildContext.InstallSuffix)
|
||||
}
|
||||
if root.Package.Internal.OmitDWARF {
|
||||
ldflags = append(ldflags, "-w")
|
||||
if root.Package.Internal.OmitDebug {
|
||||
ldflags = append(ldflags, "-s", "-w")
|
||||
}
|
||||
if cfg.BuildBuildmode == "plugin" {
|
||||
pluginpath := root.Package.ImportPath
|
||||
|
|
|
|||
Loading…
Reference in New Issue