Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util/printer: get GoVersion from runtime variable instead of shell #13763

Merged
merged 5 commits into from Nov 27, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion Makefile
Expand Up @@ -32,7 +32,6 @@ LDFLAGS += -X "github.com/pingcap/parser/mysql.TiDBReleaseVersion=$(shell git de
LDFLAGS += -X "github.com/pingcap/tidb/util/printer.TiDBBuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
LDFLAGS += -X "github.com/pingcap/tidb/util/printer.TiDBGitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "github.com/pingcap/tidb/util/printer.TiDBGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
LDFLAGS += -X "github.com/pingcap/tidb/util/printer.GoVersion=$(shell go version)"

TEST_LDFLAGS = -X "github.com/pingcap/tidb/config.checkBeforeDropLDFlag=1"
COVERAGE_SERVER_LDFLAGS = -X "github.com/pingcap/tidb/tidb-server.isCoverageServer=1"
Expand Down
10 changes: 7 additions & 3 deletions util/printer/printer.go
Expand Up @@ -17,6 +17,8 @@ import (
"bytes"
"encoding/json"
"fmt"
_ "runtime" // import link package
_ "unsafe" // required by go:linkname

"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/config"
Expand All @@ -30,7 +32,6 @@ var (
TiDBBuildTS = "None"
TiDBGitHash = "None"
TiDBGitBranch = "None"
GoVersion = "None"
// TiKVMinVersion is the minimum version of TiKV that can be compatible with the current TiDB.
TiKVMinVersion = "v3.0.0-60965b006877ca7234adaced7890d7b029ed1306"
)
Expand All @@ -42,7 +43,7 @@ func PrintTiDBInfo() {
zap.String("Git Commit Hash", TiDBGitHash),
zap.String("Git Branch", TiDBGitBranch),
zap.String("UTC Build Time", TiDBBuildTS),
zap.String("GoVersion", GoVersion),
zap.String("GoVersion", buildVersion),
zap.Bool("Race Enabled", israce.RaceEnabled),
zap.Bool("Check Table Before Drop", config.CheckTableBeforeDrop),
zap.String("TiKV Min Version", TiKVMinVersion))
Expand All @@ -67,7 +68,7 @@ func GetTiDBInfo() string {
TiDBGitHash,
TiDBGitBranch,
TiDBBuildTS,
GoVersion,
buildVersion,
israce.RaceEnabled,
TiKVMinVersion,
config.CheckTableBeforeDrop)
Expand Down Expand Up @@ -167,3 +168,6 @@ func GetPrintResult(cols []string, datas [][]string) (string, bool) {
value = append(value, getPrintDivLine(maxColLen)...)
return string(value), true
}

//go:linkname buildVersion runtime.buildVersion
var buildVersion string