[short] skip 'compiles and links executables'
# use default.pgo for a single main package
-go build -a -x -pgo=auto -o a1.exe ./a/a1
+go build -n -pgo=auto -o a1.exe ./a/a1
stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
# check that pgo applied to dependencies
# check that pgo appears in build info
# N.B. we can't start the stdout check with -pgo because the script assumes that
# if the first arg starts with - it is a grep flag.
-go version -m a1.exe
-stdout 'build\s+-pgo=.*default\.pgo'
+stderr 'build\\t-pgo=.*default\.pgo'
# use default.pgo for ... with a single main package
-go build -a -x -pgo=auto ./a/...
+go build -n -pgo=auto ./a/...
stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
# check that pgo appears in build info
-go version -m a1$GOEXE
-stdout 'build\s+-pgo=.*default\.pgo'
+stderr 'build\\t-pgo=.*default\.pgo'
# build succeeds without PGO when default.pgo file is absent
-go build -a -x -pgo=auto -o nopgo.exe ./nopgo
+go build -n -pgo=auto -o nopgo.exe ./nopgo
stderr 'compile.*nopgo.go'
! stderr 'compile.*-pgoprofile'
# check that pgo doesn't appear in build info
-go version -m nopgo.exe
-! stdout 'build\s+-pgo='
+! stderr 'build\\t-pgo='
# other build-related commands
go install -a -n -pgo=auto ./a/a1
# -pgo=auto is the default. Commands without explicit -pgo=auto
# should work as -pgo=auto.
-go build -a -x -o a1.exe ./a/a1
+go build -a -n -o a1.exe ./a/a1
stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
stderr 'compile.*-p test/dep.*-pgoprofile=.*default\.pgo'
# check that pgo appears in build info
-go version -m a1.exe
-stdout 'build\s+-pgo=.*default\.pgo'
+stderr 'build\\t-pgo=.*default\.pgo'
-go build -a -x -o nopgo.exe ./nopgo
+go build -a -n -o nopgo.exe ./nopgo
stderr 'compile.*nopgo.go'
! stderr 'compile.*-pgoprofile'
# check that pgo doesn't appear in build info
-go version -m nopgo.exe
-! stdout 'build\s+-pgo='
+! stderr 'build\\t-pgo='
# -pgo=off should turn off PGO.
-go build -a -x -pgo=off -o a1.exe ./a/a1
+go build -a -n -pgo=off -o a1.exe ./a/a1
stderr 'compile.*a1.go'
! stderr 'compile.*-pgoprofile'
# check that pgo doesn't appear in build info
-go version -m a1.exe
-! stdout 'build\s+-pgo='
+! stderr 'build\\t-pgo='
-- go.mod --
module test
# Test go build -pgo=auto flag with multiple main packages.
-[short] skip 'compiles and links executables'
-
-env GOBIN=$WORK/bin
-go install -a -x -pgo=auto ./a ./b ./nopgo
+go install -a -n -pgo=auto ./a ./b ./nopgo
# a/default.pgo applies to package a and (transitive)
# dependencies.
stderr -count=2 'compile.*-pgoprofile=.*dep3(/|\\\\)dep3\.go'
# check that pgo appears or not in build info as expected
-# N.B. we can't start the stdout check with -pgo because the script assumes that
-# if the first arg starts with - it is a grep flag.
-go version -m $GOBIN/a$GOEXE
-stdout 'build\s+-pgo=.*a'${/}'default\.pgo'
-
-go version -m $GOBIN/b$GOEXE
-stdout 'build\s+-pgo=.*b'${/}'default\.pgo'
-
-go version -m $GOBIN/nopgo$GOEXE
-! stdout 'build\s+-pgo='
+stderr 'path\\ttest/a\\n.*build\\t-pgo=.*a(/|\\\\)default\.pgo'
+stderr 'path\\ttest/b\\n.*build\\t-pgo=.*b(/|\\\\)default\.pgo'
+! stderr 'path\\ttest/nopgo\\n.*build\\t-pgo='
# go test works the same way
go test -a -n -pgo=auto ./a ./b ./nopgo
[!compiler:gc] skip 'using -gcflags and -ldflags'
[short] skip
-env GOCACHE=$WORK/gocache # Looking for compile commands, so need a clean cache.
-
# -gcflags=-e applies to named packages, not dependencies
-go build -n -v -gcflags=-e z1 z2
+go build -a -n -v -gcflags=-e z1 z2
stderr 'compile.* -p z1.* -e '
stderr 'compile.* -p z2.* -e '
stderr 'compile.* -p y'
! stderr 'compile.* -p [^z].* -e '
# -gcflags can specify package=flags, and can be repeated; last match wins
-go build -n -v -gcflags=-e -gcflags=z1=-N z1 z2
+go build -a -n -v -gcflags=-e -gcflags=z1=-N z1 z2
stderr 'compile.* -p z1.* -N '
! stderr 'compile.* -p z1.* -e '
! stderr 'compile.* -p z2.* -N '
! stderr 'compile.* -p [^z].* -N '
# -gcflags can have arbitrary spaces around the flags
-go build -n -v -gcflags=' z1 = -e ' z1
+go build -a -n -v -gcflags=' z1 = -e ' z1
stderr 'compile.* -p z1.* -e '
# -gcflags='all=-e' should apply to all packages, even with go test
-go test -c -n -gcflags='all=-e' z1
+go test -a -c -n -gcflags='all=-e' z1
stderr 'compile.* -p z3.* -e '
# this particular -gcflags argument made the compiler crash
stderr 'invalid value'
# -ldflags for implicit test package applies to test binary
-go test -c -n -gcflags=-N -ldflags=-X=x.y=z z1
+go test -a -c -n -gcflags=-N -ldflags=-X=x.y=z z1
stderr 'compile.* -N .*z_test.go'
stderr 'link.* -X=x.y=z'
# -ldflags for explicit test package applies to test binary
-go test -c -n -gcflags=z1=-N -ldflags=z1=-X=x.y=z z1
+go test -a -c -n -gcflags=z1=-N -ldflags=z1=-X=x.y=z z1
stderr 'compile.* -N .*z_test.go'
stderr 'link.* -X=x.y=z'
# -ldflags applies to link of command
-go build -n -ldflags=-X=math.pi=3 my/cmd/prog
+go build -a -n -ldflags=-X=math.pi=3 my/cmd/prog
stderr 'link.* -X=math.pi=3'
# -ldflags applies to link of command even with strange directory name
-go build -n -ldflags=-X=math.pi=3 my/cmd/prog/
+go build -a -n -ldflags=-X=math.pi=3 my/cmd/prog/
stderr 'link.* -X=math.pi=3'
# -ldflags applies to current directory
cd my/cmd/prog
-go build -n -ldflags=-X=math.pi=3
+go build -a -n -ldflags=-X=math.pi=3
stderr 'link.* -X=math.pi=3'
# -ldflags applies to current directory even if GOPATH is funny
[!case-sensitive] cd $WORK/GoPath/src/my/cmd/prog
-go build -n -ldflags=-X=math.pi=3
+go build -a -n -ldflags=-X=math.pi=3
stderr 'link.* -X=math.pi=3'
# cgo.a should not be a dependency of internally-linked go package
# Regression test for golang.org/issue/29667:
# spurious 'failed to cache compiled Go files' errors.
-# This test failed reliably when run with -count=10
-# on a Linux workstation.
env GOCACHE=$WORK/gocache
mkdir $GOCACHE
go list -json -compiled -test=false -export=false -deps=true -- . &
go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-go list -json -compiled -test=false -export=false -deps=true -- . &
-
wait
-- go.mod --
stderr 'go: parsing \$GOFLAGS: unknown flag -unsafeptr'
env GOFLAGS=
-env GOCACHE=$WORK/gocache
-
# "go test" on a user package should by default enable an explicit list of analyzers.
-go test -x -run=none .
+go test -n -run=none .
stderr '[/\\]vet'$GOEXE'["]? .* -errorsas .* ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
# An explicitly-empty -vet argument should imply the default analyzers.
-go test -x -vet= -run=none .
+go test -n -vet= -run=none .
stderr '[/\\]vet'$GOEXE'["]? .* -errorsas .* ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
# "go test" on a standard package should by default disable an explicit list.
-go test -x -run=none encoding/binary
+go test -n -run=none encoding/binary
stderr '[/\\]vet'$GOEXE'["]? -unsafeptr=false -unreachable=false ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
-go test -x -vet= -run=none encoding/binary
+go test -n -vet= -run=none encoding/binary
stderr '[/\\]vet'$GOEXE'["]? -unsafeptr=false -unreachable=false ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
# Both should allow users to override via the -vet flag.
-go test -x -vet=unreachable -run=none .
+go test -n -vet=unreachable -run=none .
stderr '[/\\]vet'$GOEXE'["]? -unreachable ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
-go test -x -vet=unreachable -run=none encoding/binary
+go test -n -vet=unreachable -run=none encoding/binary
stderr '[/\\]vet'$GOEXE'["]? -unreachable ["]?\$WORK[/\\][^ ]*[/\\]vet\.cfg'
-- go.mod --