go: cmd/link: -buildmode=c-shared not supported on linux/mips64le
What version of Go are you using (go version
)?
$ go version 1.15.6
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="mips64le" GOBIN="" GOCACHE="/root/.cache/go-build" GOENV="/root/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="mips64le" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/go" GOPRIVATE="" GOPROXY="https://goproxy.cn,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_mips64le" GCCGO="gccgo" GOMIPS64="hardfloat" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/go/src/github.com/cilium/cilium/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -mabi=64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build215838537=/tmp/go-build -gno-record-gcc-switches"
What did you do?
When I tried to migrate Cilium to the mips64le (loongnix) platform, I got an error, among others, when I compiled a class library, Proxylib, and found that Cilium was handling it as a .so file. Here is the compile command
$ CGO_ENABLED=1 go build -mod=vendor -ldflags ' -X "github.com/cilium/cilium/pkg/version.ciliumVersion=1.9.1 6857a8d2a 2020-12-18T01 :24:42+08:00" -s -w -X "github.com/cilium/cilium/pkg/envoy.RequestedEnvoyVersionSHA=1177896bebde79915fe5f9092409bf0254084b4e" -X " github.com/cilium/cilium/pkg/datapath/loader.DatapathSHA=3d9461ac3d8ae0b334f319c93e10ddea336d8617" -extldflags -Wl,-soname, libcilium.so.1' -tags=osusergo -o libcilium.so.1 -buildmode=c-shared -buildmode=c-shared support on linux/mips64le
Since -buildmod=c-shared is used, this buildmod prompt does not support building on linux/mips64le, does anyone have any good solutions?
What did you expect to see?
-buildmode=c-shared support on linux/mips64le
What did you see instead?
-buildmode=c-shared not supported on linux/mips64le
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 2
- Comments: 37 (21 by maintainers)
I have analyzed this issue, and I try to develop this feature, but I have not completed it yet. I will do it.
This is only a guess, but my first thought would be that
(*ctxt0).asmout
in cmd/internal/obj/mips/asm0.go needs to checkc.ctxt.Flag_shared
, and, if that is true, not setrel.Type
toobjabi.R_CALLMIPS
. It needs to generate a position independent relocation instead. Look at C code and see how the assembly differs when using-fPIC
; the code in mips/asm0.go will likely need to do something similar. Also look at how other cmd/internal/obj/ARCH/asm*.go files handleFlag_shared
.@ianlancetaylor I meet a issue when I develop the
-buildmod=c-shared
featrue on linux/mips64le port. Could you give me a hint to fix this issule? I just open some switches that intercept the feature on linux/mips64le port, and executego build -a -x -work -buildmod=c-shared xxx.go
the following error occors: