]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist, build: support building statically linked toolchain
authorShenghou Ma <minux.ma@gmail.com>
Wed, 2 Oct 2013 03:44:20 +0000 (23:44 -0400)
committerShenghou Ma <minux.ma@gmail.com>
Wed, 2 Oct 2013 03:44:20 +0000 (23:44 -0400)
Added a new $GO_DISTFLAGS to make.bash, and while we're here,
added mention $CXX in make.bash (CL 13704044).

Fixes #6448.
Update #3564
We can pass GO_DISTFLAGS=-s from misc/dist to make.bash so that
it will build a statically linked toolchain.
(Note: OS X doesn't have the concept of static linking, so don't
pass GO_DISTFLAGS=-s for OS X builds)

R=adg, rsc, iant
CC=golang-dev
https://golang.org/cl/13887043

src/cmd/dist/a.h
src/cmd/dist/build.c
src/cmd/dist/main.c
src/make.bash

index 5ded13d6f68b8e21c162ad3c992801ae41fb18b0..9de93180f188a0f077c2484be2d556100dec2820 100644 (file)
@@ -112,6 +112,7 @@ void        goc2c(char*, char*);
 
 // main.c
 extern int vflag;
+extern int sflag;
 void   usage(void);
 void   xmain(int argc, char **argv);
 
index 9fe6058a50d18c3f475a00e70fc46703ba55a33f..e6e5f0cf7f4288d7f6d6f23226d403263ce1c576 100644 (file)
@@ -720,6 +720,8 @@ install(char *dir)
                        vadd(&link, bpathf(&b, "%s/%s", tooldir, name));
                } else {
                        vcopy(&link, gccargs.p, gccargs.len);
+                       if(sflag)
+                               vadd(&link, "-static");
                        vadd(&link, "-o");
                        targ = link.len;
                        vadd(&link, bpathf(&b, "%s/%s%s", tooldir, name, exe));
@@ -1527,6 +1529,9 @@ cmdbootstrap(int argc, char **argv)
        case 'a':
                rebuildall = 1;
                break;
+       case 's':
+               sflag++;
+               break;
        case 'v':
                vflag++;
                break;
@@ -1613,6 +1618,9 @@ cmdinstall(int argc, char **argv)
        int i;
 
        ARGBEGIN{
+       case 's':
+               sflag++;
+               break;
        case 'v':
                vflag++;
                break;
index 72a7579d14230f132e9480678153733e9a6847f9..fad01802a5952b6c2456d8d3b848dea4757b1fd5 100644 (file)
@@ -5,6 +5,7 @@
 #include "a.h"
 
 int vflag;
+int sflag;
 char *argv0;
 
 // cmdtab records the available commands.
index 30388388f2d2b7c6c3e1eb7fb8a8942c44aaea39..877d1e5ebb659ae76ee0e2295b8313641c3395a5 100755 (executable)
 #
 # CC: Command line to run to get at host C compiler.
 # Default is "gcc". Also supported: "clang".
+# CXX: Command line to run to get at host C++ compiler, only recorded
+# for cgo use. Default is "g++". Also supported: "clang++".
+#
+# GO_DISTFLAGS: extra flags to provide to "dist bootstrap". Use "-s"
+# to build a statically linked toolchain.
 
 set -e
 if [ ! -f run.bash ]; then
@@ -140,7 +145,7 @@ buildall="-a"
 if [ "$1" = "--no-clean" ]; then
        buildall=""
 fi
-./cmd/dist/dist bootstrap $buildall -v # builds go_bootstrap
+./cmd/dist/dist bootstrap $buildall $GO_DISTFLAGS -v # builds go_bootstrap
 # Delay move of dist tool to now, because bootstrap may clear tool directory.
 mv cmd/dist/dist "$GOTOOLDIR"/dist
 "$GOTOOLDIR"/go_bootstrap clean -i std