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/compile, cmd/link: c-shared not supported on linux/loong64 #53301

Open
suchao-lv opened this issue Jun 9, 2022 · 2 comments
Open

cmd/compile, cmd/link: c-shared not supported on linux/loong64 #53301

suchao-lv opened this issue Jun 9, 2022 · 2 comments
Labels
arch-loong64 FeatureRequest NeedsInvestigation
Milestone

Comments

@suchao-lv
Copy link

@suchao-lv suchao-lv commented Jun 9, 2022

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

$ go version
go version go1.18 linux/loong64

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="on"
GOARCH="loong64"
GOBIN=""
GOCACHE="/home/uos/.cache/go-build"
GOENV="/home/uos/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="loong64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/uos/go/pkg/mod"
GONOPROXY="*.uniontech.com"
GONOSUMDB="*.uniontech.com"
GOOS="linux"
GOPATH="/home/uos/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/share/ubxgo/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/share/ubxgo/go/pkg/tool/linux_loong64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -mabi=lp64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1139878000=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go build -x -buildmode=c-shared -o hello.so hello.go

-buildmode=c-shared not supported on linux/loong64

I tried modified source code to support c-shared

/usr/share/ubxgo/go/pkg/tool/linux_loong64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -installsuffix shared -buildmode=c-shared -buildid=VjSGCzgmjjJmng4hvW1p/WO5bAXmxALTE53mSBcMM/lLTTU0AieOjUvcGiNFbI/VjSGCzgmjjJmng4hvW1p -extld=gcc /home/uos/.cache/go-build/8a/8a684f2f6e11d470d52b1497952c1f44669b428ec4b5cbe654f378ab7a078f2b-d
#command-line-arguments
/usr/share/ubxgo/go/pkg/tool/linux_loong64/link: running gcc failed: exit status 1
collect2: fatal error: ld terminated with signal 11 [segfault]
compilation terminated.
package main
import "C"
//export hello
func hello(value string) *C.char {
        return C.CString("hello"+value)
}

func main() {

}

What did you expect to see?

What did you see instead?

Why doesn't loongarch supported c-shared mode?


Modified into English (origin Chinese)

@randall77
Copy link
Contributor

@randall77 randall77 commented Jun 9, 2022

@golang/loong64

@mengzhuo mengzhuo changed the title affected/package: cmd/compile, cmd/link: c-shared not supported on linux/loong64 Jun 9, 2022
@mengzhuo mengzhuo added the arch-loong64 label Jun 9, 2022
@xen0n
Copy link
Member

@xen0n xen0n commented Jun 9, 2022

I think for producing shared objects, some kind of real relocation record support is needed, but unfortunately the current stack-machine-based relocations of LoongArch are poorly supported at best.

I think it's probably better to wait until loongson/LoongArch-Documentation#50 is finalized and merged.

@cherrymui cherrymui added the NeedsInvestigation label Jun 9, 2022
@cherrymui cherrymui added this to the Unplanned milestone Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-loong64 FeatureRequest NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

5 participants