diff --git a/build/ci.go b/build/ci.go index e37a1d222..56437d07a 100644 --- a/build/ci.go +++ b/build/ci.go @@ -213,10 +213,7 @@ func doInstall(cmdline []string) { // Configure the build. env := build.Env() - if *staticlink { - env.StaticLink = true - } - gobuild := tc.Go("build", buildFlags(env)...) + gobuild := tc.Go("build", buildFlags(env, *staticlink)...) // arm64 CI builders are memory-constrained and can't handle concurrent builds, // better disable it. This check isn't the best, it should probably @@ -249,7 +246,7 @@ func doInstall(cmdline []string) { } // buildFlags returns the go tool flags for building. -func buildFlags(env build.Environment) (flags []string) { +func buildFlags(env build.Environment, staticlink bool) (flags []string) { var ld []string if env.Commit != "" { ld = append(ld, "-X", "main.gitCommit="+env.Commit) @@ -264,7 +261,7 @@ func buildFlags(env build.Environment) (flags []string) { // alpine Linux. if runtime.GOOS == "linux" { staticlinkflag := "" - if env.StaticLink { + if staticlink { staticlinkflag = "-static" } ld = append(ld, "-extldflags", fmt.Sprintf("' -Wl,-z,stack-size=0x800000 %s'", staticlinkflag)) diff --git a/internal/build/env.go b/internal/build/env.go index 852b1f369..d70c0d50a 100644 --- a/internal/build/env.go +++ b/internal/build/env.go @@ -34,7 +34,6 @@ var ( BuildnumFlag = flag.String("buildnum", "", `Overrides CI build number`) PullRequestFlag = flag.Bool("pull-request", false, `Overrides pull request status of the build`) CronJobFlag = flag.Bool("cron-job", false, `Overrides cron job status of the build`) - StaticLink = flag.Bool("static-link", false, `Overrides static link status of the build`) ) // Environment contains metadata provided by the build environment. @@ -46,12 +45,11 @@ type Environment struct { Buildnum string IsPullRequest bool IsCronJob bool - StaticLink bool } func (env Environment) String() string { - return fmt.Sprintf("%s env (commit:%s date:%s branch:%s tag:%s buildnum:%s pr:%t static:%t)", - env.Name, env.Commit, env.Date, env.Branch, env.Tag, env.Buildnum, env.IsPullRequest, env.StaticLink) + return fmt.Sprintf("%s env (commit:%s date:%s branch:%s tag:%s buildnum:%s pr:%t)", + env.Name, env.Commit, env.Date, env.Branch, env.Tag, env.Buildnum, env.IsPullRequest) } // Env returns metadata about the current CI environment, falling back to LocalEnv @@ -74,7 +72,6 @@ func Env() Environment { Buildnum: os.Getenv("TRAVIS_BUILD_NUMBER"), IsPullRequest: os.Getenv("TRAVIS_PULL_REQUEST") != "false", IsCronJob: os.Getenv("TRAVIS_EVENT_TYPE") == "cron", - StaticLink: false, } case os.Getenv("CI") == "True" && os.Getenv("APPVEYOR") == "True": commit := os.Getenv("APPVEYOR_PULL_REQUEST_HEAD_COMMIT") @@ -92,7 +89,6 @@ func Env() Environment { Buildnum: os.Getenv("APPVEYOR_BUILD_NUMBER"), IsPullRequest: os.Getenv("APPVEYOR_PULL_REQUEST_NUMBER") != "", IsCronJob: os.Getenv("APPVEYOR_SCHEDULED_BUILD") == "True", - StaticLink: false, } default: return LocalEnv() @@ -172,8 +168,5 @@ func applyEnvFlags(env Environment) Environment { if *CronJobFlag { env.IsCronJob = true } - if *StaticLink { - env.StaticLink = true - } return env }