mirror of
https://github.com/restic/restic.git
synced 2024-12-23 00:07:25 +00:00
Merge pull request #2294 from BenWiederhake/debugsyms
build: Preserve debug symbols in debug build
This commit is contained in:
commit
956a1b0f96
1 changed files with 9 additions and 1 deletions
10
build.go
10
build.go
|
@ -395,8 +395,12 @@ func main() {
|
||||||
|
|
||||||
verbosePrintf("detected Go version %v\n", goVersion)
|
verbosePrintf("detected Go version %v\n", goVersion)
|
||||||
|
|
||||||
|
preserveSymbols := false
|
||||||
for i := range buildTags {
|
for i := range buildTags {
|
||||||
buildTags[i] = strings.TrimSpace(buildTags[i])
|
buildTags[i] = strings.TrimSpace(buildTags[i])
|
||||||
|
if buildTags[i] == "debug" || buildTags[i] == "profile" {
|
||||||
|
preserveSymbols = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
verbosePrintf("build tags: %s\n", buildTags)
|
verbosePrintf("build tags: %s\n", buildTags)
|
||||||
|
@ -423,7 +427,11 @@ func main() {
|
||||||
if version != "" {
|
if version != "" {
|
||||||
constants["main.version"] = version
|
constants["main.version"] = version
|
||||||
}
|
}
|
||||||
ldflags := "-s -w " + constants.LDFlags()
|
ldflags := constants.LDFlags()
|
||||||
|
if !preserveSymbols {
|
||||||
|
// Strip debug symbols.
|
||||||
|
ldflags = "-s -w " + ldflags
|
||||||
|
}
|
||||||
verbosePrintf("ldflags: %s\n", ldflags)
|
verbosePrintf("ldflags: %s\n", ldflags)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
Loading…
Reference in a new issue