Commit 6b188ef5 authored by Shenghou Ma's avatar Shenghou Ma

cmd/dist, build: support building statically linked toolchain

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
parent 57d37b55
...@@ -112,6 +112,7 @@ void goc2c(char*, char*); ...@@ -112,6 +112,7 @@ void goc2c(char*, char*);
// main.c // main.c
extern int vflag; extern int vflag;
extern int sflag;
void usage(void); void usage(void);
void xmain(int argc, char **argv); void xmain(int argc, char **argv);
......
...@@ -720,6 +720,8 @@ install(char *dir) ...@@ -720,6 +720,8 @@ install(char *dir)
vadd(&link, bpathf(&b, "%s/%s", tooldir, name)); vadd(&link, bpathf(&b, "%s/%s", tooldir, name));
} else { } else {
vcopy(&link, gccargs.p, gccargs.len); vcopy(&link, gccargs.p, gccargs.len);
if(sflag)
vadd(&link, "-static");
vadd(&link, "-o"); vadd(&link, "-o");
targ = link.len; targ = link.len;
vadd(&link, bpathf(&b, "%s/%s%s", tooldir, name, exe)); vadd(&link, bpathf(&b, "%s/%s%s", tooldir, name, exe));
...@@ -1527,6 +1529,9 @@ cmdbootstrap(int argc, char **argv) ...@@ -1527,6 +1529,9 @@ cmdbootstrap(int argc, char **argv)
case 'a': case 'a':
rebuildall = 1; rebuildall = 1;
break; break;
case 's':
sflag++;
break;
case 'v': case 'v':
vflag++; vflag++;
break; break;
...@@ -1613,6 +1618,9 @@ cmdinstall(int argc, char **argv) ...@@ -1613,6 +1618,9 @@ cmdinstall(int argc, char **argv)
int i; int i;
ARGBEGIN{ ARGBEGIN{
case 's':
sflag++;
break;
case 'v': case 'v':
vflag++; vflag++;
break; break;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "a.h" #include "a.h"
int vflag; int vflag;
int sflag;
char *argv0; char *argv0;
// cmdtab records the available commands. // cmdtab records the available commands.
......
...@@ -37,6 +37,11 @@ ...@@ -37,6 +37,11 @@
# #
# CC: Command line to run to get at host C compiler. # CC: Command line to run to get at host C compiler.
# Default is "gcc". Also supported: "clang". # 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 set -e
if [ ! -f run.bash ]; then if [ ! -f run.bash ]; then
...@@ -140,7 +145,7 @@ buildall="-a" ...@@ -140,7 +145,7 @@ buildall="-a"
if [ "$1" = "--no-clean" ]; then if [ "$1" = "--no-clean" ]; then
buildall="" buildall=""
fi 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. # Delay move of dist tool to now, because bootstrap may clear tool directory.
mv cmd/dist/dist "$GOTOOLDIR"/dist mv cmd/dist/dist "$GOTOOLDIR"/dist
"$GOTOOLDIR"/go_bootstrap clean -i std "$GOTOOLDIR"/go_bootstrap clean -i std
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment