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

plugin: /usr/bin/ld: failed to set dynamic section sizes: bad value #58800

Closed
hasit opened this issue Mar 1, 2023 · 3 comments
Closed

plugin: /usr/bin/ld: failed to set dynamic section sizes: bad value #58800

hasit opened this issue Mar 1, 2023 · 3 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hasit
Copy link

hasit commented Mar 1, 2023

What version of Go are you using (go version)?

$ go version
go version go1.19.6 linux/amd64

Using golang:1.19.6-bullseye Docker image.

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

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.19.6"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/src/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3821714963=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Trying to build plugin with the following code:
Go playground: https://go.dev/play/p/D0QJ0S09DX7?v=goprev

Ran go build -buildmode=plugin --ldflags '-s -w' -o plugin.so .

What did you expect to see?

Expect plugin.so to be built.

What did you see instead?

The following error:

go build -buildmode=plugin Output
+ go build -buildmode=plugin --ldflags '    -s -w     -X '\''main.Plugin=aperture-plugin-attributesprocessor'\''     -X '\''main.BuildHost=buildkitsandbox'\''     -X '\''main.BuildOS=linux/amd64'\''     -X '\''main.BuildTime=$(date -Iseconds)'\''     -X '\''main.GitBranch='\''     -X '\''main.GitCommitHash='\'' ' -o /plugins/aperture-plugin-attributesprocessor.so .
# github.com/fluxninja/aperture/plugins/agent/aperture-plugin-attributesprocessor
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.newParser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.newParser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.newParser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: /tmp/go-link-2649145681/go.o:(*IND*+0x0): multiple definition of `github.com/alecthomas/participle/v2.Build[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"('
/usr/bin/ld: $WORK/b001/exe/a.out.so: version node not found for symbol github.com/alecthomas/participle/v2.(*Parser[go.shape.struct { Invocation github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.invocation "parser:\"(@@\""; Converter *github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.converter "parser:\"|@@)\""; WhereClause *github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl.booleanExpression "parser:\"( 'where' @@ )?\"" }_0]).getElidedTypes
/usr/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status

Previously, the package attributesprocessor was being used in our main executable. We started seeing this error when we moved the code to build as a plugin.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Mar 1, 2023
@dmitshur
Copy link
Contributor

dmitshur commented Mar 1, 2023

CC @golang/runtime.

@dmitshur dmitshur added this to the Backlog milestone Mar 1, 2023
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 1, 2023
@cherrymui
Copy link
Member

cherrymui commented Mar 2, 2023

Hmmm, I guess this may be due to that the external linker doesn't like certain characters in the symbol names. Previously only type symbols can contain weird characters, and we mangle them in plugin mode to avoid problems. With generics, function symbols can has well, because it contains the instantiation type, like the case above, which is probably instantiated this type https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/grammar.go#L26 , which does contain weird characters in the struct field tag.

I guess we may need to mangle more symbol names. Or, the compiler could drop at least the struct field tags from the shape name (which don't affect GC shape), probably field names as well.

@gopherbot
Copy link

Change https://go.dev/cl/500095 mentions this issue: cmd/link: mangle certain instantiated function name in plugin mode

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 9, 2023
@dmitshur dmitshur modified the milestones: Backlog, Go1.21 Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants