aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dist
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-05-25 16:31:41 -0700
committerIan Lance Taylor <iant@golang.org>2021-06-01 19:59:18 +0000
commit24e9707cbfa6b1ed6abdd4b11f9ddaf3aac5ad88 (patch)
tree0b9fad4006bd549b9813255c6b540651f7bcb6a9 /src/cmd/dist
parent272552275f56345095b4ea7f404e5b317856cf07 (diff)
downloadgo-24e9707cbfa6b1ed6abdd4b11f9ddaf3aac5ad88.tar.gz
go-24e9707cbfa6b1ed6abdd4b11f9ddaf3aac5ad88.zip
cmd/link, cmd/cgo: support -flto in CFLAGS
The linker now accepts unrecognized object files in external linking mode. These objects will simply be passed to the external linker. This permits using -flto which can generate pure byte code objects, whose symbol table the linker does not know how to read. The cgo tool now passes -fno-lto when generating objects whose symbols it needs to read. The cgo tool now emits matching types in different objects, so that the lto linker does not report a mismatch. This is based on https://golang.org/cl/293290 by Derek Parker. For #43505 Fixes #43830 Fixes #46295 Change-Id: I6787de213417466784ddef5af8899e453b4ae1ad Reviewed-on: https://go-review.googlesource.com/c/go/+/322614 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Diffstat (limited to 'src/cmd/dist')
-rw-r--r--src/cmd/dist/test.go29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index 50bf80ba59..bc49c6d804 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -722,14 +722,29 @@ func (t *tester) registerTests() {
},
})
if t.hasCxx() {
- t.tests = append(t.tests, distTest{
- name: "swig_callback",
- heading: "../misc/swig/callback",
- fn: func(dt *distTest) error {
- t.addCmd(dt, "misc/swig/callback", t.goTest())
- return nil
+ t.tests = append(t.tests,
+ distTest{
+ name: "swig_callback",
+ heading: "../misc/swig/callback",
+ fn: func(dt *distTest) error {
+ t.addCmd(dt, "misc/swig/callback", t.goTest())
+ return nil
+ },
+ },
+ distTest{
+ name: "swig_callback_lto",
+ heading: "../misc/swig/callback",
+ fn: func(dt *distTest) error {
+ cmd := t.addCmd(dt, "misc/swig/callback", t.goTest())
+ cmd.Env = append(os.Environ(),
+ "CGO_CFLAGS=-flto",
+ "CGO_CXXFLAGS=-flto",
+ "CGO_LDFLAGS=-flto",
+ )
+ return nil
+ },
},
- })
+ )
}
}
}