@ -269,6 +269,8 @@ type errJustExit int
func ( e errJustExit ) Error ( ) string { return fmt . Sprintf ( "exit: %d" , e ) }
func ( e errJustExit ) Error ( ) string { return fmt . Sprintf ( "exit: %d" , e ) }
var goVersionSemver string
func goVersionOK ( ) bool {
func goVersionOK ( ) bool {
const (
const (
minGoVersionSemver = "v1.17.0"
minGoVersionSemver = "v1.17.0"
@ -285,8 +287,8 @@ func goVersionOK() bool {
return false
return false
}
}
versionSemver : = "v" + strings . TrimPrefix ( version , "go" )
goVersionSemver = "v" + strings . TrimPrefix ( version , "go" )
if semver . Compare ( v ersionSemver, minGoVersionSemver ) < 0 {
if semver . Compare ( goV ersionSemver, minGoVersionSemver ) < 0 {
fmt . Fprintf ( os . Stderr , "Go version %q is too old; please upgrade to Go %s\n" , version , suggestedGoVersion )
fmt . Fprintf ( os . Stderr , "Go version %q is too old; please upgrade to Go %s\n" , version , suggestedGoVersion )
return false
return false
}
}
@ -487,8 +489,15 @@ This command wraps "go %s". Below is its help:
goArgs := [ ] string {
goArgs := [ ] string {
command ,
command ,
"-trimpath" ,
"-trimpath" ,
toolexecFlag . String ( ) ,
}
}
if semver . Compare ( goVersionSemver , "v1.18.0" ) >= 0 {
// TODO: remove the conditional once we drop support for 1.17
goArgs = append ( goArgs ,
"-buildinfo=false" ,
"-buildvcs=false" ,
)
}
goArgs = append ( goArgs , toolexecFlag . String ( ) )
if flagDebugDir != "" {
if flagDebugDir != "" {
// In case the user deletes the debug directory,
// In case the user deletes the debug directory,
// and a previous build is cached,
// and a previous build is cached,
@ -883,7 +892,7 @@ var cannotObfuscate = map[string]bool{
"crypto/x509/internal/macos" : true ,
"crypto/x509/internal/macos" : true ,
}
}
// Obtained from "go list -deps runtime" on Go master (1.18) as of Nov 202 1.
// Obtained from "go list -deps runtime" on Go 1.18beta 1.
// Note that the same command on Go 1.17 results in a subset of this list.
// Note that the same command on Go 1.17 results in a subset of this list.
var runtimeAndDeps = map [ string ] bool {
var runtimeAndDeps = map [ string ] bool {
"internal/goarch" : true ,
"internal/goarch" : true ,
@ -1797,7 +1806,7 @@ func alterTrimpath(flags []string) []string {
return flagSetValue ( flags , "-trimpath" , sharedTempDir + "=>;" + trimpath )
return flagSetValue ( flags , "-trimpath" , sharedTempDir + "=>;" + trimpath )
}
}
// forwardBuildFlags is obtained from 'go help build' as of Go 1.1 7 .
// forwardBuildFlags is obtained from 'go help build' as of Go 1.1 8beta1 .
var forwardBuildFlags = map [ string ] bool {
var forwardBuildFlags = map [ string ] bool {
// These shouldn't be used in nested cmd/go calls.
// These shouldn't be used in nested cmd/go calls.
"-a" : false ,
"-a" : false ,
@ -1806,12 +1815,15 @@ var forwardBuildFlags = map[string]bool{
"-v" : false ,
"-v" : false ,
// These are always set by garble.
// These are always set by garble.
"-trimpath" : false ,
"-trimpath" : false ,
"-toolexec" : false ,
"-toolexec" : false ,
"-buildinfo" : false ,
"-buildvcs" : false ,
"-p" : true ,
"-p" : true ,
"-race" : true ,
"-race" : true ,
"-msan" : true ,
"-msan" : true ,
"-asan" : true ,
"-work" : true ,
"-work" : true ,
"-asmflags" : true ,
"-asmflags" : true ,
"-buildmode" : true ,
"-buildmode" : true ,
@ -1826,10 +1838,11 @@ var forwardBuildFlags = map[string]bool{
"-modfile" : true ,
"-modfile" : true ,
"-pkgdir" : true ,
"-pkgdir" : true ,
"-tags" : true ,
"-tags" : true ,
"-workfile" : true ,
"-overlay" : true ,
"-overlay" : true ,
}
}
// booleanFlags is obtained from 'go help build' and 'go help testflag' as of Go 1.1 7 .
// booleanFlags is obtained from 'go help build' and 'go help testflag' as of Go 1.1 8beta1 .
var booleanFlags = map [ string ] bool {
var booleanFlags = map [ string ] bool {
// Shared build flags.
// Shared build flags.
"-a" : true ,
"-a" : true ,
@ -1839,9 +1852,12 @@ var booleanFlags = map[string]bool{
"-x" : true ,
"-x" : true ,
"-race" : true ,
"-race" : true ,
"-msan" : true ,
"-msan" : true ,
"-asan" : true ,
"-linkshared" : true ,
"-linkshared" : true ,
"-modcacherw" : true ,
"-modcacherw" : true ,
"-trimpath" : true ,
"-trimpath" : true ,
"-buildinfo" : true ,
"-buildvcs" : true ,
// Test flags (TODO: support its special -args flag)
// Test flags (TODO: support its special -args flag)
"-c" : true ,
"-c" : true ,