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

tinygo version build-tags (duplicate go1.X build-tag functionality) #4391

Closed
archie2x opened this issue Aug 7, 2024 · 1 comment
Closed

Comments

@archie2x
Copy link
Contributor

archie2x commented Aug 7, 2024

Background

You can conditionally compile go source files based on go versions with //go:build lines

require go >= v1.22 //go:build go1.22
require go < v1.22 //go:build !go1.22

Ideally tinygo would offer all the same functionality of big-go and this mechanism would suffice.

Motivation

tinygo offers a subset of the functionality of big-go (rapidly closing gap!)

  • it can be difficult to manage downstream projects with release/dev versions of tinygo
  • work-arounds are temporary and have to be edited to track tinygo release

Example

While porting u-root, all files for all commands that fail to link with release tinygo (currently 0.32.0) have been marked with //go:build !tinygo && (...)

But, many of these commands now link with tinygo-dev branch, whose version predicts the next release in the (current) form 0.33.0-dev-SHA

Right now, support for using tinygo(-dev) with these commands is being managed by developers with branches.

One solution is to make a more complicated build line and supply the build tags directly, like: //go:build (!tinygo || tinygodev) && (...) and build with tinygo build -tags tinygodev

Problem

Once the next version of tinygo is released, above solution requires modifying source and/or flow to accommodate.

Proposal

I'm proposing tinygo mimic/offer the big-go version build-tags behavior with its own build tags so that we can track its growing support of the big-go functionality. Developers can write //go:build lines that won't have to necessarily be changed as functionality is added to tinygo.

//go:build (!tinygo || tinygo0.33) && (...)

This solution allows specifying a minimum tinygo version, does not require defining custom build-tags, and does not need to be modified once tinygo v0.33.0 is actually released assuming functionality that supported the build isn't removed.

Additional Functionality

Have a way to export the generated version build-tags so that dependent tools can use them.

Additional Thought

tinygo-dev branch should have a tinygodev build tag?

Anyway: supplying build tags, particularly version, only seems like a "win" and doesn't really have any drawback that I can think of.

@archie2x archie2x changed the title duplicate go1.X build-tag functionality for tinygo versions tinygoX.X tinygo version build-tags (duplicate go1.X build-tag functionality) Aug 7, 2024
@archie2x
Copy link
Contributor Author

archie2x commented Aug 9, 2024

Actually, as @aykevl pointed out, I don't think this make sense. The problem is probably the !tinygo build constraints themselves. We don't need more granularity on tinygo version.

@archie2x archie2x closed this as completed Aug 9, 2024
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

No branches or pull requests

1 participant