golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.72k stars 17.62k forks source link

golang test try to load different shared library name from `CgoLDFLAGS` #69605

Open beer-1 opened 1 month ago

beer-1 commented 1 month ago

Go version

1.22

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/runner/.cache/go-build'
GOENV='/home/runner/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/runner/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/runner/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/hostedtoolcache/go/1.22.7/x64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/hostedtoolcache/go/1.22.7/x64/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.7'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/runner/work/movevm/movevm/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 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1822593352=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Try to link different shared libraries depends on the build arch.

What did you see happen?

When we rebuild the shared library for testing, golang try to find shared library libmovevm.so not libmovevm.x86_64.so.

/tmp/go-build3551466219/b001/movevm.test: error while loading shared libraries: libmovevm.so: cannot open shared object file: No such file or directory

full logs

We defined shared linking in api/link_linux_glibc_x86_64.go. and our CgoLDFLAGS is properly showing

    "CgoLDFLAGS": [
        "-Wl,-rpath,/home/runner/work/movevm/movevm/api",
        "-L/home/runner/work/movevm/movevm/api",
        "-lmovevm.x86_64",
        "-lcompiler.x86_64"
    ],

linking definition

If we remove this line, it is properly working. Here is success log without make build-rust.

What did you expect to see?

Load libmovevm.x86_64.so not libmovevm.so

gabyhelp commented 1 month ago

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

beer-1 commented 1 month ago

This GitHub action had no problem two weeks ago, but not sure why this happening history: https://github.com/initia-labs/movevm/actions/workflows/test.yml?page=2

dr2chase commented 4 weeks ago

@golang/compiler