go/src/cmd
Jay Conrod 742dcba7bb cmd: support space and quotes in CC and CXX
The CC and CXX environment variables now support spaces and quotes
(both double and single). This fixes two issues: first, if CC is a
single path that contains spaces (like 'c:\Program
Files\gcc\bin\gcc.exe'), that should now work if the space is quoted
or escaped (#41400). Second, if CC or CXX has multiple arguments (like
'gcc -O2'), they are now split correctly, and the arguments are passed
before other arguments when invoking the C compiler. Previously,
strings.Fields was used to split arguments, and the arguments were
placed later in the command line. (#43078).

Fixes golang/go#41400
Fixes golang/go#43078

NOTE: This change also includes a fix (CL 341929) for a test that was
broken by the original CL. Commit message for the fix is below.

[dev.cmdgo] cmd/link: fix TestBuildForTvOS

This test was broken in CL 334732 on darwin.

The test invokes 'go build' with a CC containing the arguments
-framework CoreFoundation. Previously, the go command split CC on
whitespace, and inserted the arguments after the command line when
running CC directly. Those arguments weren't passed to cgo though,
so cgo ran CC without -framework CoreFoundation (or any of the other
flags).

In CL 334732, we pass CC through to cgo, and cgo splits arguments
using str.SplitQuotedFields. So -framework CoreFoundation actually
gets passed to the C compiler. It appears that -framework flags are
only meant to be used in linking operations, so when cgo invokes clang
with -E (run preprocessor only), clang emits an error that -framework
is unused.

This change fixes the test by moving -framework CoreFoundation out of
CC and into CGO_LDFLAGS.

Change-Id: I2d5d89ddb19c94adef65982a8137b01f037d5c11
Reviewed-on: https://go-review.googlesource.com/c/go/+/334732
Trust: Jay Conrod <jayconrod@google.com>
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/341936
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-08-16 20:23:11 +00:00
..
addr2line
api cmd/api: disallow silent API additions after api/go1.n.txt is created 2021-05-03 19:14:16 +00:00
asm cmd/internal/obj/arm64: fix an encoding error of CMPW instruction 2021-06-29 02:34:20 +00:00
buildid
cgo cmd: support space and quotes in CC and CXX 2021-08-16 20:23:11 +00:00
compile cmd: support space and quotes in CC and CXX 2021-08-16 20:23:11 +00:00
cover cmd/cover: use golang.org/x/tools/cover directly 2021-03-25 20:57:58 +00:00
dist cmd: support space and quotes in CC and CXX 2021-08-16 20:23:11 +00:00
doc cmd/doc: properly display interface methods 2021-03-19 03:05:26 +00:00
fix all: introduce and use internal/execabs 2021-01-21 19:10:18 +00:00
go cmd: support space and quotes in CC and CXX 2021-08-16 20:23:11 +00:00
gofmt [dev.typeparams] cmd/gofmt: remove typeparams guards 2021-06-22 17:02:41 +00:00
internal cmd: support space and quotes in CC and CXX 2021-08-16 20:23:11 +00:00
link cmd: support space and quotes in CC and CXX 2021-08-16 20:23:11 +00:00
nm cmd/dist,runtime: support cgo on openbsd/mips64 2021-04-28 12:51:42 +00:00
objdump cmd/internal/objfile: emit better error for Go object of a different version 2021-04-30 16:53:35 +00:00
pack cmd/pack: use testing.T.TempDir in tests 2021-04-07 13:24:10 +00:00
pprof cmd/pprof,runtime/pprof: disable test on more broken platforms 2021-06-17 21:58:54 +00:00
test2json all: introduce and use internal/execabs 2021-01-21 19:10:18 +00:00
trace runtime: move next_gc and last_next_gc into gcControllerState 2021-04-14 14:03:30 +00:00
vendor [dev.typeparams] cmd: update vendored golang.org/x/tools to 337cebd2c1 2021-08-10 16:07:37 +00:00
vet [dev.typeparams] all: merge master (46fd547) into dev.typeparams 2021-08-12 12:43:12 -07:00
README.vendor
go.mod [dev.typeparams] cmd: update vendored golang.org/x/tools to 337cebd2c1 2021-08-10 16:07:37 +00:00
go.sum [dev.typeparams] cmd: update vendored golang.org/x/tools to 337cebd2c1 2021-08-10 16:07:37 +00:00

README.vendor

See src/README.vendor for information on loading vendored packages
and updating the vendor directory.