diff options
author | xd <xiangdong.ji@gmail.com> | 2020-10-14 11:02:49 -0700 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2020-10-27 15:42:41 +0000 |
commit | b3f7f60129b822978115717912f4d477a46e8467 (patch) | |
tree | e1f905eec4a36990c780ec6a75bc78eb0a217105 | |
parent | 3c55aea67aa65c62016020d5907b481da010f7e0 (diff) | |
download | go-b3f7f60129b822978115717912f4d477a46e8467.tar.gz go-b3f7f60129b822978115717912f4d477a46e8467.zip |
cmd/dist: fix build failure of misc/cgo/test on arm64
misc/cgo/test fails in 'dist test' on arm64 if the C compiler is of GCC-9.4 or
above and its 'outline atomics' feature is enabled, since the internal linking
hasn't yet supported "__attribute__((constructor))" and also mis-handles hidden
visibility.
This change addresses the problem by skipping the internal linking cases of
misc/cgo/test on linux/arm64. It fixes 'dist test' failure only, user is expected to
pass a GCC option '-mno-outline-atomics' via CGO_CFLAGS if running into the same
problem when building cgo programs using internal linking.
Updates #39466
Change-Id: I57f9e85fca881e5fd2dae6c1b4446bce9e0c1975
Reviewed-on: https://go-review.googlesource.com/c/go/+/262357
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
-rw-r--r-- | src/cmd/dist/test.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index 622d0cee83..3cf49dc8ad 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -1081,7 +1081,12 @@ func (t *tester) cgoTest(dt *distTest) error { cmd := t.addCmd(dt, "misc/cgo/test", t.goTest()) cmd.Env = append(os.Environ(), "GOFLAGS=-ldflags=-linkmode=auto") - if t.internalLink() { + // Skip internal linking cases on arm64 to support GCC-9.4 and above, + // only for linux, conservatively. + // See issue #39466. + skipInternalLink := goarch == "arm64" && goos == "linux" + + if t.internalLink() && !skipInternalLink { cmd := t.addCmd(dt, "misc/cgo/test", t.goTest(), "-tags=internal") cmd.Env = append(os.Environ(), "GOFLAGS=-ldflags=-linkmode=internal") } @@ -1157,7 +1162,7 @@ func (t *tester) cgoTest(dt *distTest) error { if t.supportedBuildmode("pie") { t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie") - if t.internalLink() && t.internalLinkPIE() { + if t.internalLink() && t.internalLinkPIE() && !skipInternalLink { t.addCmd(dt, "misc/cgo/test", t.goTest(), "-buildmode=pie", "-ldflags=-linkmode=internal", "-tags=internal,internal_pie") } t.addCmd(dt, "misc/cgo/testtls", t.goTest(), "-buildmode=pie") |