From 1830c7f8cf4ecda72594a1c2ea943bd2a00cd703 Mon Sep 17 00:00:00 2001 From: sivchari Date: Mon, 3 Nov 2025 20:54:10 +0900 Subject: [PATCH 1/3] add go-compatibility feature Signed-off-by: sivchari --- builder/config.go | 11 +++++++---- compileopts/options.go | 1 + main.go | 12 ++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/builder/config.go b/builder/config.go index 5fb74ee192..bef366f8c8 100644 --- a/builder/config.go +++ b/builder/config.go @@ -33,10 +33,13 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) { if err != nil { return nil, err } - if gorootMajor != 1 || gorootMinor < minorMin || gorootMinor > minorMax { - // Note: when this gets updated, also update the Go compatibility matrix: - // https://github.com/tinygo-org/tinygo-site/blob/dev/content/docs/reference/go-compat-matrix.md - return nil, fmt.Errorf("requires go version 1.%d through 1.%d, got go%d.%d", minorMin, minorMax, gorootMajor, gorootMinor) + + if options.GoCompatibility { + if gorootMajor != 1 || gorootMinor < minorMin || gorootMinor > minorMax { + // Note: when this gets updated, also update the Go compatibility matrix: + // https://github.com/tinygo-org/tinygo-site/blob/dev/content/docs/reference/go-compat-matrix.md + return nil, fmt.Errorf("requires go version 1.%d through 1.%d, got go%d.%d", minorMin, minorMax, gorootMajor, gorootMinor) + } } // Check that the Go toolchain version isn't too new, if we haven't been diff --git a/compileopts/options.go b/compileopts/options.go index 517664db2c..e543dca459 100644 --- a/compileopts/options.go +++ b/compileopts/options.go @@ -59,6 +59,7 @@ type Options struct { WITPackage string // pass through to wasm-tools component embed invocation WITWorld string // pass through to wasm-tools component embed -w option ExtLDFlags []string + GoCompatibility bool // enable to check for Go version compatibility } // Verify performs a validation on the given options, raising an error if options are not valid. diff --git a/main.go b/main.go index 71d48a3e95..5636f1816d 100644 --- a/main.go +++ b/main.go @@ -1635,6 +1635,7 @@ func main() { cpuprofile := flag.String("cpuprofile", "", "cpuprofile output") monitor := flag.Bool("monitor", false, "enable serial monitor") baudrate := flag.Int("baudrate", 115200, "baudrate of serial monitor") + gocompatibility := flag.Bool("go-compatibility", true, "enable to check for Go versions compatibility, you can also configure this by setting the TINYGOGOCOMPATIBILITY environment variable") // Internal flags, that are only intended for TinyGo development. printIR := flag.Bool("internal-printir", false, "print LLVM IR") @@ -1712,6 +1713,16 @@ func main() { ocdCommands = strings.Split(*ocdCommandsString, ",") } + val, ok := os.LookupEnv("TINYGOGOCOMPATIBILITY") + if ok { + b, err := strconv.ParseBool(val) + if err != nil { + fmt.Fprintf(os.Stderr, "could not parse TINYGOGOCOMPATIBILITY value %q: %v\n", val, err) + os.Exit(1) + } + *gocompatibility = b + } + options := &compileopts.Options{ GOOS: goenv.Get("GOOS"), GOARCH: goenv.Get("GOARCH"), @@ -1748,6 +1759,7 @@ func main() { Timeout: *timeout, WITPackage: witPackage, WITWorld: witWorld, + GoCompatibility: *gocompatibility, } if *printCommands { options.PrintCommands = printCommand From 93aa391abf838a33ac1d363487bf5392abd84584 Mon Sep 17 00:00:00 2001 From: sivchari Date: Wed, 5 Nov 2025 18:22:28 +0900 Subject: [PATCH 2/3] rename env Signed-off-by: sivchari --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 5636f1816d..53221da681 100644 --- a/main.go +++ b/main.go @@ -1713,11 +1713,11 @@ func main() { ocdCommands = strings.Split(*ocdCommandsString, ",") } - val, ok := os.LookupEnv("TINYGOGOCOMPATIBILITY") + val, ok := os.LookupEnv("TINYGO_GOCOMPATIBILITY") if ok { b, err := strconv.ParseBool(val) if err != nil { - fmt.Fprintf(os.Stderr, "could not parse TINYGOGOCOMPATIBILITY value %q: %v\n", val, err) + fmt.Fprintf(os.Stderr, "could not parse TINYGO_GOCOMPATIBILITY value %q: %v\n", val, err) os.Exit(1) } *gocompatibility = b From 3b6c4000c2486433ca21823f3f6935dc3075404b Mon Sep 17 00:00:00 2001 From: sivchari Date: Thu, 6 Nov 2025 17:31:02 +0900 Subject: [PATCH 3/3] fix description Signed-off-by: sivchari --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 53221da681..e2736fd17b 100644 --- a/main.go +++ b/main.go @@ -1635,7 +1635,7 @@ func main() { cpuprofile := flag.String("cpuprofile", "", "cpuprofile output") monitor := flag.Bool("monitor", false, "enable serial monitor") baudrate := flag.Int("baudrate", 115200, "baudrate of serial monitor") - gocompatibility := flag.Bool("go-compatibility", true, "enable to check for Go versions compatibility, you can also configure this by setting the TINYGOGOCOMPATIBILITY environment variable") + gocompatibility := flag.Bool("go-compatibility", true, "enable to check for Go versions compatibility, you can also configure this by setting the TINYGO_GOCOMPATIBILITY environment variable") // Internal flags, that are only intended for TinyGo development. printIR := flag.Bool("internal-printir", false, "print LLVM IR")