Skip to content

Commit c8fca5c

Browse files
jayconrodtyler-french
authored andcommitted
builder: work around change in filepath.EvalSymlinks behavior (#4050)
**What type of PR is this?** > Bug fix **What does this PR do? Why is it needed?** filepath.EvalSymlinks works differently on Windows in Go 1.23.0: mount points and reparse points are no longer treated as symbolic links by os.Stat. Bazel uses junctions (implemented as reparse points) for inputs, so this means EvalSymlinks can fail with some kinds of inputs where it didn't before. replicateTree calls EvalSymlinks before constructing an input tree for `GoStdlib`. This seems to be necessary in some cases, though I'm not altogether sure why. EvalSymlinks fails due to the new behavior though. This change sets `GODEBUG=winsymlink=0` when invoking the builder binary to revert to the old behavior. This should not affect the behavior of user code compiled using the builder. This may not be a permanent solution, but it should work at least through Go 1.25. **Which issues(s) does this PR fix?** Fixes #4049 **Other notes for review** No test, but verified locally. Simply running `GoStdlib` with Go 1.23.0 will cover this. rules_go currently builds with Go 1.21.8 (no longer a version supported by Google!).
1 parent 6583a73 commit c8fca5c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

go/private/context.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,14 @@ def go_context(ctx, attr = None):
503503
#
504504
# See https://go.dev/doc/toolchain for more info.
505505
"GOTOOLCHAIN": "local",
506+
507+
# NOTE(#4049): Since Go 1.23.0, os.Readlink (and consequently
508+
# filepath.EvalSymlinks) stopped treating Windows mount points and
509+
# reparse points (junctions) as symbolic links. Bazel uses junctions
510+
# when constructing exec roots, and we use filepath.EvalSymlinks in
511+
# GoStdlib, so this broke us. Setting GODEBUG=winsymlink=0 restores
512+
# the old behavior.
513+
"GODEBUG": "winsymlink=0",
506514
}
507515

508516
# Path mapping can't map the values of environment variables, so we pass GOROOT to the action

0 commit comments

Comments
 (0)