]> Cypherpunks repositories - gostls13.git/commit
cmd/link, cmd/cgo: support -flto in CFLAGS
authorIan Lance Taylor <iant@golang.org>
Tue, 25 May 2021 23:31:41 +0000 (16:31 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 1 Jun 2021 19:59:18 +0000 (19:59 +0000)
commit24e9707cbfa6b1ed6abdd4b11f9ddaf3aac5ad88
tree0b9fad4006bd549b9813255c6b540651f7bcb6a9
parent272552275f56345095b4ea7f404e5b317856cf07
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>
src/cmd/cgo/gcc.go
src/cmd/cgo/out.go
src/cmd/dist/test.go
src/cmd/go/testdata/script/cgo_lto2_issue43830.txt [new file with mode: 0644]
src/cmd/go/testdata/script/cgo_lto_issue43830.txt [new file with mode: 0644]
src/cmd/link/internal/ld/ar.go
src/cmd/link/internal/ld/config.go
src/cmd/link/internal/ld/lib.go