-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
doc: mention "purego" build tag convention somewhere #23172
Comments
The code history of protobuf seems to indicate that this very same concept was discussed but not pursued further. I'd like to push this more since I see this distinction in at least 2 packages I own. |
I think standardizing a build tag to indicate whether package unsafe is available makes sense.
I disagree. Currently, build tags are strictly a build-system concept. I'd argue the compiler should remain ignorant of them. cmd/compile already has a |
/cc @bradfitz who also ran into this with |
@shurcooL, I'm still fine with "safe", as long as it's defined (i.e. "code that doesn't import But does it also mean no assembly? Those are the sorts of things that should be clarified, if this is to be blessed somehow. (our own use, wiki page, etc) |
@dsnet Can you clarify if your proposal is about documenting Or is it about documenting the fact that |
Would this proposal be codified in the standard library somehow, perhaps by adding a |
In a previous life, we had to identify versions of libraries, and rapidly found out that that was too coarse a measure. We eventually attached a label via the linker to each entry point*, and could tell if, for example, a call to memcpy allowed overap or not. ' We also used it in migration work, to identify parts of programs that could not be supported on a different OS or hardware platform. You arguably should consider labelling parts of the unsafe library with supported and unsupported by target OS, language or whatever, not the whole library if only one operation is unavailable. --dave |
Would this How would this build tag interact with the standard library, where both are used a lot? Does no What is the @shurcooL it sounds like the latter at minimum, the former ideally. |
I propose that "safe" be soft signal that a library should have memory safety (i.e., makes no assumptions about how objects are laid out in memory, the architecture endianess, semantics regarding registers, etc). Thus, the "safe" tag has the following properties:
Thus, |
Based on discussion with proposal-review:
|
On WebAssembly: The wasm backend that I'm working on uses a linear memory, so |
👍 for |
I support I don't have any great suggestions for where to document this, but perhaps the godoc for |
I wanted to point out that in colloquial usage, I've seen "pure Go" most commonly refer to packages that don't use cgo (but can use The |
OK, |
This is the convention that the Go ecosystem is standardizing on. See golang/go#23172.
The proposal in golang/go#23172 was accepted. The "purego" build tag is intended to be a community agreed upon soft-signal to indicate the forbidden use of unsafe, assembly, or cgo. Since GopherJS doesn't support those, it should always use "purego" versions of Go packages when they're available. This is done by always setting the "purego" build constraint. Fixes #746.
The proposal in golang/go#23172 was accepted. The "purego" build tag is intended to be a community agreed upon soft-signal to indicate the forbidden use of unsafe, assembly, or cgo. A change in the future will remove special-casing the appengine and js tags once the related toolchains support purego (possibly after some bake-in period).
Change https://go.dev/cl/561935 mentions this issue: |
Fixes #58636 Updates #23172 Change-Id: I578a5597f467be45a7d6fb7582b24855b2e6512b Reviewed-on: https://go-review.googlesource.com/c/go/+/561935 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Filippo Valsorda <filippo@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
I'm working on TinyGo, and combining these three concepts together seems like a bad idea to me (no assembly, no cgo, and no unsafe).
Furthermore, there is already a perfectly good tag for CGo support: the Right now we set the |
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. [1]: golang/go#23172
The `purego` build tag has been proposed[1] as the de-facto tag for pure Go builds. This is a superset of the `noasm` tag currently used. This patch aligns the code base to toggle to pure Go implementation when `purego` is defined. Verified that all assembly is excluded by doing: find . -name '*.s' -exec sed -i -e '$athis-is-not-valid-assembly 12345' {} \; go test --tags purego ./... [1]: golang/go#23172
The `purego` build tag has been proposed[1] as the de-facto tag for pure Go builds. This is a superset of the `noasm` tag currently used. This patch aligns the code base to toggle to pure Go implementation when `purego` is defined. Verified that all assembly is excluded by doing: find . -name '*.s' -exec sed -i -e '$athis-is-not-valid-assembly 12345' {} \; go test --tags purego ./... [1]: golang/go#23172
`purego` is a proposed[1] de-facto build constraint to denote building _only_ Go code. We must ignore this constraint to make sure that files that toggle on `purego` are added to the Bazel target `srcs` and let the compiler decide if they should be compiled or not. [1]: golang/go#23172
`purego` is a proposed[1] de-facto build constraint to denote building _only_ Go code. We must ignore this constraint to make sure that files that toggle on `purego` are added to the Bazel target `srcs` and let the compiler decide if they should be compiled or not. [1]: golang/go#23172
`purego` is a proposed[1] de-facto build constraint to denote building _only_ Go code. We must ignore this constraint to make sure that files that toggle on `purego` are added to the Bazel target `srcs` and let the compiler decide if they should be compiled or not. [1]: golang/go#23172
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The `purego` build tag has been proposed[1] as the de-facto tag for pure Go builds. This is a superset of the `noasm` tag currently used. This patch aligns the code base to toggle to pure Go implementation when `purego` is defined. Verified that all assembly is excluded by doing: find . -name '*.s' -exec sed -i -e '$athis-is-not-valid-assembly 12345' {} \; go test --tags purego ./... [1]: golang/go#23172
The `purego` build tag has been proposed[1] as the de-facto tag for pure Go builds. This is a superset of the `noasm` tag currently used. This patch aligns the code base to toggle to pure Go implementation when `purego` is defined. Verified that all assembly is excluded by doing: find . -name '*.s' -exec sed -i -e '$athis-is-not-valid-assembly 12345' {} \; go test --tags purego ./... [1]: golang/go#23172
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
The community has agreed[1] that "pure" builds of Go code should use the `purego` build tag. This change adds that de-facto tag. The minimum version of Gazelle is bumped to `0.36.0` which includes a patch[2] for ignoring the `purego` tag so that the source flies are passed to the compiler for conditional compilation decisions. [1]: golang/go#23172 [2]: bazel-contrib/bazel-gazelle#1767
As the number of Go implementations continues to increase, the number of cases where the
unsafe
package is unlikely to work properly also rises. Currently, there isappengine
,gopherjs
, and possiblywasm
where pointer arithmetic is not allowed.Currently, protobuf and other packages special cases build tags for
appengine
andjs
and may need to add others in the near future. It does not scale very well to blacklist specific known Go implementations where unsafe does not work.My proposal is to document
safe
as a community agreed upon tag meaning thatunsafe
should not be used. It is conceivable that this concept be extended to the compiler rejecting programs that useunsafe
when thesafe
tag is set, but I'm currently more interested as a library owner in knowing whether to avoidunsafe
in my own packages.\cc @zombiezen @dneil @neelance @shurcooL
The text was updated successfully, but these errors were encountered: