[PATCH] cmd/link: check CGO_CFLAGS for non -g/-I/-O options before internal linking
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Tue, 5 Jan 2021 23:18:24 +0000 (12:18 +1300)
committerMichael Hudson-Doyle <mwhudson@debian.org>
Tue, 9 Feb 2021 23:58:55 +0000 (23:58 +0000)
commita5a7b09fb8be678733e27932fa1218ce3e10254b
treebe86bd1b48450eef66605cfa4edc1a21c2aa70e1
parente8d28df330e04a3db9f40a40413259e4aa5d0f86
[PATCH] cmd/link: check CGO_CFLAGS for non -g/-I/-O options before internal linking

On Debian and Ubuntu we are investigating enabling link-time
optimization by default, which means the default CFLAGS will contain
arguments that cause gcc to generate object files
cmd/link/internal/loadelf cannot process. Rather than failing in this
situation, scan CGO_CFLAGS in mustLinkExternal and do not link
internally if there is a flag that does not start with -g, -I, or -O.

CFLAGS can also be injected via #cgo CFLAGS: directives but as use of
any non-standard library cgo modules disables internal linking anyway,
we don't have to worry about that here.

Fixes #43505

Change-Id: Ib083f6daf22617e2e5df67e95d3bc178942328cd

Gbp-Pq: Name 0007-cmd-link-check-CGO_CFLAGS-for-non-g-I-O-options-befo.patch
src/cmd/link/internal/ld/config.go