mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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 #4714 LGTM=minux.ma, iant R=golang-codereviews, minux.ma, iant, rsc, dominik.honnef CC=golang-codereviews https://golang.org/cl/57100043
This commit is contained in:
parent
76c9182523
commit
2dc759d7c6
6 changed files with 79 additions and 54 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue