Open vault-thirteen opened 1 year ago
CC @thanm @cherrymui @bcmills
If we want to be fully consistent, I wonder whether cmd/go should set TMPDIR=$GOTMPDIR
before invoking any subprocess. For example, cmd/cgo also uses os.CreateTemp
which will currently use TMPDIR
rather than GOTMPDIR
.
Agreed with @ianlancetaylor that cmd/go is probably a better place to do the setting. One consequence is that it will also affect external commands invoked by Go tools (e.g. the C compiler, C linker, ar
command, etc. invoked by the Go linker or cgo command, which may also fix (work around) #59026).
Updated the issue title to cmd/go tentatively.
What version of Go are you using (
go version
)?1.20.3.
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?Windows 10, Intel x86-64.
What did you do?
My environment variable
GOTMPDIR
is set to a custom place.When I am trying to build something I look at the compiler's output using the
-x
argument. It looks like, the compiler is using theGOTMPDIR
at the frist stage of executable file building, at the compile stage, but at the second stage it uses the default system path instead of theGOTMPDIR
variable.What did you expect to see?
I expect to use the
GOTMPDIR
variable value for all build stages in Go.What did you see instead?
It looks like, the compiler is using the
GOTMPDIR
at the frist stage of executable file building, at the compile stage, but at the second stage it uses the default system path instead of theGOTMPDIR
variable.Here we can see that path in first stage is:
But in the linking stage it is suddenly changed to the default path: