Skip to content

Commit

Permalink
build: work around cgo linker issue on macOS 10.12.4 (#13849)
Browse files Browse the repository at this point in the history
Fixes #3792 by stripping debug symbols.
  • Loading branch information
fjl authored Mar 29, 2017
1 parent baf2001 commit 1cf2ee4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,16 @@ func doInstall(cmdline []string) {
}

func buildFlags(env build.Environment) (flags []string) {
// Set gitCommit constant via link-time assignment.
var ld []string
if env.Commit != "" {
flags = append(flags, "-ldflags", "-X main.gitCommit="+env.Commit)
ld = append(ld, "-X", "main.gitCommit="+env.Commit)
}
if runtime.GOOS == "darwin" {
ld = append(ld, "-s")
}

if len(ld) > 0 {
flags = append(flags, "-ldflags", strings.Join(ld, " "))
}
return flags
}
Expand Down Expand Up @@ -266,6 +273,7 @@ func doTest(cmdline []string) {
coverage = flag.Bool("coverage", false, "Whether to record code coverage")
)
flag.CommandLine.Parse(cmdline)
env := build.Env()

packages := []string{"./..."}
if len(flag.CommandLine.Args()) > 0 {
Expand All @@ -279,7 +287,7 @@ func doTest(cmdline []string) {
spellcheck(packages)
}
// Run the actual tests.
gotest := goTool("test")
gotest := goTool("test", buildFlags(env)...)
// Test a single package at a time. CI builders are slow
// and some tests run into timeouts under load.
gotest.Args = append(gotest.Args, "-p", "1")
Expand Down

0 comments on commit 1cf2ee4

Please sign in to comment.