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

cmd/link: -buildmode=c-shared not supported on linux/mips64le #43264

Open
Mengkzhaoyun opened this issue Dec 18, 2020 · 16 comments
Open

cmd/link: -buildmode=c-shared not supported on linux/mips64le #43264

Mengkzhaoyun opened this issue Dec 18, 2020 · 16 comments

Comments

@Mengkzhaoyun
Copy link

@Mengkzhaoyun Mengkzhaoyun commented Dec 18, 2020

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

@ianlancetaylor ianlancetaylor changed the title -buildmode=c-shared not supported on linux/mips64le cmd/link: -buildmode=c-shared not supported on linux/mips64le Dec 18, 2020
@ianlancetaylor ianlancetaylor added this to the Backlog milestone Dec 18, 2020
@XiaodongLoong
Copy link

@XiaodongLoong XiaodongLoong commented Dec 22, 2020

I have analyzed this issue, and I try to develop this feature, but I have not completed it yet.
I will do it.

@hellocloudnative
Copy link

@hellocloudnative hellocloudnative commented Dec 22, 2020

我也遇到了编译so文件,不支持的问题。这个问题如何解决呢

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Dec 22, 2020

@XiaodongLoong Thanks.

@XiaodongLoong
Copy link

@XiaodongLoong XiaodongLoong commented Mar 24, 2021

@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 execute go build -a -x -work -buildmod=c-shared xxx.go the following error occors:

/root/go/pkg/tool/linux_mips64le/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -installsuffix shared -buildmode=c-shared -buildid=7oc0eGeuITC04x1PL6YA/zGmTkGzcjMksVKPwtCJC/FipDBPEiHap1g6M81mW7/7oc0eGeuITC04x1PL6YA -extld=gcc $WORK/b001/_pkg_.a
# command-line-arguments
/root/go/pkg/tool/linux_mips64le/link: running gcc failed: exit status 1
collect2: fatal error: ld terminated with signal 10 [Bus error], core dumped
compilation terminated.
/usr/bin/ld: /tmp/go-link-020946183/go.o: relocation R_MIPS_26 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.31.1 assertion fail ../../bfd/elfxx-mips.c:6550
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.31.1 assertion fail ../../bfd/elfxx-mips.c:6550
/usr/bin/ld: BFD (GNU Binutils for Debian) 2.31.1 assertion fail ../../bfd/elfxx-mips.c:6550

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Mar 24, 2021

This is only a guess, but my first thought would be that (*ctxt0).asmout in cmd/internal/obj/mips/asm0.go needs to check c.ctxt.Flag_shared, and, if that is true, not set rel.Type to objabi.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 handle Flag_shared.

XiaodongLoong added a commit to XiaodongLoong/go that referenced this issue Aug 2, 2021
For golang#43264

Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
XiaodongLoong added a commit to XiaodongLoong/go that referenced this issue Aug 2, 2021
For golang#43264

Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
XiaodongLoong added a commit to XiaodongLoong/go that referenced this issue Aug 2, 2021
For golang#43264

Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
XiaodongLoong added a commit to XiaodongLoong/go that referenced this issue Aug 2, 2021
For golang#43264

Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 2, 2021

Change https://golang.org/cl/339049 mentions this issue: cmd/internal: support -buildmode=c-shared on linux/mips64le

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 2, 2021

Change https://golang.org/cl/339051 mentions this issue: runtime: support -buildmode=c-shared on linux/mips64le

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 2, 2021

Change https://golang.org/cl/339050 mentions this issue: cmd/compile: support -buildmode=c-shared on linux/mips64le

@XiaodongLoong
Copy link

@XiaodongLoong XiaodongLoong commented Aug 2, 2021

@ianlancetaylor I have completed this work, thanks for your guidance.
It is OK on test cases from https://github.com/vladimirvivien/go-cshared-examples and Cilium.

XiaodongLoong added a commit to XiaodongLoong/go that referenced this issue Aug 2, 2021
For golang#43264

Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
@gopherbot
Copy link

@gopherbot gopherbot commented Aug 2, 2021

Change https://golang.org/cl/339069 mentions this issue: cmd/link: support -buildmode=c-shared on linux/mips64le

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 2, 2021

Change https://golang.org/cl/339052 mentions this issue: cmd/link: support -buildmode=c-shared on linux/mips64le

XiaodongLoong added a commit to XiaodongLoong/go that referenced this issue Aug 3, 2021
For golang#43264

Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
XiaodongLoong added a commit to XiaodongLoong/go that referenced this issue Aug 13, 2021
For golang#43264

Signed-off-by: Xiaodong Liu <liuxiaodong@loongson.cn>
@gopherbot
Copy link

@gopherbot gopherbot commented Sep 9, 2021

Change https://golang.org/cl/348734 mentions this issue: cmd/link: support -buildmode=c-shared on linux/mips64le

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 9, 2021

Change https://golang.org/cl/348733 mentions this issue: cmd/internal: support -buildmode=c-shared on linux/mips64le

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 9, 2021

Change https://golang.org/cl/348732 mentions this issue: cmd/compile: support -buildmode=c-shared on linux/mips64le

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 9, 2021

Change https://golang.org/cl/348735 mentions this issue: runtime: support -buildmode=c-shared on linux/mips64le

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 9, 2021

Change https://golang.org/cl/354890 mentions this issue: cmd/internal/sys: open c-shared feature on linux/mips64le

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants