[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