Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go/internal/load: (Optionally) follow symlinks referenced by //go:embed #59924

Open
fmeum opened this issue May 2, 2023 · 3 comments
Open
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@fmeum
Copy link

fmeum commented May 2, 2023

What version of Go are you using (go version)?

$ go version
go version go1.20.3 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

N/A, applies to any GOOS/GOARCH

What did you do?

In a Bazel build action running in a symlink-based sandbox, try to build the Go standard library or any third-party package using //go:embed.

What did you expect to see?

The build passes just as it would if the input files weren't symlinks. Tools only play nice with Bazel if they follow symlinks, as whether or not an input file to a Bazel build action is a symlink depends on the particular strategy with which Bazel chooses to execute the action (e.g. remotely or locally, in a sandbox or not, ...).

//go:embed not allowing symlinks to be embedded makes sense and I am not asking for that to be changed. However, it would be very helpful if it could be made to follow symlinks, either by default or optionally, guarded by a flag or environment variable.

What did you see instead?

external/go_sdk/src/crypto/elliptic/p256_asm.go:24:12: pattern p256_asm_table.bin: cannot embed irregular file p256_asm_table.bin

This happens because of the use of Lstat in

info, err := fsys.Lstat(file)
, which makes symlinks hit the branch at
return nil, nil, fmt.Errorf("cannot embed irregular file %s", rel)

This issue requires rules_go to copy around the stdlib and breaks build actions that operate on generated code.

@fmeum
Copy link
Author

fmeum commented May 2, 2023

CC @thanm

@thanm thanm added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels May 2, 2023
@thanm
Copy link
Contributor

thanm commented May 2, 2023

@golang/tools-team

@bcmills bcmills added this to the Backlog milestone May 2, 2023
@fmeum
Copy link
Author

fmeum commented Jul 31, 2023

@thanm This continues to be a problem. If there is anything I can do, such as submit a PR to modify this behavior based on an environment variable, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants