go: remove notion of separate __obj__
directory
#17775
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Remove the notion of a separate
__obj__
directory (obj_dir_path
in the code) for compiling object files (e.g., Cgo and assembly) and just generate and capture object files in the same directory as the sources they are built from.The issue is that the user can configure references to the source directory in
-I
and other compiler/assembler options using the${SRCDIR}
syntax. With a separate object directory, the rules would need additional code to either copy files around or duplicate-I
and other options to account for both the original sources directory and the objects directory if code wanted to be agnostic to the location of files that it expected to be in the package directory.The idea for an objects tmp directory originally came from the
go
toolchain.go
copies source files into the objects directory to avoid the duplication problem mentioned above. It makes sense for the Go toolchain to do this because the original sources are the user's actual source repository. Writing temporary object files into the original repository would make for a bad user experience.Pants, on the other hand, uses an execution sandbox and does not have the same issue about modifying the original repository during a build. Thus, it makes sense in Pants to avoid copying files and just put object files next to the sources in the execution sandbox they are built from. This means the Cgo rules can avoid having to parse and duplicate options in which
${SRCDIR}
is used.This is a partial fix for #17592. It fixes errors due to the mishandling of
${SRCDIR}
by the Cgo rules in not duplicating options that had${SRCDIR}
in them to account for both the original sources directory and the objects directory.