cmd/go, cmd/link: don't handle GOROOT_FINAL in linker #36118
Comments
Change https://golang.org/cl/210943 mentions this issue: |
I don't quite see how we can replace |
Are there still any platforms for which |
When I opened this issue, I was just thinking about how the linker expands
For the purpose of setting the default |
I don't know if anybody really uses |
GOROOT_FINAL
is used to set the final location ofGOROOT
when building the toolchain and standard library.When the compiler or assembler parse a file, they store file names and columns on AST nodes. If the file name is in
GOROOT
, theGOROOT
path is replaced with the literal$GOROOT
. This is done incmd/internal/objabi.AbsFile
. These file names eventually end up in debug data.The linker expands these strings, replacing
$GOROOT
with the actualGOROOT
orGOROOT_FINAL
if that's set. This is done incmd/link/internal/ld.expandGoroot
.We should avoid special handling for
GOROOT_FINAL
in the linker. Instead we should more unified support for-trimpath
.-trimpath
is given to thego
command, all source paths in output files (including compiled .a files and intermediate generated cgo files) should be derived from package paths the same way.-trimpath
flags with the same format and meaning. They should not have special handling forGOROOT
paths.GOROOT_FINAL
is set when thego
command builds a package inGOROOT
, an appropriate-trimpath
flag should be given to the compiler, assembler, and cgo.The text was updated successfully, but these errors were encountered: