-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
Proposal Details
As a part of an invocation of go tool cgo
, temporary files are created and placed in an "object directory". This directory can be specified with the -objdir flag, and it defaults to _obj within the current directory.
There are some issues with this:
- It is racy in conditions where this tool is invoked in parallel within the same directory
- it creates unexpected clutter (the objdir is not cleaned up at all post-invocation)
- it fails when the current directory is not writable (with a somewhat misleading error, e.g "Fatal error: can't create _obj/cgo.o: No such file or directory"; the success of
os.Mkdir
is not verified)
I believe that creating a temporary directory and removing it afterwards would be a better default, as it would avoid these issues.
Anything that explicitly sets the -objdir
flag would be left unchanged, and the current default behaviour could be restored simply by explicitly setting -objdir
to _obj
This would break anything that runs go tool cgo
without explicitly setting -objdir
and assumes that the _obj
directory is left over afterwards. In the golang/go repository, there is no occurrence of this, aside from one behaviour test for cmd/go