diff options
author | Elias Naur <elias.naur@gmail.com> | 2014-02-06 09:11:00 -0800 |
---|---|---|
committer | Elias Naur <elias.naur@gmail.com> | 2014-02-06 09:11:00 -0800 |
commit | 9be6bbf0e88fadcb8e7031965391ec16a8f9b477 (patch) | |
tree | 2e5f863c6b8e3acaf6acbfa42aa536b17f3f8556 /src/make.bash | |
parent | 3c49825c2ea5d8664709ab6649e5e7f596bcbfc8 (diff) | |
download | go-9be6bbf0e88fadcb8e7031965391ec16a8f9b477.tar.gz |
cmd/go, cmd/cgo, make.bash: cross compiling with cgo enabled
Introduce two new environment variables, CC_FOR_TARGET and CXX_FOR_TARGET.
CC_FOR_TARGET defaults to CC and is used when compiling for GOARCH, while
CC remains for compiling for GOHOSTARCH.
CXX_FOR_TARGET defaults to CXX and is used when compiling C++ code for
GOARCH.
CGO_ENABLED defaults to disabled when cross compiling and has to be
explicitly enabled.
Update issue 4714
LGTM=minux.ma, iant
R=golang-codereviews, minux.ma, iant, rsc, dominik.honnef
CC=golang-codereviews
https://codereview.appspot.com/57100043
Committer: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/make.bash')
-rwxr-xr-x | src/make.bash | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/make.bash b/src/make.bash index 877d1e5eb..bfcb5d58e 100755 --- a/src/make.bash +++ b/src/make.bash @@ -35,10 +35,15 @@ # controls the default behavior of the linker's -linkmode option. The # default value depends on the system. # -# CC: Command line to run to get at host C compiler. +# CC: Command line to run to compile C code for GOHOSTARCH. # 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++". +# +# CC_FOR_TARGET: Command line to run to compile C code for GOARCH. +# This is used by cgo. Default is CC. +# +# CXX_FOR_TARGET: Command line to run to compile C++ code for GOARCH. +# This is used by cgo. Default is CXX, or, if that is not set, +# "g++" or "clang++". # # GO_DISTFLAGS: extra flags to provide to "dist bootstrap". Use "-s" # to build a statically linked toolchain. @@ -153,13 +158,15 @@ echo if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then echo "# Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH." - GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \ + # CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the host, however, + # use the host compiler, CC, from `cmd/dist/dist env` instead. + CC=$CC GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \ "$GOTOOLDIR"/go_bootstrap install -ccflags "$GO_CCFLAGS" -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std echo fi echo "# Building packages and commands for $GOOS/$GOARCH." -"$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -ccflags "$GO_CCFLAGS" -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std +CC=$CC_FOR_TARGET "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -ccflags "$GO_CCFLAGS" -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std echo rm -f "$GOTOOLDIR"/go_bootstrap |