cmd/dlv: use -a flag with go1.9

By specifying the -a flag we insure that all packages are recompiled
with -gcflags='-N -l'. Previously -a could not be specified because the
compiler could not compile runtime without optimizations.

Fixes #738
This commit is contained in:
aarzilli 2017-05-30 19:31:33 +02:00 committed by Derek Parker
parent 2ad9ce6fe3
commit ec8e6c4af3

@ -536,6 +536,10 @@ func gobuild(debugname, pkg string) error {
if BuildFlags != "" {
args = append(args, splitQuotedFields(BuildFlags)...)
}
if ver, _ := goversion.Installed(); ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
// after go1.9 building with -gcflags='-N -l' and -a simultaneously works
args = append(args, "-a")
}
args = append(args, pkg)
return gocommand("build", args...)
}
@ -545,6 +549,10 @@ func gotestbuild(pkg string) error {
if BuildFlags != "" {
args = append(args, splitQuotedFields(BuildFlags)...)
}
if ver, _ := goversion.Installed(); ver.Major < 0 || ver.AfterOrEqual(goversion.GoVersion{1, 9, -1, 0, 0, ""}) {
// after go1.9 building with -gcflags='-N -l' and -a simultaneously works
args = append(args, "-a")
}
args = append(args, pkg)
return gocommand("test", args...)
}