golang/go

cmd/go: provide better error message when cross-compiling toolchain is required

Open

#16,395 创建于 2016年7月16日

在 GitHub 查看
 (11 评论) (0 反应) (0 负责人)Go (19,008 fork)batch import
GoCommandNeedsFixhelp wanted

仓库指标

Star
 (133,883 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

  1. What version of Go are you using (go version)?

510fb6397dfc93067dc90d42c58dfc5f8b995285: tip between 1.7rc1 and 1.7rc2

  1. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN="/Users/josh/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/josh"
GORACE=""
GOROOT="/Users/josh/go/tip"
GOTOOLDIR="/Users/josh/go/tip/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pp/0010hzld5b12h_92j5th082r0000gn/T/go-build629103623=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
  1. What did you do?

GOOS=android GOARCH=amd64 go install std cmd

  1. What did you expect to see?

Success.

  1. What did you see instead?
# cmd/addr2line
warning: unable to find runtime/cgo.a
/Users/josh/go/tip/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)

# cmd/asm
warning: unable to find runtime/cgo.a
/Users/josh/go/tip/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)

and so on

Running GOOS=android GOARCH=amd64 go install -ldflags=-v std cmd:

# cmd/cgo
HEADER = -H4 -T0x401000 -D0x0 -R0x1000
searching for runtime.a in $WORK/runtime.a
searching for runtime.a in /Users/josh/go/tip/pkg/android_amd64_shared/runtime.a
searching for runtime/cgo.a in $WORK/runtime/cgo.a
searching for runtime/cgo.a in /Users/josh/go/tip/pkg/android_amd64_shared/runtime/cgo.a
warning: unable to find runtime/cgo.a
 0.00 deadcode
 0.03 pclntab=599713 bytes, funcdata total 119620 bytes
 0.03 dodata
 0.04 dwarf
 0.07 symsize = 0
 0.16 reloc
 0.17 asmb
 0.17 codeblk
 0.17 datblk
 0.18 sym
 0.18 symsize = 122040
 0.19 symsize = 122088
 0.19 dwarf
 0.21 headr
host link: "clang" "-m64" "-gdwarf-2" "-Wl,-z,relro" "-pie" "-o" "/var/folders/pp/0010hzld5b12h_92j5th082r0000gn/T/go-build962217633/cmd/cgo/_obj/exe/a.out" "-rdynamic" "-Qunused-arguments" "/var/folders/pp/0010hzld5b12h_92j5th082r0000gn/T/go-link-534529285/go.o"
/Users/josh/go/tip/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)

and so on

This also causes GOOS=android GOARCH=amd64 ./bootstrap.bash to fail.

Maybe this is expected (?), but it doesn't seem right to me.

贡献者指南