diff --git a/0001-Skip-WASI-tests.patch b/0001-Skip-WASI-tests.patch index 1f648df..bd9c522 100644 --- a/0001-Skip-WASI-tests.patch +++ b/0001-Skip-WASI-tests.patch @@ -1,7 +1,7 @@ From 6b50974a6d4972b755a35d40d87e5bdf9c97d925 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Tue, 15 Dec 2020 05:06:04 -0500 -Subject: [PATCH 01/18] Skip WASI tests. +Subject: [PATCH 01/26] Skip WASI tests. We do not have wasmtime available. @@ -34,5 +34,5 @@ index 9ddbe52f..79ae2cf2 100644 } for _, targ := range targs { -- -2.36.1 +2.38.1 diff --git a/0002-Use-system-mingw64-headers-and-crt.patch b/0002-Use-system-mingw64-headers-and-crt.patch index 821f09a..012aa83 100644 --- a/0002-Use-system-mingw64-headers-and-crt.patch +++ b/0002-Use-system-mingw64-headers-and-crt.patch @@ -1,7 +1,7 @@ From 76c575659d42187b0c4c15d4f5978c4368800da7 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 2 Jan 2022 05:47:18 -0500 -Subject: [PATCH 02/18] Use system mingw64 headers and crt +Subject: [PATCH 02/26] Use system mingw64 headers and crt Signed-off-by: Elliott Sales de Andrade --- @@ -118,5 +118,5 @@ index ebfc5082..cd49283d 100644 ) case "": -- -2.36.1 +2.38.1 diff --git a/0003-Skip-some-cross-Linux-tests-where-qemu-is-broken.patch b/0003-Skip-some-cross-Linux-tests-where-qemu-is-broken.patch index 87d5c28..5209323 100644 --- a/0003-Skip-some-cross-Linux-tests-where-qemu-is-broken.patch +++ b/0003-Skip-some-cross-Linux-tests-where-qemu-is-broken.patch @@ -1,7 +1,7 @@ From 2a2e35e4565e8ea7f7ac2d34cb9da24000bb6474 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 3 Jan 2022 22:39:31 -0500 -Subject: [PATCH 03/18] Skip some cross Linux tests where qemu is broken +Subject: [PATCH 03/26] Skip some cross Linux tests where qemu is broken The upstream issues will hopefully be fixed soon: @@ -60,5 +60,5 @@ index 79ae2cf2..9359ef0c 100644 actual := bytes.Replace(stdout.Bytes(), []byte{'\r', '\n'}, []byte{'\n'}, -1) expected = bytes.Replace(expected, []byte{'\r', '\n'}, []byte{'\n'}, -1) // for Windows -- -2.36.1 +2.38.1 diff --git a/0004-Suggest-optional-packages-to-install-if-missing.patch b/0004-Suggest-optional-packages-to-install-if-missing.patch index b7f2c2c..ab97660 100644 --- a/0004-Suggest-optional-packages-to-install-if-missing.patch +++ b/0004-Suggest-optional-packages-to-install-if-missing.patch @@ -1,7 +1,7 @@ From 3f935d679870de924aa65d78c23ecdcb483ab4a3 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 6 Feb 2022 03:49:16 -0500 -Subject: [PATCH 04/18] Suggest optional packages to install if missing +Subject: [PATCH 04/26] Suggest optional packages to install if missing Signed-off-by: Elliott Sales de Andrade --- @@ -74,5 +74,5 @@ index 53d89bf0..e55719b2 100644 + return err } -- -2.36.1 +2.38.1 diff --git a/0005-Skip-TestDirFS-on-32-bit-systems.patch b/0005-Skip-TestDirFS-on-32-bit-systems.patch index 9101800..dc9acd5 100644 --- a/0005-Skip-TestDirFS-on-32-bit-systems.patch +++ b/0005-Skip-TestDirFS-on-32-bit-systems.patch @@ -1,7 +1,7 @@ From 41cbdf1cfe50f24b49beb615f0924ea3255c7e7d Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 8 May 2022 04:18:05 -0400 -Subject: [PATCH 05/18] Skip TestDirFS on 32-bit systems +Subject: [PATCH 05/26] Skip TestDirFS on 32-bit systems Because Seek is not fully implemented there. @@ -26,5 +26,5 @@ index dd255fb4..5dc0d860 100644 t.Log("TODO: allow foo/bar/. as synonym for path foo/bar on wasi?") return -- -2.36.1 +2.38.1 diff --git a/0006-Skip-broken-tests-on-i686.patch b/0006-Skip-broken-tests-on-i686.patch index 98e0acf..1c241b5 100644 --- a/0006-Skip-broken-tests-on-i686.patch +++ b/0006-Skip-broken-tests-on-i686.patch @@ -1,7 +1,7 @@ From a44f31de099aaf6768af2102919f1a8c221ce6f4 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 8 May 2022 18:39:26 -0400 -Subject: [PATCH 06/18] Skip broken tests on i686 +Subject: [PATCH 06/26] Skip broken tests on i686 * compress/flate runs out of memory * testing/fstest uses Seek, which is not implemented there @@ -40,5 +40,5 @@ index 99f67c29..1ef11d29 100644 TEST_PACKAGES_DARWIN := $(TEST_PACKAGES_LINUX) -- -2.36.1 +2.38.1 diff --git a/0007-wasm-fix-GC-scanning-of-allocas.patch b/0007-wasm-fix-GC-scanning-of-allocas.patch index 02da873..5397b13 100644 --- a/0007-wasm-fix-GC-scanning-of-allocas.patch +++ b/0007-wasm-fix-GC-scanning-of-allocas.patch @@ -1,7 +1,7 @@ From e8f07384a0f5a61351a62931d3fb69bf6c451c1b Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 16 Oct 2022 00:44:38 +0200 -Subject: [PATCH 07/18] wasm: fix GC scanning of allocas +Subject: [PATCH 07/26] wasm: fix GC scanning of allocas Scanning of allocas was entirely broken on WebAssembly. The code intended to do this was never run. There were also no tests. @@ -261,5 +261,5 @@ index 90b7a7c7..32ee9560 100644 + return value } -- -2.36.1 +2.38.1 diff --git a/0008-compiler-return-a-FunctionType-not-a-PointerType-in-.patch b/0008-compiler-return-a-FunctionType-not-a-PointerType-in-.patch index 77d6ea3..9045c40 100644 --- a/0008-compiler-return-a-FunctionType-not-a-PointerType-in-.patch +++ b/0008-compiler-return-a-FunctionType-not-a-PointerType-in-.patch @@ -1,7 +1,7 @@ From 9e64a63d49100e550fad97b390bb01489ed6ca44 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Tue, 20 Sep 2022 23:59:22 +0200 -Subject: [PATCH 08/18] compiler: return a FunctionType (not a PointerType) in +Subject: [PATCH 08/26] compiler: return a FunctionType (not a PointerType) in getRawFuncType This is necessary for opaque pointer support (in LLVM 15). @@ -48,5 +48,5 @@ index c59a9ade..b0ea71e3 100644 c.addStandardDeclaredAttributes(llvmFn) llvmFn.AddFunctionAttr(c.ctx.CreateStringAttribute("tinygo-invoke", c.getMethodSignatureName(instr.Method))) -- -2.36.1 +2.38.1 diff --git a/0009-all-add-type-parameter-to-CreateCall.patch b/0009-all-add-type-parameter-to-CreateCall.patch index ca16ea3..acfce69 100644 --- a/0009-all-add-type-parameter-to-CreateCall.patch +++ b/0009-all-add-type-parameter-to-CreateCall.patch @@ -1,7 +1,7 @@ From 8138d69793c00829df45501c35975055ad52d151 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 21 Sep 2022 00:37:01 +0200 -Subject: [PATCH 09/18] all: add type parameter to CreateCall +Subject: [PATCH 09/26] all: add type parameter to CreateCall This uses LLVMBuildCall2 in the background, which is the replacement for the deprecated LLVMBuildCall function. @@ -989,5 +989,5 @@ index aeba713d..aedad71d 100644 builder.CreateRetVoid() } else { -- -2.36.1 +2.38.1 diff --git a/0010-all-add-type-parameter-to-CreateLoad.patch b/0010-all-add-type-parameter-to-CreateLoad.patch index 2cbfe1b..8f4d9f4 100644 --- a/0010-all-add-type-parameter-to-CreateLoad.patch +++ b/0010-all-add-type-parameter-to-CreateLoad.patch @@ -1,7 +1,7 @@ From 65a18179d8ff911ba43a3a28ffb2f36c262cff5e Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 21 Sep 2022 13:55:32 +0200 -Subject: [PATCH 10/18] all: add type parameter to CreateLoad +Subject: [PATCH 10/26] all: add type parameter to CreateLoad This is needed for LLVM 15. @@ -373,5 +373,5 @@ index aedad71d..064e38f4 100644 callParams = append(callParams, paramValue) } -- -2.36.1 +2.38.1 diff --git a/0011-all-add-type-parameter-to-GEP-calls.patch b/0011-all-add-type-parameter-to-GEP-calls.patch index 866f9fb..120c469 100644 --- a/0011-all-add-type-parameter-to-GEP-calls.patch +++ b/0011-all-add-type-parameter-to-GEP-calls.patch @@ -1,7 +1,7 @@ From dd4f1c594ef0fadb59fa418f1049542f86237800 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 21 Sep 2022 17:00:09 +0200 -Subject: [PATCH 11/18] all: add type parameter to *GEP calls +Subject: [PATCH 11/26] all: add type parameter to *GEP calls This is necessary for LLVM 15. @@ -561,5 +561,5 @@ index f1a3c93d..169f1454 100644 llvm.ConstInt(ctx.Int32Type(), uint64(i), false), }) -- -2.36.1 +2.38.1 diff --git a/0012-all-replace-llvm.Const-calls-with-builder.Create-cal.patch b/0012-all-replace-llvm.Const-calls-with-builder.Create-cal.patch index a730ef6..d63dd8c 100644 --- a/0012-all-replace-llvm.Const-calls-with-builder.Create-cal.patch +++ b/0012-all-replace-llvm.Const-calls-with-builder.Create-cal.patch @@ -1,7 +1,7 @@ From 6053c1c8528c63a669d070550bacd43f2f6a68e1 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Tue, 20 Sep 2022 23:26:49 +0200 -Subject: [PATCH 12/18] all: replace llvm.Const* calls with builder.Create* +Subject: [PATCH 12/26] all: replace llvm.Const* calls with builder.Create* calls A number of llvm.Const* functions (in particular extractvalue and @@ -574,5 +574,5 @@ index 2f17f815..d70bc626 100644 // Replace Implements call with the type assert call. builder.SetInsertPointBefore(call) -- -2.36.1 +2.38.1 diff --git a/0013-interp-change-object.llvmType-to-the-initializer-typ.patch b/0013-interp-change-object.llvmType-to-the-initializer-typ.patch index 4ef130d..6cbd134 100644 --- a/0013-interp-change-object.llvmType-to-the-initializer-typ.patch +++ b/0013-interp-change-object.llvmType-to-the-initializer-typ.patch @@ -1,7 +1,7 @@ From 1004deaafd70d4eb94196977c20a5b1a17cded81 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 22 Sep 2022 01:06:40 +0200 -Subject: [PATCH 13/18] interp: change object.llvmType to the initializer type +Subject: [PATCH 13/26] interp: change object.llvmType to the initializer type Previously it was a pointer type, which won't work with opaque pointers. Instead, use the global initializer type instead. @@ -75,5 +75,5 @@ index 583f9355..6a537bad 100644 // The exact type isn't known, but the object layout is known. globalType = obj.llvmLayoutType -- -2.36.1 +2.38.1 diff --git a/0014-all-remove-pointer-ElementType-calls.patch b/0014-all-remove-pointer-ElementType-calls.patch index 36f0818..146b0ab 100644 --- a/0014-all-remove-pointer-ElementType-calls.patch +++ b/0014-all-remove-pointer-ElementType-calls.patch @@ -1,7 +1,7 @@ From 0cdaa0f6db40e372db24d945b557d03b97ff92e9 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 22 Sep 2022 13:33:00 +0200 -Subject: [PATCH 14/18] all: remove pointer ElementType calls +Subject: [PATCH 14/26] all: remove pointer ElementType calls This is needed for opaque pointers, which are enabled by default in LLVM 15. @@ -582,5 +582,5 @@ index 064e38f4..83a16d85 100644 if returnType == int64Type { hasInt64 = true -- -2.36.1 +2.38.1 diff --git a/0015-transform-fix-memory-corruption-issues.patch b/0015-transform-fix-memory-corruption-issues.patch index d209b69..10ea146 100644 --- a/0015-transform-fix-memory-corruption-issues.patch +++ b/0015-transform-fix-memory-corruption-issues.patch @@ -1,7 +1,7 @@ From 6bf7aa1623b6d7d9a269df876453af22b1c54c2d Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 12 Oct 2022 21:46:50 +0200 -Subject: [PATCH 15/18] transform: fix memory corruption issues +Subject: [PATCH 15/26] transform: fix memory corruption issues There was a bug in the wasm ABI lowering pass (found using AddressSanitizer on LLVM 15) that resulted in a rather subtle memory @@ -27,5 +27,5 @@ index 83a16d85..08122a3e 100644 builder.SetInsertPointBefore(call) callParams := []llvm.Value{} -- -2.36.1 +2.38.1 diff --git a/0016-riscv-add-target-abi-metadata-flag.patch b/0016-riscv-add-target-abi-metadata-flag.patch index e194223..abc5083 100644 --- a/0016-riscv-add-target-abi-metadata-flag.patch +++ b/0016-riscv-add-target-abi-metadata-flag.patch @@ -1,7 +1,7 @@ From 003963ddc796960ce498361409a9d121366b1c42 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 12 Oct 2022 22:05:38 +0000 -Subject: [PATCH 16/18] riscv: add "target-abi" metadata flag +Subject: [PATCH 16/26] riscv: add "target-abi" metadata flag This flag is necessary in LLVM 15 because it appears that LLVM 15 has changed the default target ABI from lp64 to lp64d. This results in a @@ -189,5 +189,5 @@ index c2378e97..fc45c91c 100644 "ldflags": [ "-melf64lriscv" -- -2.36.1 +2.38.1 diff --git a/0017-interp-add-support-for-constant-icmp-instructions.patch b/0017-interp-add-support-for-constant-icmp-instructions.patch index 500803c..d3d7158 100644 --- a/0017-interp-add-support-for-constant-icmp-instructions.patch +++ b/0017-interp-add-support-for-constant-icmp-instructions.patch @@ -1,7 +1,7 @@ From 76f42a3fac44ac6d07c53b10ddadb683ca019684 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Tue, 18 Oct 2022 23:16:36 +0000 -Subject: [PATCH 17/18] interp: add support for constant icmp instructions +Subject: [PATCH 17/26] interp: add support for constant icmp instructions These instructions sometimes pop up in LLVM 15, but they never occured in LLVM 14. Implementing them is relatively straightforward: simply @@ -191,5 +191,5 @@ index 5fac449e..08d74c85 100644 @someArrayPointer = local_unnamed_addr global i8* getelementptr inbounds ({ i16, i8, i8 }, { i16, i8, i8 }* @someArray, i64 0, i32 1) -- -2.36.1 +2.38.1 diff --git a/0018-ci-add-support-for-LLVM-15.patch b/0018-ci-add-support-for-LLVM-15.patch index 7c17787..a947661 100644 --- a/0018-ci-add-support-for-LLVM-15.patch +++ b/0018-ci-add-support-for-LLVM-15.patch @@ -1,7 +1,7 @@ From 6557b534a1c2195cb7f2a465f8dc36662525f764 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 22 Sep 2022 13:39:51 +0200 -Subject: [PATCH 18/18] ci: add support for LLVM 15 +Subject: [PATCH 18/26] ci: add support for LLVM 15 This commit switches to LLVM 15 everywhere by default, while still keeping LLVM 14 support. @@ -3486,5 +3486,5 @@ index d70bc626..209e15ae 100644 // Get the underlying type. interfaceType = builder.CreateExtractValue(interfaceType.Initializer(), 0, "") -- -2.36.1 +2.38.1 diff --git a/0019-src-runtime-add-xorshift-based-fastrand64.patch b/0019-src-runtime-add-xorshift-based-fastrand64.patch new file mode 100644 index 0000000..9323d7a --- /dev/null +++ b/0019-src-runtime-add-xorshift-based-fastrand64.patch @@ -0,0 +1,40 @@ +From 8686fd42351642868970dacc76519fe6ac3f8fac Mon Sep 17 00:00:00 2001 +From: Damian Gryski +Date: Fri, 6 Jan 2023 20:24:34 -0800 +Subject: [PATCH 19/26] src/runtime: add xorshift-based fastrand64 + +Signed-off-by: Elliott Sales de Andrade +--- + src/runtime/algorithm.go | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + +diff --git a/src/runtime/algorithm.go b/src/runtime/algorithm.go +index 15487176..35e2e260 100644 +--- a/src/runtime/algorithm.go ++++ b/src/runtime/algorithm.go +@@ -25,6 +25,22 @@ func xorshift32(x uint32) uint32 { + return x + } + ++// This function is used by hash/maphash. ++func fastrand64() uint64 { ++ xorshift64State = xorshiftMult64(xorshift64State) ++ return xorshift64State ++} ++ ++var xorshift64State uint64 = 1 ++ ++// 64-bit xorshift multiply rng from http://vigna.di.unimi.it/ftp/papers/xorshift.pdf ++func xorshiftMult64(x uint64) uint64 { ++ x ^= x >> 12 // a ++ x ^= x << 25 // b ++ x ^= x >> 27 // c ++ return x * 2685821657736338717 ++} ++ + // This function is used by hash/maphash. + func memhash(p unsafe.Pointer, seed, s uintptr) uintptr { + if unsafe.Sizeof(uintptr(0)) > 4 { +-- +2.38.1 + diff --git a/0020-testing-implement-t.Setenv.patch b/0020-testing-implement-t.Setenv.patch new file mode 100644 index 0000000..0627c88 --- /dev/null +++ b/0020-testing-implement-t.Setenv.patch @@ -0,0 +1,129 @@ +From 42d8bf6be8c01504667e858a1b13079956ab53cd Mon Sep 17 00:00:00 2001 +From: Ayke van Laethem +Date: Sat, 14 Jan 2023 19:32:36 +0100 +Subject: [PATCH 20/26] testing: implement t.Setenv + +This method has been added in Go 1.17 and is used in archive/zip +starting with Go 1.20. Therefore, this method is now needed in Go 1.20. + +I've left out the parts that disable parallel execution of tests, +because we don't do that in TinyGo. + +See: +* https://github.com/golang/go/issues/41260 +* https://go-review.googlesource.com/c/go/+/260577 + +Signed-off-by: Elliott Sales de Andrade +--- + src/testing/testing.go | 22 ++++++++++++++ + src/testing/testing_test.go | 57 +++++++++++++++++++++++++++++++++++++ + 2 files changed, 79 insertions(+) + +diff --git a/src/testing/testing.go b/src/testing/testing.go +index a458f267..d5af277e 100644 +--- a/src/testing/testing.go ++++ b/src/testing/testing.go +@@ -117,6 +117,7 @@ type TB interface { + Log(args ...interface{}) + Logf(format string, args ...interface{}) + Name() string ++ Setenv(key, value string) + Skip(args ...interface{}) + SkipNow() + Skipf(format string, args ...interface{}) +@@ -330,6 +331,27 @@ func (c *common) TempDir() string { + return dir + } + ++// Setenv calls os.Setenv(key, value) and uses Cleanup to ++// restore the environment variable to its original value ++// after the test. ++func (c *common) Setenv(key, value string) { ++ prevValue, ok := os.LookupEnv(key) ++ ++ if err := os.Setenv(key, value); err != nil { ++ c.Fatalf("cannot set environment variable: %v", err) ++ } ++ ++ if ok { ++ c.Cleanup(func() { ++ os.Setenv(key, prevValue) ++ }) ++ } else { ++ c.Cleanup(func() { ++ os.Unsetenv(key) ++ }) ++ } ++} ++ + // runCleanup is called at the end of the test. + func (c *common) runCleanup() { + for { +diff --git a/src/testing/testing_test.go b/src/testing/testing_test.go +index 3ab32426..6a8607b2 100644 +--- a/src/testing/testing_test.go ++++ b/src/testing/testing_test.go +@@ -139,3 +139,60 @@ func testTempDir(t *testing.T) { + t.Errorf("unexpected files in TempDir") + } + } ++ ++func TestSetenv(t *testing.T) { ++ tests := []struct { ++ name string ++ key string ++ initialValueExists bool ++ initialValue string ++ newValue string ++ }{ ++ { ++ name: "initial value exists", ++ key: "GO_TEST_KEY_1", ++ initialValueExists: true, ++ initialValue: "111", ++ newValue: "222", ++ }, ++ { ++ name: "initial value exists but empty", ++ key: "GO_TEST_KEY_2", ++ initialValueExists: true, ++ initialValue: "", ++ newValue: "222", ++ }, ++ { ++ name: "initial value is not exists", ++ key: "GO_TEST_KEY_3", ++ initialValueExists: false, ++ initialValue: "", ++ newValue: "222", ++ }, ++ } ++ ++ for _, test := range tests { ++ if test.initialValueExists { ++ if err := os.Setenv(test.key, test.initialValue); err != nil { ++ t.Fatalf("unable to set env: got %v", err) ++ } ++ } else { ++ os.Unsetenv(test.key) ++ } ++ ++ t.Run(test.name, func(t *testing.T) { ++ t.Setenv(test.key, test.newValue) ++ if os.Getenv(test.key) != test.newValue { ++ t.Fatalf("unexpected value after t.Setenv: got %s, want %s", os.Getenv(test.key), test.newValue) ++ } ++ }) ++ ++ got, exists := os.LookupEnv(test.key) ++ if got != test.initialValue { ++ t.Fatalf("unexpected value after t.Setenv cleanup: got %s, want %s", got, test.initialValue) ++ } ++ if exists != test.initialValueExists { ++ t.Fatalf("unexpected value after t.Setenv cleanup: got %t, want %t", exists, test.initialValueExists) ++ } ++ } ++} +-- +2.38.1 + diff --git a/0021-compiler-add-support-for-new-unsafe-slice-string-fun.patch b/0021-compiler-add-support-for-new-unsafe-slice-string-fun.patch new file mode 100644 index 0000000..d349bc6 --- /dev/null +++ b/0021-compiler-add-support-for-new-unsafe-slice-string-fun.patch @@ -0,0 +1,255 @@ +From adf2a54b66083cbe88ee8bbb695d136f2e90fb58 Mon Sep 17 00:00:00 2001 +From: Ayke van Laethem +Date: Fri, 13 Jan 2023 17:52:18 +0000 +Subject: [PATCH 21/26] compiler: add support for new unsafe slice/string + functions + +This adds support for unsafe.SliceData, unsafe.String, and +unsafe.SringData that were introduced in Go 1.20. + +Signed-off-by: Elliott Sales de Andrade +--- + compiler/asserts.go | 11 +++---- + compiler/compiler.go | 40 ++++++++++++++++--------- + compiler/compiler_test.go | 10 +++++++ + compiler/testdata/go1.20.go | 15 ++++++++++ + compiler/testdata/go1.20.ll | 58 +++++++++++++++++++++++++++++++++++++ + src/runtime/panic.go | 7 +++-- + 6 files changed, 120 insertions(+), 21 deletions(-) + create mode 100644 compiler/testdata/go1.20.go + create mode 100644 compiler/testdata/go1.20.ll + +diff --git a/compiler/asserts.go b/compiler/asserts.go +index ba482494..0fb112e0 100644 +--- a/compiler/asserts.go ++++ b/compiler/asserts.go +@@ -89,10 +89,11 @@ func (b *builder) createSliceToArrayPointerCheck(sliceLen llvm.Value, arrayLen i + b.createRuntimeAssert(isLess, "slicetoarray", "sliceToArrayPointerPanic") + } + +-// createUnsafeSliceCheck inserts a runtime check used for unsafe.Slice. This +-// function must panic if the ptr/len parameters are invalid. +-func (b *builder) createUnsafeSliceCheck(ptr, len llvm.Value, elementType llvm.Type, lenType *types.Basic) { +- // From the documentation of unsafe.Slice: ++// createUnsafeSliceStringCheck inserts a runtime check used for unsafe.Slice ++// and unsafe.String. This function must panic if the ptr/len parameters are ++// invalid. ++func (b *builder) createUnsafeSliceStringCheck(name string, ptr, len llvm.Value, elementType llvm.Type, lenType *types.Basic) { ++ // From the documentation of unsafe.Slice and unsafe.String: + // > At run time, if len is negative, or if ptr is nil and len is not + // > zero, a run-time panic occurs. + // However, in practice, it is also necessary to check that the length is +@@ -117,7 +118,7 @@ func (b *builder) createUnsafeSliceCheck(ptr, len llvm.Value, elementType llvm.T + lenIsNotZero := b.CreateICmp(llvm.IntNE, len, zero, "") + assert := b.CreateAnd(ptrIsNil, lenIsNotZero, "") + assert = b.CreateOr(assert, lenOutOfBounds, "") +- b.createRuntimeAssert(assert, "unsafe.Slice", "unsafeSlicePanic") ++ b.createRuntimeAssert(assert, name, "unsafeSlicePanic") + } + + // createChanBoundsCheck creates a bounds check before creating a new channel to +diff --git a/compiler/compiler.go b/compiler/compiler.go +index 8b6e8661..eda045ab 100644 +--- a/compiler/compiler.go ++++ b/compiler/compiler.go +@@ -1638,20 +1638,20 @@ func (b *builder) createBuiltin(argTypes []types.Type, argValues []llvm.Value, c + case "Sizeof": // unsafe.Sizeof + size := b.targetData.TypeAllocSize(argValues[0].Type()) + return llvm.ConstInt(b.uintptrType, size, false), nil +- case "Slice": // unsafe.Slice +- // This creates a slice from a pointer and a length. ++ case "Slice", "String": // unsafe.Slice, unsafe.String ++ // This creates a slice or string from a pointer and a length. + // Note that the exception mentioned in the documentation (if the + // pointer and length are nil, the slice is also nil) is trivially + // already the case. + ptr := argValues[0] + len := argValues[1] +- slice := llvm.Undef(b.ctx.StructType([]llvm.Type{ +- ptr.Type(), +- b.uintptrType, +- b.uintptrType, +- }, false)) +- elementType := b.getLLVMType(argTypes[0].Underlying().(*types.Pointer).Elem()) +- b.createUnsafeSliceCheck(ptr, len, elementType, argTypes[1].Underlying().(*types.Basic)) ++ var elementType llvm.Type ++ if callName == "Slice" { ++ elementType = b.getLLVMType(argTypes[0].Underlying().(*types.Pointer).Elem()) ++ } else { ++ elementType = b.ctx.Int8Type() ++ } ++ b.createUnsafeSliceStringCheck("unsafe."+callName, ptr, len, elementType, argTypes[1].Underlying().(*types.Basic)) + if len.Type().IntTypeWidth() < b.uintptrType.IntTypeWidth() { + // Too small, zero-extend len. + len = b.CreateZExt(len, b.uintptrType, "") +@@ -1659,10 +1659,24 @@ func (b *builder) createBuiltin(argTypes []types.Type, argValues []llvm.Value, c + // Too big, truncate len. + len = b.CreateTrunc(len, b.uintptrType, "") + } +- slice = b.CreateInsertValue(slice, ptr, 0, "") +- slice = b.CreateInsertValue(slice, len, 1, "") +- slice = b.CreateInsertValue(slice, len, 2, "") +- return slice, nil ++ if callName == "Slice" { ++ slice := llvm.Undef(b.ctx.StructType([]llvm.Type{ ++ ptr.Type(), ++ b.uintptrType, ++ b.uintptrType, ++ }, false)) ++ slice = b.CreateInsertValue(slice, ptr, 0, "") ++ slice = b.CreateInsertValue(slice, len, 1, "") ++ slice = b.CreateInsertValue(slice, len, 2, "") ++ return slice, nil ++ } else { ++ str := llvm.Undef(b.getLLVMRuntimeType("_string")) ++ str = b.CreateInsertValue(str, argValues[0], 0, "") ++ str = b.CreateInsertValue(str, len, 1, "") ++ return str, nil ++ } ++ case "SliceData", "StringData": // unsafe.SliceData, unsafe.StringData ++ return b.CreateExtractValue(argValues[0], 0, "slice.data"), nil + default: + return llvm.Value{}, b.makeError(pos, "todo: builtin: "+callName) + } +diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go +index a5cd9c6b..f8221a08 100644 +--- a/compiler/compiler_test.go ++++ b/compiler/compiler_test.go +@@ -9,6 +9,7 @@ import ( + "testing" + + "github.com/tinygo-org/tinygo/compileopts" ++ "github.com/tinygo-org/tinygo/goenv" + "github.com/tinygo-org/tinygo/loader" + "tinygo.org/x/go-llvm" + ) +@@ -27,6 +28,12 @@ type testCase struct { + func TestCompiler(t *testing.T) { + t.Parallel() + ++ // Determine Go minor version (e.g. 16 in go1.16.3). ++ _, goMinor, err := goenv.GetGorootVersion(goenv.Get("GOROOT")) ++ if err != nil { ++ t.Fatal("could not read Go version:", err) ++ } ++ + // Determine which tests to run, depending on the Go and LLVM versions. + tests := []testCase{ + {"basic.go", "", ""}, +@@ -43,6 +50,9 @@ func TestCompiler(t *testing.T) { + {"channel.go", "", ""}, + {"gc.go", "", ""}, + } ++ if goMinor >= 20 { ++ tests = append(tests, testCase{"go1.20.go", "", ""}) ++ } + + for _, tc := range tests { + name := tc.file +diff --git a/compiler/testdata/go1.20.go b/compiler/testdata/go1.20.go +new file mode 100644 +index 00000000..be65363e +--- /dev/null ++++ b/compiler/testdata/go1.20.go +@@ -0,0 +1,15 @@ ++package main ++ ++import "unsafe" ++ ++func unsafeSliceData(s []int) *int { ++ return unsafe.SliceData(s) ++} ++ ++func unsafeString(ptr *byte, len int16) string { ++ return unsafe.String(ptr, len) ++} ++ ++func unsafeStringData(s string) *byte { ++ return unsafe.StringData(s) ++} +diff --git a/compiler/testdata/go1.20.ll b/compiler/testdata/go1.20.ll +new file mode 100644 +index 00000000..fc66b47c +--- /dev/null ++++ b/compiler/testdata/go1.20.ll +@@ -0,0 +1,58 @@ ++; ModuleID = 'go1.20.go' ++source_filename = "go1.20.go" ++target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20" ++target triple = "wasm32-unknown-wasi" ++ ++%runtime._string = type { ptr, i32 } ++ ++declare noalias nonnull ptr @runtime.alloc(i32, ptr, ptr) #0 ++ ++declare void @runtime.trackPointer(ptr nocapture readonly, ptr) #0 ++ ++; Function Attrs: nounwind ++define hidden void @main.init(ptr %context) unnamed_addr #1 { ++entry: ++ ret void ++} ++ ++; Function Attrs: nounwind ++define hidden ptr @main.unsafeSliceData(ptr %s.data, i32 %s.len, i32 %s.cap, ptr %context) unnamed_addr #1 { ++entry: ++ call void @runtime.trackPointer(ptr %s.data, ptr undef) #2 ++ ret ptr %s.data ++} ++ ++; Function Attrs: nounwind ++define hidden %runtime._string @main.unsafeString(ptr dereferenceable_or_null(1) %ptr, i16 %len, ptr %context) unnamed_addr #1 { ++entry: ++ %0 = icmp slt i16 %len, 0 ++ %1 = icmp eq ptr %ptr, null ++ %2 = icmp ne i16 %len, 0 ++ %3 = and i1 %1, %2 ++ %4 = or i1 %3, %0 ++ br i1 %4, label %unsafe.String.throw, label %unsafe.String.next ++ ++unsafe.String.next: ; preds = %entry ++ %5 = zext i16 %len to i32 ++ %6 = insertvalue %runtime._string undef, ptr %ptr, 0 ++ %7 = insertvalue %runtime._string %6, i32 %5, 1 ++ call void @runtime.trackPointer(ptr %ptr, ptr undef) #2 ++ ret %runtime._string %7 ++ ++unsafe.String.throw: ; preds = %entry ++ call void @runtime.unsafeSlicePanic(ptr undef) #2 ++ unreachable ++} ++ ++declare void @runtime.unsafeSlicePanic(ptr) #0 ++ ++; Function Attrs: nounwind ++define hidden ptr @main.unsafeStringData(ptr %s.data, i32 %s.len, ptr %context) unnamed_addr #1 { ++entry: ++ call void @runtime.trackPointer(ptr %s.data, ptr undef) #2 ++ ret ptr %s.data ++} ++ ++attributes #0 = { "target-features"="+bulk-memory,+nontrapping-fptoint,+sign-ext" } ++attributes #1 = { nounwind "target-features"="+bulk-memory,+nontrapping-fptoint,+sign-ext" } ++attributes #2 = { nounwind } +diff --git a/src/runtime/panic.go b/src/runtime/panic.go +index d7ba9ded..c9c69363 100644 +--- a/src/runtime/panic.go ++++ b/src/runtime/panic.go +@@ -143,10 +143,11 @@ func sliceToArrayPointerPanic() { + runtimePanic("slice smaller than array") + } + +-// Panic when calling unsafe.Slice() (Go 1.17+) with a len that's too large +-// (which includes if the ptr is nil and len is nonzero). ++// Panic when calling unsafe.Slice() (Go 1.17+) or unsafe.String() (Go 1.20+) ++// with a len that's too large (which includes if the ptr is nil and len is ++// nonzero). + func unsafeSlicePanic() { +- runtimePanic("unsafe.Slice: len out of range") ++ runtimePanic("unsafe.Slice/String: len out of range") + } + + // Panic when trying to create a new channel that is too big. +-- +2.38.1 + diff --git a/0022-runtime-implement-math-rand.fastrand64-to-fix-linker.patch b/0022-runtime-implement-math-rand.fastrand64-to-fix-linker.patch new file mode 100644 index 0000000..7f4ff02 --- /dev/null +++ b/0022-runtime-implement-math-rand.fastrand64-to-fix-linker.patch @@ -0,0 +1,35 @@ +From c6b1937fefc56c73648ba5339420bd9151e63fc8 Mon Sep 17 00:00:00 2001 +From: Ayke van Laethem +Date: Fri, 13 Jan 2023 19:54:05 +0100 +Subject: [PATCH 22/26] runtime: implement math/rand.fastrand64 to fix linker + error + +This is needed for Go 1.20 support. + +Signed-off-by: Elliott Sales de Andrade +--- + src/runtime/algorithm.go | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/src/runtime/algorithm.go b/src/runtime/algorithm.go +index 35e2e260..11b39200 100644 +--- a/src/runtime/algorithm.go ++++ b/src/runtime/algorithm.go +@@ -7,6 +7,14 @@ import ( + "unsafe" + ) + ++// This function is needed by math/rand since Go 1.20. ++// See: https://github.com/golang/go/issues/54880 ++// ++//go:linkname rand_fastrand64 math/rand.fastrand64 ++func rand_fastrand64() uint64 { ++ return fastrand64() ++} ++ + // This function is used by hash/maphash. + func fastrand() uint32 { + xorshift32State = xorshift32(xorshift32State) +-- +2.38.1 + diff --git a/0023-runtime-implement-internal-godebug.setUpdate-as-a-st.patch b/0023-runtime-implement-internal-godebug.setUpdate-as-a-st.patch new file mode 100644 index 0000000..cd73b3f --- /dev/null +++ b/0023-runtime-implement-internal-godebug.setUpdate-as-a-st.patch @@ -0,0 +1,31 @@ +From 89e962d18b5d85cad8f6ee14c030aaccdcd89728 Mon Sep 17 00:00:00 2001 +From: Ayke van Laethem +Date: Fri, 13 Jan 2023 20:02:54 +0100 +Subject: [PATCH 23/26] runtime: implement internal/godebug.setUpdate as a stub + +This function provides a mechanism to watch for changes to the GODEBUG +environment variable. For now, we'll not implement it. It might be +useful in the future, when it can always be added. + +Signed-off-by: Elliott Sales de Andrade +--- + src/runtime/runtime.go | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/runtime/runtime.go b/src/runtime/runtime.go +index 4e24b923..c9df6939 100644 +--- a/src/runtime/runtime.go ++++ b/src/runtime/runtime.go +@@ -87,3 +87,9 @@ func LockOSThread() { + // Stub for now + func UnlockOSThread() { + } ++ ++//go:linkname godebug_setUpdate internal/godebug.setUpdate ++func godebug_setUpdate(update func(string, string)) { ++ // Unimplemented. The 'update' function needs to be called whenever the ++ // GODEBUG environment variable changes (for example, via os.Setenv). ++} +-- +2.38.1 + diff --git a/0024-syscall-implement-setenv-unsetenv-in-the-runtime.patch b/0024-syscall-implement-setenv-unsetenv-in-the-runtime.patch new file mode 100644 index 0000000..791d6a8 --- /dev/null +++ b/0024-syscall-implement-setenv-unsetenv-in-the-runtime.patch @@ -0,0 +1,136 @@ +From cce74aa2f32a29c2dd473b8240680fdc49314486 Mon Sep 17 00:00:00 2001 +From: Ayke van Laethem +Date: Sat, 14 Jan 2023 23:10:44 +0100 +Subject: [PATCH 24/26] syscall: implement setenv/unsetenv in the runtime + +This is expected starting with Go 1.20. + +I've also applied the same modification to syscall_libc.go so that +setenv is only called in a single place. + +Signed-off-by: Elliott Sales de Andrade +--- + src/runtime/{env_linux.go => env_unix.go} | 34 +++++++++++++++-------- + src/syscall/syscall_libc.go | 27 ++++-------------- + 2 files changed, 29 insertions(+), 32 deletions(-) + rename src/runtime/{env_linux.go => env_unix.go} (66%) + +diff --git a/src/runtime/env_linux.go b/src/runtime/env_unix.go +similarity index 66% +rename from src/runtime/env_linux.go +rename to src/runtime/env_unix.go +index cfe8c7f8..e05e063a 100644 +--- a/src/runtime/env_linux.go ++++ b/src/runtime/env_unix.go +@@ -1,29 +1,41 @@ +-//go:build linux +-// +build linux ++//go:build linux || darwin ++// +build linux darwin + + package runtime + + // Update the C environment if cgo is loaded. +-// Called from syscall.Setenv. ++// Called from Go 1.20 and above. + // +-//go:linkname syscall_setenv_c syscall.setenv_c +-func syscall_setenv_c(key string, val string) { ++//go:linkname syscallSetenv syscall.runtimeSetenv ++func syscallSetenv(key, value string) { + keydata := cstring(key) +- valdata := cstring(val) ++ valdata := cstring(value) + // ignore any errors + libc_setenv(&keydata[0], &valdata[0], 1) +- return + } + + // Update the C environment if cgo is loaded. +-// Called from syscall.Unsetenv. ++// Called from Go 1.20 and above. + // +-//go:linkname syscall_unsetenv_c syscall.unsetenv_c +-func syscall_unsetenv_c(key string) { ++//go:linkname syscallUnsetenv syscall.runtimeUnsetenv ++func syscallUnsetenv(key string) { + keydata := cstring(key) + // ignore any errors + libc_unsetenv(&keydata[0]) +- return ++} ++ ++// Compatibility with Go 1.19 and below. ++// ++//go:linkname syscall_setenv_c syscall.setenv_c ++func syscall_setenv_c(key string, val string) { ++ syscallSetenv(key, val) ++} ++ ++// Compatibility with Go 1.19 and below. ++// ++//go:linkname syscall_unsetenv_c syscall.unsetenv_c ++func syscall_unsetenv_c(key string) { ++ syscallUnsetenv(key) + } + + // cstring converts a Go string to a C string. +diff --git a/src/syscall/syscall_libc.go b/src/syscall/syscall_libc.go +index 0f10b7fb..1d3d69c7 100644 +--- a/src/syscall/syscall_libc.go ++++ b/src/syscall/syscall_libc.go +@@ -198,21 +198,12 @@ func Setenv(key, val string) (err error) { + return EINVAL + } + } +- keydata := cstring(key) +- valdata := cstring(val) +- errCode := libc_setenv(&keydata[0], &valdata[0], 1) +- if errCode != 0 { +- err = getErrno() +- } ++ runtimeSetenv(key, val) + return + } + + func Unsetenv(key string) (err error) { +- keydata := cstring(key) +- errCode := libc_unsetenv(&keydata[0]) +- if errCode != 0 { +- err = getErrno() +- } ++ runtimeUnsetenv(key) + return + } + +@@ -313,6 +304,10 @@ func splitSlice(p []byte) (buf *byte, len uintptr) { + return slice.buf, slice.len + } + ++// These two functions are provided by the runtime. ++func runtimeSetenv(key, value string) ++func runtimeUnsetenv(key string) ++ + //export strlen + func libc_strlen(ptr unsafe.Pointer) uintptr + +@@ -326,16 +321,6 @@ func libc_write(fd int32, buf *byte, count uint) int + //export getenv + func libc_getenv(name *byte) *byte + +-// int setenv(const char *name, const char *val, int replace); +-// +-//export setenv +-func libc_setenv(name *byte, val *byte, replace int32) int32 +- +-// int unsetenv(const char *name); +-// +-//export unsetenv +-func libc_unsetenv(name *byte) int32 +- + // ssize_t read(int fd, void *buf, size_t count); + // + //export read +-- +2.38.1 + diff --git a/0025-builder-add-support-for-Go-1.20.patch b/0025-builder-add-support-for-Go-1.20.patch new file mode 100644 index 0000000..ef16562 --- /dev/null +++ b/0025-builder-add-support-for-Go-1.20.patch @@ -0,0 +1,139 @@ +From 41d29d766af9aa9251560c48f0591c5fa2ad9886 Mon Sep 17 00:00:00 2001 +From: Ayke van Laethem +Date: Fri, 13 Jan 2023 17:53:55 +0000 +Subject: [PATCH 25/26] builder: add support for Go 1.20 + +Not all features work yet, but allow it to compile with this Go version. + +Signed-off-by: Elliott Sales de Andrade +--- + .circleci/config.yml | 8 ++++++++ + Makefile | 1 - + builder/config.go | 4 ++-- + cgo/cgo_test.go | 15 +++++++++++---- + cgo/testdata/errors.out.go | 4 ++-- + testdata/stdlib.go | 2 +- + 6 files changed, 24 insertions(+), 10 deletions(-) + +diff --git a/.circleci/config.yml b/.circleci/config.yml +index 38621258..74217b12 100644 +--- a/.circleci/config.yml ++++ b/.circleci/config.yml +@@ -119,6 +119,13 @@ jobs: + - test-linux: + llvm: "14" + resource_class: large ++ test-llvm15-go120: ++ docker: ++ - image: golang:1.20-rc-buster ++ steps: ++ - test-linux: ++ llvm: "15" ++ resource_class: large + + workflows: + test-all: +@@ -126,3 +133,4 @@ workflows: + # This tests our lowest supported versions of Go and LLVM, to make sure at + # least the smoke tests still pass. + - test-llvm14-go118 ++ - test-llvm15-go120 +diff --git a/Makefile b/Makefile +index 89927961..5253900d 100644 +--- a/Makefile ++++ b/Makefile +@@ -280,7 +280,6 @@ TEST_PACKAGES_FAST = \ + container/list \ + container/ring \ + crypto/des \ +- crypto/internal/subtle \ + crypto/md5 \ + crypto/rc4 \ + crypto/sha1 \ +diff --git a/builder/config.go b/builder/config.go +index c55ce1a2..a7df83f1 100644 +--- a/builder/config.go ++++ b/builder/config.go +@@ -33,8 +33,8 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) { + if err != nil { + return nil, fmt.Errorf("could not read version from GOROOT (%v): %v", goroot, err) + } +- if major != 1 || minor < 18 || minor > 19 { +- return nil, fmt.Errorf("requires go version 1.18 through 1.19, got go%d.%d", major, minor) ++ if major != 1 || minor < 18 || minor > 20 { ++ return nil, fmt.Errorf("requires go version 1.18 through 1.20, got go%d.%d", major, minor) + } + + clangHeaderPath := getClangHeaderPath(goenv.Get("TINYGOROOT")) +diff --git a/cgo/cgo_test.go b/cgo/cgo_test.go +index e25da7a1..a44dd8e1 100644 +--- a/cgo/cgo_test.go ++++ b/cgo/cgo_test.go +@@ -11,6 +11,7 @@ import ( + "go/types" + "os" + "path/filepath" ++ "regexp" + "runtime" + "strings" + "testing" +@@ -21,9 +22,15 @@ var flagUpdate = flag.Bool("update", false, "Update images based on test output. + + // normalizeResult normalizes Go source code that comes out of tests across + // platforms and Go versions. +-func normalizeResult(result string) string { +- actual := strings.ReplaceAll(result, "\r\n", "\n") +- return actual ++func normalizeResult(t *testing.T, result string) string { ++ result = strings.ReplaceAll(result, "\r\n", "\n") ++ ++ // This changed to 'undefined:', in Go 1.20. ++ result = strings.ReplaceAll(result, ": undeclared name:", ": undefined:") ++ // Go 1.20 added a bit more detail ++ result = regexp.MustCompile(`(unknown field z in struct literal).*`).ReplaceAllString(result, "$1") ++ ++ return result + } + + func TestCGo(t *testing.T) { +@@ -88,7 +95,7 @@ func TestCGo(t *testing.T) { + if err != nil { + t.Errorf("could not write out CGo AST: %v", err) + } +- actual := normalizeResult(buf.String()) ++ actual := normalizeResult(t, buf.String()) + + // Read the file with the expected output, to compare against. + outfile := filepath.Join("testdata", name+".out.go") +diff --git a/cgo/testdata/errors.out.go b/cgo/testdata/errors.out.go +index b15a26b6..716fd771 100644 +--- a/cgo/testdata/errors.out.go ++++ b/cgo/testdata/errors.out.go +@@ -8,9 +8,9 @@ + // Type checking errors after CGo processing: + // testdata/errors.go:102: cannot use 2 << 10 (untyped int constant 2048) as C.char value in variable declaration (overflows) + // testdata/errors.go:105: unknown field z in struct literal +-// testdata/errors.go:108: undeclared name: C.SOME_CONST_1 ++// testdata/errors.go:108: undefined: C.SOME_CONST_1 + // testdata/errors.go:110: cannot use C.SOME_CONST_3 (untyped int constant 1234) as byte value in variable declaration (overflows) +-// testdata/errors.go:112: undeclared name: C.SOME_CONST_4 ++// testdata/errors.go:112: undefined: C.SOME_CONST_4 + + package main + +diff --git a/testdata/stdlib.go b/testdata/stdlib.go +index bc59d20c..f051eaf0 100644 +--- a/testdata/stdlib.go ++++ b/testdata/stdlib.go +@@ -24,7 +24,7 @@ func main() { + syscall.Getppid() + + // package math/rand +- fmt.Println("pseudorandom number:", rand.Int31()) ++ fmt.Println("pseudorandom number:", rand.New(rand.NewSource(1)).Int31()) + + // package strings + fmt.Println("strings.IndexByte:", strings.IndexByte("asdf", 'd')) +-- +2.38.1 + diff --git a/0026-Skip-archive-zip-tests.patch b/0026-Skip-archive-zip-tests.patch new file mode 100644 index 0000000..5ee4b93 --- /dev/null +++ b/0026-Skip-archive-zip-tests.patch @@ -0,0 +1,36 @@ +From 3ab845ff45c17ed5079a1b63e98f217cd0be26aa Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Mon, 23 Jan 2023 02:28:27 -0500 +Subject: [PATCH 26/26] Skip archive/zip tests + +Signed-off-by: Elliott Sales de Andrade +--- + Makefile | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 5253900d..8ac92040 100644 +--- a/Makefile ++++ b/Makefile +@@ -336,7 +336,6 @@ endif + + # Additional standard library packages that pass tests on individual platforms + TEST_PACKAGES_LINUX := \ +- archive/zip \ + compress/lzw \ + crypto/hmac \ + debug/dwarf \ +@@ -352,6 +351,10 @@ TEST_PACKAGES_LINUX += \ + compress/flate \ + testing/fstest + endif ++ifeq ($(filter-out $(shell $(GO) env GOVERSION | cut -f 2 -d.), 18 19), ) ++TEST_PACKAGES_LINUX += \ ++ archive/zip ++endif + + TEST_PACKAGES_DARWIN := $(TEST_PACKAGES_LINUX) + +-- +2.38.1 + diff --git a/tinygo.spec b/tinygo.spec index f358329..08d8ed3 100644 --- a/tinygo.spec +++ b/tinygo.spec @@ -98,6 +98,19 @@ Patch0015: 0015-transform-fix-memory-corruption-issues.patch Patch0016: 0016-riscv-add-target-abi-metadata-flag.patch Patch0017: 0017-interp-add-support-for-constant-icmp-instructions.patch Patch0018: 0018-ci-add-support-for-LLVM-15.patch +# Backport patches for Go 1.20 support +# https://github.com/tinygo-org/tinygo/pull/3368 +Patch0019: 0019-src-runtime-add-xorshift-based-fastrand64.patch +# https://github.com/tinygo-org/tinygo/pull/3387 +Patch0020: 0020-testing-implement-t.Setenv.patch +# https://github.com/tinygo-org/tinygo/pull/3391 +Patch0021: 0021-compiler-add-support-for-new-unsafe-slice-string-fun.patch +Patch0022: 0022-runtime-implement-math-rand.fastrand64-to-fix-linker.patch +Patch0023: 0023-runtime-implement-internal-godebug.setUpdate-as-a-st.patch +Patch0024: 0024-syscall-implement-setenv-unsetenv-in-the-runtime.patch +Patch0025: 0025-builder-add-support-for-Go-1.20.patch +# https://github.com/tinygo-org/tinygo/issues/3408 +Patch0026: 0026-Skip-archive-zip-tests.patch # Not supported upstream yet. ExcludeArch: armv7hl ppc64le s390x