1
0
mirror of https://github.com/golang/go synced 2024-11-23 15:50:07 -07:00

runtime: keep build version around in binaries

So we can tell from a binary which version of
Go built it.

LGTM=minux, rsc
R=golang-codereviews, minux, khr, rsc, dave
CC=golang-codereviews
https://golang.org/cl/117040043
This commit is contained in:
Keith Randall 2014-07-21 20:52:11 -07:00
parent d9079cc883
commit 76f1b901db
2 changed files with 11 additions and 1 deletions

View File

@ -30,7 +30,8 @@ mkzversion(char *dir, char *file)
"package runtime\n"
"\n"
"const defaultGoroot = `%s`\n"
"const theVersion = `%s`\n", goroot_final, goversion));
"const theVersion = `%s`\n"
"var buildVersion = theVersion\n", goroot_final, goversion));
writefile(&out, file, 0);

View File

@ -129,6 +129,8 @@ static bool exitsyscallfast(void);
static bool haveexperiment(int8*);
static void allgadd(G*);
extern String runtime·buildVersion;
// The bootstrap sequence is:
//
// call osinit
@ -188,6 +190,13 @@ runtime·schedinit(void)
runtime·copystack = false;
mstats.enablegc = 1;
if(runtime·buildVersion.str == nil) {
// Condition should never trigger. This code just serves
// to ensure runtime·buildVersion is kept in the resulting binary.
runtime·buildVersion.str = (uint8*)"unknown";
runtime·buildVersion.len = 7;
}
}
extern void main·init(void);