]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: correct runtime.GOOS, runtime.GOARCH
authorRuss Cox <rsc@golang.org>
Wed, 2 Feb 2011 20:35:54 +0000 (15:35 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 2 Feb 2011 20:35:54 +0000 (15:35 -0500)
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

src/pkg/runtime/Makefile
src/pkg/runtime/mkversion.c

index e9488cfb505238adb69d263dd2cdf13596f7c533..3a2d3139763e28ad0b3baea675832f3d30a69605 100644 (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 $@
index 9790d3f093f9c539b88d1be57d1a3d33bfdad34c..56afa1892ed003b4197c1895e80bd538f4f90993 100644 (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);
 }