valyala / gozstd

go wrapper for zstd
MIT License
420 stars 60 forks source link

gozstd fails during linking if the standard lib "plugin" module is imported #32

Open gordallott opened 3 years ago

gordallott commented 3 years ago

you can reproduce this simply by importing both gozstd and plugin at the same time, for example

package main

import (
    _ "github.com/valyala/gozstd"
    _ "plugin"
)

as an example I forked the gozstd repo to add a test to fail this, thus

go get github.com/gordallott/gozstd
go test -v github.com/gordallott/gozstd

should result in something like

# github.com/gordallott/gozstd.test
/home/mhr3/.axiom-dev/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /home/mhr3/.axiom-dev/gopath/src/github.com/gordallott/gozstd/libzstd_linux_amd64.a(zdict.o): relocation R_X86_64_PC32 against symbol `stderr@@GLIBC_2.2.5' can not be used when making a PDE object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

tested on multiple machines with go version go version go1.15.2 linux/amd64

does not appear to be a CGO problem as using other CGO based modules work fine with the plugin module

jamesqddd commented 2 years ago

I have the same problem,and how to solve this problem please,thanks.

SimFG commented 1 year ago

maybe this pull request can help you, detail: https://github.com/pingcap/tiflow/pull/834