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

Incompatible with Go 1.23 due to locking down linkname using #1146

Closed
HeRaNO opened this issue Jul 1, 2024 · 5 comments · Fixed by #1167
Closed

Incompatible with Go 1.23 due to locking down linkname using #1146

HeRaNO opened this issue Jul 1, 2024 · 5 comments · Fixed by #1167

Comments

@HeRaNO
Copy link

HeRaNO commented Jul 1, 2024

Describe the bug

Upstream JSON lib sonic is suffering from linkname usage locking down. And it affects hertz according to reports.

          got the same issue from `cloudwego/hertz`.

Originally posted by @xin-hao-awx in bytedance/sonic#660 (comment)

Also can find more information at bytedance/sonic#637

BTW, linkname is used in hertz, too. So maybe we need an investigation.

To Reproduce

  1. Download Go 1.23 RC1
  2. Build a naive Hertz project
  3. See errors in building phase

Expected behavior

No error should be presented.

Hertz version:

On develop branch

Environment:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/test/.cache/go-build'
GOENV='/home/test/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/test/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/test/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23rc1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/test/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/home/test/xcpc-team-reg-main/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2791510403=/tmp/go-build -gno-record-gcc-switches'

Additional context

We have an update PR (#1106 ) but idle for a time. I can compile a naive hertz project with Go 1.21, and it runs OK. Please consider bumping the PR status.

@li-jin-gou
Copy link
Member

li-jin-gou commented Jul 1, 2024

@HeRaNO
Copy link
Author

HeRaNO commented Jul 1, 2024

refer to https://www.cloudwego.io/zh/docs/hertz/tutorials/basic-feature/json/

For the following code:

package main

import (
	"context"

	"github.com/cloudwego/hertz/pkg/app"
	"github.com/cloudwego/hertz/pkg/app/server"
	"github.com/cloudwego/hertz/pkg/common/utils"
	"github.com/cloudwego/hertz/pkg/protocol/consts"
)

func main() {
	h := server.Default(server.WithHostPorts(":12345"))

	h.GET("/ping", func(c context.Context, ctx *app.RequestContext) {
		ctx.JSON(consts.StatusOK, utils.H{"ping": "pong"})
	})

	h.Spin()
}

Compiling with Go 1.23-rc1:

go build -tags stdjson

and the error message is:

# github.com/bytedance/sonic/loader
../go/pkg/mod/github.com/bytedance/[email protected]/loader/funcdata.go:37:32: undefined: _func
../go/pkg/mod/github.com/bytedance/[email protected]/loader/funcdata.go:74:12: undefined: moduledata
../go/pkg/mod/github.com/bytedance/[email protected]/loader/funcdata.go:77:18: undefined: moduledata
../go/pkg/mod/github.com/bytedance/[email protected]/loader/funcdata.go:188:28: undefined: compilationUnit
../go/pkg/mod/github.com/bytedance/[email protected]/loader/stubs.go:27:22: undefined: moduledata
../go/pkg/mod/github.com/bytedance/[email protected]/loader/stubs.go:29:26: undefined: moduledata
../go/pkg/mod/github.com/bytedance/[email protected]/loader/stubs.go:34:27: undefined: moduledata
../go/pkg/mod/github.com/bytedance/[email protected]/loader/stubs.go:36:36: undefined: moduledata
../go/pkg/mod/github.com/bytedance/[email protected]/loader/stubs.go:46:21: undefined: moduledata
../go/pkg/mod/github.com/bytedance/[email protected]/loader/stubs.go:50:22: undefined: moduledata
../go/pkg/mod/github.com/bytedance/[email protected]/loader/stubs.go:50:22: too many errors

In addition, hertz also has linkname used in protobuf codegen. I'm afraid it cannot compile under Go 1.23 even if we bypass sonic issue.

@HeRaNO
Copy link
Author

HeRaNO commented Jul 2, 2024

I found that we used sonic https://github.com/cloudwego/hertz/blob/develop/pkg/app/server/binding/internal/decoder/sonic_required.go here, but with a wrong(?) gjson tag. Not sure whether we should change it to stdjson.

@HeRaNO
Copy link
Author

HeRaNO commented Jul 5, 2024

@li-jin-gou Hi. The code above cannot be compiled under Go 1.23-rc1. Could you please take a look?

@xin-hao-2025
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants