Skip to content

Conversation

@dvyukov
Copy link
Collaborator

@dvyukov dvyukov commented Apr 3, 2025

Currently the commands we have in go:generate first create an empty file
and then write final contents. This breaks any parallel builds of the source.
Even running go generate ./... does not work.
Write output files atomically.

Currently the commands we have in go:generate first create an empty file
and then write final contents. This breaks any parallel builds of the source.
Even running go generate ./... does not work.
Write output files atomically.
@dvyukov dvyukov enabled auto-merge April 3, 2025 12:37
Copy link
Collaborator

@tarasmadan tarasmadan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious about "(go run gen/gen.go gen/json/arm64.json | gofmt > generated/insns.tmp); mv generated/insns.tmp generated/insns.go"...

@dvyukov dvyukov added this pull request to the merge queue Apr 3, 2025
@dvyukov
Copy link
Collaborator Author

dvyukov commented Apr 3, 2025

Just curious about "(go run gen/gen.go gen/json/arm64.json | gofmt > generated/insns.tmp); mv generated/insns.tmp generated/insns.go"...

This would work, but I hate duplicating non-trivial shell (we would need it in at least 3 places, probably more). Also some tools already write files in the tool, so we would need to move that code out of these tools to use bash for atomic writing.

Re hating bash: can you spot a bug in your snippet? ;)

Merged via the queue into google:master with commit d7ae3a1 Apr 3, 2025
17 checks passed
@tarasmadan
Copy link
Collaborator

Just curious about "(go run gen/gen.go gen/json/arm64.json | gofmt > generated/insns.tmp); mv generated/insns.tmp generated/insns.go"...

This would work, but I hate duplicating non-trivial shell (we would need it in at least 3 places, probably more). Also some tools already write files in the tool, so we would need to move that code out of these tools to use bash for atomic writing.

Re hating bash: can you spot a bug in your snippet? ;)

You made me curious... Where? How many?

@dvyukov
Copy link
Collaborator Author

dvyukov commented Apr 3, 2025

I think it should be && instead of ;.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants