Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.20.2 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
This issue can be reproduced inside the official golang:1.20-alpine docker container and it works fine on the previous golang:1.19-alpine
go env Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.20.2" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/build/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 -fdebug-prefix-map=/tmp/go-build3925415831=/tmp/go-build -gno-record-gcc-switches"
What did you do?
This error has been discovered in Yocto/OpenEmbedded that builds the go shared std library and this issue also affect
other go projects [1], the workaround to build successfully since go 1.20 is not using the -linkshared
[1] https://lists.yoctoproject.org/g/meta-virtualization/topic/97182310
Steps to reproduce:
# fetch some affected source
git clone https://github.com/foundriesio/fioconfig && cd fioconfig
# go-1.19 is good
cat > Dockerfile.shared << EOF
FROM golang:1.19-alpine
RUN mkdir /build
WORKDIR /build
RUN apk add --update --no-cache g++
COPY . .
RUN go mod download
RUN go install -buildmode=shared -linkshared std
RUN go build -linkshared -tags vpn -o ./fioconfig main.go
EOF
docker build . -f Dockerfile.shared
# go-1.20 is broken
cat > Dockerfile.shared << EOF
FROM golang:1.20-alpine
RUN mkdir /build
WORKDIR /build
RUN apk add --update --no-cache g++
COPY . .
RUN go env
RUN go mod download
RUN go install -buildmode=shared -linkshared std
RUN go build -linkshared -tags vpn -o ./fioconfig main.go
EOF
docker build . -f Dockerfile.shared
What did you expect to see?
Build my go linkshared application without any errors like on previous version 1.19.
What did you see instead?
Linking errors
# command-line-arguments
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).Add
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).Add
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).CombinedMult
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).CombinedMult
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).Double
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).Double
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).IsOnCurve
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).IsOnCurve
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).Params
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).Params
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).ScalarBaseMult
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).ScalarBaseMult
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).ScalarMult
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).ScalarMult
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).Unmarshal
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).Unmarshal
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).UnmarshalCompressed
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).UnmarshalCompressed
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).normalizeScalar
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).normalizeScalar
type:*crypto/elliptic.nistCurve[*crypto/internal/nistec.P224Point]: unreachable sym in relocation: crypto/elliptic.(*nistCurve[*crypto/internal/nistec.P224Point]).pointFromAffine
/usr/local/go/pkg/tool/linux_amd64/link: too many errors
The command '/bin/sh -c go build -linkshared -tags vpn -o ./fioconfig main.go' returned a non-zero code: 1
Metadata
Metadata
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Activity
quaresmajose commentedon Mar 10, 2023
It looks like the crypto/elliptic is now no more than a compatibility wrapper and the new crypto/ecdh don't implement the P-224 curves [2].
[2] https://words.filippo.io/dispatches/go-1-20-cryptography
@FiloSottile is the author of the blog post so he maybe know better what going on.
cagedmantis commentedon Mar 10, 2023
cc @rolandshoemaker @golang/security
mdempsky commentedon Mar 14, 2023
Standalone repro:
I think this is a compiler or linker issue, not an issue with crypto/elliptic itself.
I expect the issue has to do with instantiating generic types across DSO boundaries (due to inlining).
/cc @golang/compiler
mdempsky commentedon Mar 14, 2023
@cherrymui gave this explanation:
[-]crypto/elliptic: linkshared regression in crypto/internal/nistec.P224Point since version 1.20[/-][+]cmd/compile: crypto/elliptic build error under -linkshared mode[/+]cuonglm commentedon Mar 15, 2023
FYI, this is started failing since https://go-review.googlesource.com/c/go/+/443535 (with 18baca6 and de6abd7 applied for fixing
go install -linkshared -buildmode=shared std)quaresmajose commentedon Mar 15, 2023
The described steps to reproduce this issue uses
GOARCH="amd64"but please note that it can be reproduced on other architectures too. At last I can reproduce the issue onarmandarm64so maybe this is architecture independent.gopherbot commentedon Mar 15, 2023
Change https://go.dev/cl/476735 mentions this issue:
cmd/link: improve error message and debugging8 remaining items
go: fix some linkshared regression introduced in go 1.20
go: fix some linkshared regression introduced in go 1.20
go: fix some linkshared regression introduced in go 1.20
cuonglm commentedon Mar 25, 2023
@gopherbot please backport this issue to go1.20
gopherbot commentedon Mar 25, 2023
Backport issue(s) opened: #59236 (for 1.20).
Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.
Revert "yq: drop {LINKSHARED}"
buildah: enable linkshared
cmd/compile: re-compile instantiated generic methods in linkshared mode