1
0
mirror of https://github.com/golang/go synced 2024-11-21 18:24:46 -07:00

runtime: correct runtime.GOOS, runtime.GOARCH

If the same directory was used for multiple builds,
it was possible for a stale version.go to contain the
wrong definitions for $GOOS and $GOARCH, because
they can change even if the hg version does not.
Split into multiple files to fix.

R=r, r2
CC=golang-dev
https://golang.org/cl/4124050
This commit is contained in:
Russ Cox 2011-02-02 15:35:54 -05:00
parent bd4e49f524
commit bc874ec0dd
2 changed files with 12 additions and 4 deletions

View File

@ -26,8 +26,12 @@ GOFILES=\
softfloat64.go\
type.go\
version.go\
version_$(GOOS).go\
version_$(GOARCH).go\
runtime_defs.go\
CLEANFILES+=version.go version_*.go
OFILES_windows=\
syscall.$O\
@ -127,6 +131,12 @@ mkversion: mkversion.c
version.go: mkversion
./mkversion >version.go
version_$(GOARCH).go:
(echo 'package runtime'; echo 'const theGoarch = "$(GOARCH)"') >$@
version_$(GOOS).go:
(echo 'package runtime'; echo 'const theGoos = "$(GOOS)"') >$@
%.c: %.goc goc2c
./goc2c `pwd`/$< > $@.tmp
mv -f $@.tmp $@

View File

@ -5,13 +5,11 @@ char *template =
"// generated by mkversion.c; do not edit.\n"
"package runtime\n"
"const defaultGoroot = \"%s\"\n"
"const theVersion = \"%s\"\n"
"const theGoarch = \"%s\"\n"
"const theGoos = \"%s\"\n";
"const theVersion = \"%s\"\n";
void
main(void)
{
print(template, getgoroot(), getgoversion(), getgoarch(), getgoos());
print(template, getgoroot(), getgoversion());
exits(0);
}