From 6cdd50d199f56cb7423cd4a9b8e75be8faea58f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E4=BB=AA?= Date: Mon, 19 Jan 2026 14:19:03 +0800 Subject: [PATCH 1/5] feat: support go1.26 --- go.sum | 3 --- internal/rt/map_swiss_go124.go | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/go.sum b/go.sum index 7fa91e4fd..f6a89eaa6 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M= github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= -github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA= -github.com/bytedance/sonic/loader v0.3.0/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI= github.com/bytedance/sonic/loader v0.4.0 h1:olZ7lEqcxtZygCK9EKYKADnpQoYkRQxaeY2NYzevs+o= github.com/bytedance/sonic/loader v0.4.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo= github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M= @@ -19,7 +17,6 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= diff --git a/internal/rt/map_swiss_go124.go b/internal/rt/map_swiss_go124.go index 6a7907691..b3cd40beb 100644 --- a/internal/rt/map_swiss_go124.go +++ b/internal/rt/map_swiss_go124.go @@ -1,5 +1,5 @@ -//go:build go1.24 && !go1.26 && goexperiment.swissmap -// +build go1.24,!go1.26,goexperiment.swissmap +//go:build go1.26 || goexperiment.swissmap +// +build go1.26 goexperiment.swissmap package rt From fd03617f46ad1cb65037e57bd2258b4fffc77d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E4=BB=AA?= Date: Mon, 19 Jan 2026 14:49:19 +0800 Subject: [PATCH 2/5] go1.26 tag --- ast/api.go | 4 ++-- ast/api_compat.go | 2 +- ast/api_native_test.go | 4 ++-- compat.go | 2 +- decode_test.go | 4 ++-- decoder/decoder_compat.go | 4 ++-- decoder/decoder_native.go | 4 ++-- decoder/decoder_native_test.go | 4 ++-- encode_test.go | 4 ++-- encoder/encoder_compat.go | 2 +- encoder/encoder_native.go | 2 +- encoder/encoder_native_test.go | 2 +- internal/compat/warn.go | 2 +- internal/decoder/api/decoder_amd64.go | 4 ++-- internal/decoder/api/decoder_arm64.go | 2 +- internal/decoder/jitdec/asm_stubs_amd64_go121.go | 2 +- internal/decoder/jitdec/assembler_regabi_amd64.go | 4 ++-- internal/decoder/jitdec/generic_regabi_amd64.go | 2 +- internal/encoder/alg/spec.go | 4 ++-- internal/encoder/alg/spec_compat.go | 2 +- internal/encoder/x86/asm_stubs_amd64_go121.go | 4 ++-- internal/encoder/x86/assembler_regabi_amd64.go | 4 ++-- internal/encoder/x86/debug_go117.go | 4 ++-- internal/rt/base64_amd64.go | 2 +- internal/rt/base64_compat.go | 2 +- internal/rt/gcwb.go | 2 +- internal/rt/{map_nosiwss_go124.go => map_go124.go} | 0 internal/rt/{map_swiss_go124.go => map_go126.go} | 0 loader/funcdata_compat.go | 4 ++-- loader/funcdata_go123.go | 4 ++-- loader/funcdata_latest.go | 4 ++-- rfc_test.go | 4 ++-- search_test.go | 4 ++-- sonic.go | 4 ++-- unquote/unquote.go | 4 ++-- unquote/unquote_fallback.go | 2 +- utf8/utf8.go | 4 ++-- utf8/utf8_fallback.go | 2 +- utf8/utf8_native_test.go | 4 ++-- 39 files changed, 59 insertions(+), 59 deletions(-) rename internal/rt/{map_nosiwss_go124.go => map_go124.go} (100%) rename internal/rt/{map_swiss_go124.go => map_go126.go} (100%) diff --git a/ast/api.go b/ast/api.go index b9d3c58ee..51a276108 100644 --- a/ast/api.go +++ b/ast/api.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* * Copyright 2022 ByteDance Inc. diff --git a/ast/api_compat.go b/ast/api_compat.go index c6a540cbf..08eecf88b 100644 --- a/ast/api_compat.go +++ b/ast/api_compat.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 +// +build !amd64,!arm64 go1.27 !go1.17 arm64,!go1.20 /* * Copyright 2022 ByteDance Inc. diff --git a/ast/api_native_test.go b/ast/api_native_test.go index 077c29ed6..e113904ae 100644 --- a/ast/api_native_test.go +++ b/ast/api_native_test.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* * Copyright 2022 ByteDance Inc. diff --git a/compat.go b/compat.go index 1fa670a48..40b4de43c 100644 --- a/compat.go +++ b/compat.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 +// +build !amd64,!arm64 go1.27 !go1.17 arm64,!go1.20 /* * Copyright 2021 ByteDance Inc. diff --git a/decode_test.go b/decode_test.go index 8cbcf2bcc..5ddc7e5ab 100644 --- a/decode_test.go +++ b/decode_test.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/decoder/decoder_compat.go b/decoder/decoder_compat.go index 75b21746f..b06d2d809 100644 --- a/decoder/decoder_compat.go +++ b/decoder/decoder_compat.go @@ -1,5 +1,5 @@ -//go:build (!amd64 && !arm64) || go1.26 || !go1.17 || (arm64 && !go1.20) -// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 +//go:build (!amd64 && !arm64) || go1.27 || !go1.17 || (arm64 && !go1.20) +// +build !amd64,!arm64 go1.27 !go1.17 arm64,!go1.20 /* * Copyright 2023 ByteDance Inc. diff --git a/decoder/decoder_native.go b/decoder/decoder_native.go index 4313a4e14..28c203392 100644 --- a/decoder/decoder_native.go +++ b/decoder/decoder_native.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* diff --git a/decoder/decoder_native_test.go b/decoder/decoder_native_test.go index ce3ff943b..22ed3006a 100644 --- a/decoder/decoder_native_test.go +++ b/decoder/decoder_native_test.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/encode_test.go b/encode_test.go index 46e5f05d9..ea28a66eb 100644 --- a/encode_test.go +++ b/encode_test.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/encoder/encoder_compat.go b/encoder/encoder_compat.go index a7350548a..a19d0b988 100644 --- a/encoder/encoder_compat.go +++ b/encoder/encoder_compat.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 +// +build !amd64,!arm64 go1.27 !go1.17 arm64,!go1.20 /* * Copyright 2023 ByteDance Inc. diff --git a/encoder/encoder_native.go b/encoder/encoder_native.go index bfed805fd..faf70c71a 100644 --- a/encoder/encoder_native.go +++ b/encoder/encoder_native.go @@ -1,4 +1,4 @@ -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* * Copyright 2023 ByteDance Inc. diff --git a/encoder/encoder_native_test.go b/encoder/encoder_native_test.go index b4f3de832..003ebb117 100644 --- a/encoder/encoder_native_test.go +++ b/encoder/encoder_native_test.go @@ -1,4 +1,4 @@ -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/internal/compat/warn.go b/internal/compat/warn.go index 4fabaabac..a5f3f7824 100644 --- a/internal/compat/warn.go +++ b/internal/compat/warn.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 +// +build !amd64,!arm64 go1.27 !go1.17 arm64,!go1.20 package compat diff --git a/internal/decoder/api/decoder_amd64.go b/internal/decoder/api/decoder_amd64.go index 4e7f46fa6..f9b388803 100644 --- a/internal/decoder/api/decoder_amd64.go +++ b/internal/decoder/api/decoder_amd64.go @@ -1,5 +1,5 @@ -//go:build go1.17 && !go1.26 -// +build go1.17,!go1.26 +//go:build go1.17 && !go1.27 +// +build go1.17,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/internal/decoder/api/decoder_arm64.go b/internal/decoder/api/decoder_arm64.go index 5a7d44de1..758371b34 100644 --- a/internal/decoder/api/decoder_arm64.go +++ b/internal/decoder/api/decoder_arm64.go @@ -1,4 +1,4 @@ -// +build go1.17,!go1.26 +// +build go1.17,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/internal/decoder/jitdec/asm_stubs_amd64_go121.go b/internal/decoder/jitdec/asm_stubs_amd64_go121.go index 5cd3750bf..138c3a6e3 100644 --- a/internal/decoder/jitdec/asm_stubs_amd64_go121.go +++ b/internal/decoder/jitdec/asm_stubs_amd64_go121.go @@ -1,4 +1,4 @@ -// +build go1.21,!go1.26 +// +build go1.21,!go1.27 // Copyright 2023 CloudWeGo Authors // diff --git a/internal/decoder/jitdec/assembler_regabi_amd64.go b/internal/decoder/jitdec/assembler_regabi_amd64.go index dc86efe08..4c2b8a541 100644 --- a/internal/decoder/jitdec/assembler_regabi_amd64.go +++ b/internal/decoder/jitdec/assembler_regabi_amd64.go @@ -1,5 +1,5 @@ -//go:build go1.17 && !go1.26 -// +build go1.17,!go1.26 +//go:build go1.17 && !go1.27 +// +build go1.17,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/internal/decoder/jitdec/generic_regabi_amd64.go b/internal/decoder/jitdec/generic_regabi_amd64.go index 2cb41f08d..f8cbab15c 100644 --- a/internal/decoder/jitdec/generic_regabi_amd64.go +++ b/internal/decoder/jitdec/generic_regabi_amd64.go @@ -1,4 +1,4 @@ -// +build go1.17,!go1.26 +// +build go1.17,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/internal/encoder/alg/spec.go b/internal/encoder/alg/spec.go index f98914961..33d787928 100644 --- a/internal/encoder/alg/spec.go +++ b/internal/encoder/alg/spec.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.16 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.16,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.16 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.16,!go1.27 arm64,go1.20,!go1.27 /** * Copyright 2024 ByteDance Inc. diff --git a/internal/encoder/alg/spec_compat.go b/internal/encoder/alg/spec_compat.go index cd9beab04..70e55fd54 100644 --- a/internal/encoder/alg/spec_compat.go +++ b/internal/encoder/alg/spec_compat.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.26 !go1.16 arm64,!go1.20 +// +build !amd64,!arm64 go1.27 !go1.16 arm64,!go1.20 /** * Copyright 2024 ByteDance Inc. diff --git a/internal/encoder/x86/asm_stubs_amd64_go121.go b/internal/encoder/x86/asm_stubs_amd64_go121.go index 34a2ff321..af1e3129e 100644 --- a/internal/encoder/x86/asm_stubs_amd64_go121.go +++ b/internal/encoder/x86/asm_stubs_amd64_go121.go @@ -1,5 +1,5 @@ -//go:build go1.21 && !go1.26 -// +build go1.21,!go1.26 +//go:build go1.21 && !go1.27 +// +build go1.21,!go1.27 // Copyright 2023 CloudWeGo Authors // diff --git a/internal/encoder/x86/assembler_regabi_amd64.go b/internal/encoder/x86/assembler_regabi_amd64.go index 620c85900..7905ead31 100644 --- a/internal/encoder/x86/assembler_regabi_amd64.go +++ b/internal/encoder/x86/assembler_regabi_amd64.go @@ -1,5 +1,5 @@ -//go:build go1.17 && !go1.26 -// +build go1.17,!go1.26 +//go:build go1.17 && !go1.27 +// +build go1.17,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/internal/encoder/x86/debug_go117.go b/internal/encoder/x86/debug_go117.go index 6d7659e68..79a86f423 100644 --- a/internal/encoder/x86/debug_go117.go +++ b/internal/encoder/x86/debug_go117.go @@ -1,5 +1,5 @@ -//go:build go1.17 && !go1.26 -// +build go1.17,!go1.26 +//go:build go1.17 && !go1.27 +// +build go1.17,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/internal/rt/base64_amd64.go b/internal/rt/base64_amd64.go index 9b0cfca72..9bd4181f8 100644 --- a/internal/rt/base64_amd64.go +++ b/internal/rt/base64_amd64.go @@ -1,4 +1,4 @@ -// +build amd64,go1.17,!go1.26 +// +build amd64,go1.17,!go1.27 package rt diff --git a/internal/rt/base64_compat.go b/internal/rt/base64_compat.go index e6abcb57d..015e17c10 100644 --- a/internal/rt/base64_compat.go +++ b/internal/rt/base64_compat.go @@ -1,4 +1,4 @@ -// +build !amd64 !go1.17 go1.26 +// +build !amd64 !go1.17 go1.27 package rt diff --git a/internal/rt/gcwb.go b/internal/rt/gcwb.go index c9ad5fb2f..b00c9d906 100644 --- a/internal/rt/gcwb.go +++ b/internal/rt/gcwb.go @@ -1,4 +1,4 @@ -// +build go1.21,!go1.26 +// +build go1.21,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/internal/rt/map_nosiwss_go124.go b/internal/rt/map_go124.go similarity index 100% rename from internal/rt/map_nosiwss_go124.go rename to internal/rt/map_go124.go diff --git a/internal/rt/map_swiss_go124.go b/internal/rt/map_go126.go similarity index 100% rename from internal/rt/map_swiss_go124.go rename to internal/rt/map_go126.go diff --git a/loader/funcdata_compat.go b/loader/funcdata_compat.go index c5c802856..68d50a663 100644 --- a/loader/funcdata_compat.go +++ b/loader/funcdata_compat.go @@ -1,5 +1,5 @@ -//go:build !go1.17 || go1.26 -// +build !go1.17 go1.26 +//go:build !go1.17 || go1.27 +// +build !go1.17 go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/loader/funcdata_go123.go b/loader/funcdata_go123.go index 53a2b180e..617fda82d 100644 --- a/loader/funcdata_go123.go +++ b/loader/funcdata_go123.go @@ -1,5 +1,5 @@ -//go:build go1.23 && !go1.26 -// +build go1.23,!go1.26 +//go:build go1.23 && !go1.27 +// +build go1.23,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/loader/funcdata_latest.go b/loader/funcdata_latest.go index eb4c37578..dbb2fe0dd 100644 --- a/loader/funcdata_latest.go +++ b/loader/funcdata_latest.go @@ -1,5 +1,5 @@ -// go:build go1.18 && !go1.26 -// +build go1.18,!go1.26 +// go:build go1.18 && !go1.27 +// +build go1.18,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/rfc_test.go b/rfc_test.go index 182eba997..41099cc89 100644 --- a/rfc_test.go +++ b/rfc_test.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 package sonic_test diff --git a/search_test.go b/search_test.go index 282c9c60e..5f7b63614 100644 --- a/search_test.go +++ b/search_test.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/sonic.go b/sonic.go index 3a5aff22f..2aabaa8b8 100644 --- a/sonic.go +++ b/sonic.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* * Copyright 2021 ByteDance Inc. diff --git a/unquote/unquote.go b/unquote/unquote.go index 6c8c0c80f..ebfd6c0b6 100644 --- a/unquote/unquote.go +++ b/unquote/unquote.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* diff --git a/unquote/unquote_fallback.go b/unquote/unquote_fallback.go index 41e28f067..eb9a64438 100644 --- a/unquote/unquote_fallback.go +++ b/unquote/unquote_fallback.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 +// +build !amd64,!arm64 go1.27 !go1.17 arm64,!go1.20 /* * Copyright 2021 ByteDance Inc. diff --git a/utf8/utf8.go b/utf8/utf8.go index 71403028e..d5cbeb71a 100644 --- a/utf8/utf8.go +++ b/utf8/utf8.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* * Copyright 2022 ByteDance Inc. diff --git a/utf8/utf8_fallback.go b/utf8/utf8_fallback.go index bd12fcd1c..fb662f922 100644 --- a/utf8/utf8_fallback.go +++ b/utf8/utf8_fallback.go @@ -1,4 +1,4 @@ -// +build !amd64,!arm64 go1.26 !go1.17 arm64,!go1.20 +// +build !amd64,!arm64 go1.27 !go1.17 arm64,!go1.20 /* * Copyright 2021 ByteDance Inc. diff --git a/utf8/utf8_native_test.go b/utf8/utf8_native_test.go index 5cd4c1d6d..ab5cd0ed6 100644 --- a/utf8/utf8_native_test.go +++ b/utf8/utf8_native_test.go @@ -1,5 +1,5 @@ -//go:build (amd64 && go1.17 && !go1.26) || (arm64 && go1.20 && !go1.26) -// +build amd64,go1.17,!go1.26 arm64,go1.20,!go1.26 +//go:build (amd64 && go1.17 && !go1.27) || (arm64 && go1.20 && !go1.27) +// +build amd64,go1.17,!go1.27 arm64,go1.20,!go1.27 /* * Copyright 2022 ByteDance Inc. From 467f52d913a199579b07becae65527abde21b05a Mon Sep 17 00:00:00 2001 From: "duanyi.aster" Date: Thu, 22 Jan 2026 11:13:58 +0800 Subject: [PATCH 3/5] feat: update go moduledata --- go.mod | 2 + loader/funcdata_go123.go | 4 +- loader/funcdata_go126.go | 123 +++++++++++++++++++ loader/funcdata_legacy.go | 24 ++++ loader/{funcdata_latest.go => moduledata.go} | 4 + 5 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 loader/funcdata_go126.go create mode 100644 loader/funcdata_legacy.go rename loader/{funcdata_latest.go => moduledata.go} (99%) diff --git a/go.mod b/go.mod index 909275480..20e0e7845 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/bytedance/sonic go 1.18 +replace github.com/bytedance/sonic/loader => ./loader + require ( github.com/bytedance/gopkg v0.1.3 github.com/bytedance/sonic/loader v0.4.0 diff --git a/loader/funcdata_go123.go b/loader/funcdata_go123.go index 617fda82d..53a2b180e 100644 --- a/loader/funcdata_go123.go +++ b/loader/funcdata_go123.go @@ -1,5 +1,5 @@ -//go:build go1.23 && !go1.27 -// +build go1.23,!go1.27 +//go:build go1.23 && !go1.26 +// +build go1.23,!go1.26 /* * Copyright 2021 ByteDance Inc. diff --git a/loader/funcdata_go126.go b/loader/funcdata_go126.go new file mode 100644 index 000000000..71820252a --- /dev/null +++ b/loader/funcdata_go126.go @@ -0,0 +1,123 @@ +//go:build go1.26 && !go1.27 +// +build go1.26,!go1.27 + +/* + * Copyright 2021 ByteDance Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package loader + +import ( + `unsafe` + `github.com/bytedance/sonic/loader/internal/rt` +) + +const ( + _Magic uint32 = 0xFFFFFFF1 +) + +type moduledata struct { + pcHeader *pcHeader + funcnametab []byte + cutab []uint32 + filetab []byte + pctab []byte + pclntable []byte + ftab []funcTab + findfunctab uintptr + minpc, maxpc uintptr // first func address, last func address + last func size + + text, etext uintptr // start/end of text, (etext-text) must be greater than MIN_FUNC + noptrdata, enoptrdata uintptr + data, edata uintptr + bss, ebss uintptr + noptrbss, enoptrbss uintptr + covctrs, ecovctrs uintptr + end, gcdata, gcbss uintptr + types, etypes uintptr + rodata uintptr + gofunc uintptr // go.func.* is actual funcinfo object in image + epclntab uintptr + + textsectmap []textSection // see runtime/symtab.go: textAddr() + typelinks []int32 // offsets from types + itablinks []*rt.GoItab + + ptab []ptabEntry + + pluginpath string + pkghashes []modulehash + + // This slice records the initializing tasks that need to be + // done to start up the program. It is built by the linker. + inittasks []unsafe.Pointer + + modulename string + modulehashes []modulehash + + hasmain uint8 // 1 if module contains the main function, 0 otherwise + bad bool // module failed to load and should be ignored + + gcdatamask, gcbssmask bitVector + + typemap map[int32]*rt.GoType // offset to *_rtype in previous module + + next *moduledata +} + +type _func struct { + entryOff uint32 // start pc, as offset from moduledata.text/pcHeader.textStart + nameOff int32 // function name, as index into moduledata.funcnametab. + + args int32 // in/out args size + deferreturn uint32 // offset of start of a deferreturn call instruction from entry, if any. + + pcsp uint32 + pcfile uint32 + pcln uint32 + npcdata uint32 + cuOffset uint32 // runtime.cutab offset of this function's CU + startLine int32 // line number of start of function (func keyword/TEXT directive) + funcID uint8 // set for certain special runtime functions + flag uint8 + _ [1]byte // pad + nfuncdata uint8 // + + // The end of the struct is followed immediately by two variable-length + // arrays that reference the pcdata and funcdata locations for this + // function. + + // pcdata contains the offset into moduledata.pctab for the start of + // that index's table. e.g., + // &moduledata.pctab[_func.pcdata[_PCDATA_UnsafePoint]] is the start of + // the unsafe point table. + // + // An offset of 0 indicates that there is no table. + // + // pcdata [npcdata]uint32 + + // funcdata contains the offset past moduledata.gofunc which contains a + // pointer to that index's funcdata. e.g., + // *(moduledata.gofunc + _func.funcdata[_FUNCDATA_ArgsPointerMaps]) is + // the argument pointer map. + // + // An offset of ^uint32(0) indicates that there is no entry. + // + // funcdata [nfuncdata]uint32 +} + +func setEpclntab(mod *moduledata, val uintptr) { + mod.epclntab = val +} diff --git a/loader/funcdata_legacy.go b/loader/funcdata_legacy.go new file mode 100644 index 000000000..df5c8e887 --- /dev/null +++ b/loader/funcdata_legacy.go @@ -0,0 +1,24 @@ +//go:build go1.18 && !go1.26 +// +build go1.18,!go1.26 + +/* + * Copyright 2021 ByteDance Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package loader + +func setEpclntab(mod *moduledata, val uintptr) { + // No-op for versions < 1.26 +} diff --git a/loader/funcdata_latest.go b/loader/moduledata.go similarity index 99% rename from loader/funcdata_latest.go rename to loader/moduledata.go index dbb2fe0dd..7a22c04a3 100644 --- a/loader/funcdata_latest.go +++ b/loader/moduledata.go @@ -268,6 +268,10 @@ func makeModuledata(name string, filenames []string, funcsp *[]Func, text []byte pclntab := makePclntable(pclntSize, startLocations, _funcs, uint32(len(text)), pcdataOffs, funcdataOffs) mod.pclntable = pclntab + if len(pclntab) > 0 { + setEpclntab(mod, uintptr(unsafe.Pointer(&pclntab[0]))+uintptr(len(pclntab))) + } + // make pc header mod.pcHeader = &pcHeader { magic : _Magic, From 164028502aa09f4575c94570c66ca87b5630f9a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E4=BB=AA?= Date: Thu, 22 Jan 2026 14:31:13 +0800 Subject: [PATCH 4/5] fix: gotype indirect --- .../jitdec/generic_regabi_amd64_test.s | 2 +- internal/rt/fastvalue.go | 4 --- internal/rt/gotype_go126.go | 25 +++++++++++++++++++ internal/rt/gotype_legacy.go | 25 +++++++++++++++++++ 4 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 internal/rt/gotype_go126.go create mode 100644 internal/rt/gotype_legacy.go diff --git a/internal/decoder/jitdec/generic_regabi_amd64_test.s b/internal/decoder/jitdec/generic_regabi_amd64_test.s index a08f0e2ad..98978e830 100644 --- a/internal/decoder/jitdec/generic_regabi_amd64_test.s +++ b/internal/decoder/jitdec/generic_regabi_amd64_test.s @@ -1,4 +1,4 @@ -// +build go1.17,!go1.26 +// +build go1.17 // // Copyright 2021 ByteDance Inc. diff --git a/internal/rt/fastvalue.go b/internal/rt/fastvalue.go index bd41afa6c..a9c74d30a 100644 --- a/internal/rt/fastvalue.go +++ b/internal/rt/fastvalue.go @@ -71,10 +71,6 @@ func (self *GoType) String() string { return self.Pack().String() } -func (self *GoType) Indirect() bool { - return self.KindFlags&F_direct == 0 -} - type GoItab struct { it unsafe.Pointer Vt *GoType diff --git a/internal/rt/gotype_go126.go b/internal/rt/gotype_go126.go new file mode 100644 index 000000000..d950cec13 --- /dev/null +++ b/internal/rt/gotype_go126.go @@ -0,0 +1,25 @@ +//go:build go1.26 +// +build go1.26 + +/* + * Copyright 2021 ByteDance Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package rt + +// In Go 1.26+, TFlagDirectIface is in the TFlag (Flags) field, not Kind_. +func (self *GoType) Indirect() bool { + return self.Flags&F_direct == 0 +} diff --git a/internal/rt/gotype_legacy.go b/internal/rt/gotype_legacy.go new file mode 100644 index 000000000..16b0d3fb8 --- /dev/null +++ b/internal/rt/gotype_legacy.go @@ -0,0 +1,25 @@ +//go:build !go1.26 +// +build !go1.26 + +/* + * Copyright 2021 ByteDance Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package rt + +// In Go < 1.26, KindDirectIface is in the Kind_ (KindFlags) field. +func (self *GoType) Indirect() bool { + return self.KindFlags&F_direct == 0 +} From 23f640b914d7fea46846392be678c9b2414e6c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=B5=E4=BB=AA?= Date: Thu, 22 Jan 2026 16:38:00 +0800 Subject: [PATCH 5/5] chore: update warning --- internal/compat/warn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/compat/warn.go b/internal/compat/warn.go index a5f3f7824..7b2ecb0b9 100644 --- a/internal/compat/warn.go +++ b/internal/compat/warn.go @@ -8,5 +8,5 @@ import ( ) func Warn(prefix string) { - fmt.Fprintf(os.Stderr, "WARNING: %s only supports (go1.17~1.24 && amd64 CPU) or (go1.20~1.24 && arm64 CPU), but your environment is not suitable and will fallback to encoding/json\n", prefix) + fmt.Fprintf(os.Stderr, "WARNING: %s only supports (go1.17~1.26 and amd64 CPU) or (go1.20~1.26 and arm64 CPU), but your environment is not suitable and will fallback to encoding/json\n", prefix) }