From: Russ Cox Date: Mon, 19 Jan 2015 16:33:46 +0000 (-0500) Subject: [dev.cc] cmd/dist, lib9: make GOHOSTARCH, GOHOSTOS available to C programs X-Git-Tag: go1.5beta1~1915^2~117 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c4dd7fac89a845d4c9e5e9f1e079d9d7013269de;p=gostls13.git [dev.cc] cmd/dist, lib9: make GOHOSTARCH, GOHOSTOS available to C programs Needed for invoking a Go subprocess in the C code. The Go tools live in $GOROOT/pkg/tool/$GOHOSTARCH_$GOHOSTOS. Change-Id: I961b6b8a07de912de174b758b2fb87d77080546d Reviewed-on: https://go-review.googlesource.com/3042 Reviewed-by: Ian Lance Taylor --- diff --git a/include/libc.h b/include/libc.h index e4d8799077..d82a19ccce 100644 --- a/include/libc.h +++ b/include/libc.h @@ -292,6 +292,8 @@ extern char* getgoversion(void); extern char* getgoarm(void); extern char* getgo386(void); extern char* getgoextlinkenabled(void); +extern char* getgohostos(void); +extern char* getgohostarch(void); extern char* mktempdir(void); extern void removeall(char*); diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index 9e4d1e3c22..366612cdd1 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -929,6 +929,8 @@ func install(dir string) { compile = append(compile, "-D", fmt.Sprintf("GOOS=%q", goos), "-D", fmt.Sprintf("GOARCH=%q", goarch), + "-D", fmt.Sprintf("GOHOSTOS=%q", gohostos), + "-D", fmt.Sprintf("GOHOSTARCH=%q", gohostarch), "-D", fmt.Sprintf("GOROOT=%q", goroot_final), "-D", fmt.Sprintf("GOVERSION=%q", goversion), "-D", fmt.Sprintf("GOARM=%q", goarm), diff --git a/src/lib9/goos.c b/src/lib9/goos.c index 2d4a800dd1..68b94d6114 100644 --- a/src/lib9/goos.c +++ b/src/lib9/goos.c @@ -52,8 +52,20 @@ getgo386(void) return defgetenv("GO386", GO386); } -char * +char* getgoextlinkenabled(void) { return GO_EXTLINK_ENABLED; } + +char* +getgohostarch(void) +{ + return GOHOSTARCH; +} + +char* +getgohostos(void) +{ + return GOHOSTOS; +}