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

Closed
xiaobai394 opened this issue Jun 9, 2022 · 13 comments
Closed

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

xiaobai394 opened this issue Jun 9, 2022 · 13 comments
Assignees
Labels
arch-loong64 Issues solely affecting the loongson architecture. compiler/runtime Issues related to the Go compiler and/or runtime. FeatureRequest NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@xiaobai394
Copy link

xiaobai394 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

@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 Issues solely affecting the loongson architecture. label Jun 9, 2022
@xen0n
Copy link
Member

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 Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 9, 2022
@cherrymui cherrymui added this to the Unplanned milestone Jun 9, 2022
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
@wojiushixiaobai
Copy link

有任何进展吗?loongson/LoongArch-Documentation#57 已经关闭

@xen0n
Copy link
Member

xen0n commented Aug 25, 2022

有任何进展吗?loongson/LoongArch-Documentation#57 已经关闭

I think it's better to write in English...

Translation for non-Chinese speakers:

Any progress? loongson/LoongArch-Documentation#57 is already closed.

I don't know if the Loongson people have plans for this cycle; pinging others in @golang/loong64. I myself don't think I have enough time to make any promise though.

@gopherbot
Copy link

Change https://go.dev/cl/425475 mentions this issue: cmd/compile: add support for --buildmode=c-shared on loong64

@gopherbot
Copy link

Change https://go.dev/cl/425474 mentions this issue: runtime: add support for --buildmode=c-shared on loong64

@gopherbot
Copy link

Change https://go.dev/cl/425477 mentions this issue: cmd/link: add support for --buildmode=c-shared on loong64

@gopherbot
Copy link

Change https://go.dev/cl/425478 mentions this issue: cmd/internal/sys: enable c-shared feature on loong64

@gopherbot
Copy link

Change https://go.dev/cl/425479 mentions this issue: cmd/dist, misc/cgo/testcshared: enable c-shared test on loong64

@gopherbot
Copy link

Change https://go.dev/cl/425476 mentions this issue: cmd/internal/obj/loong64, cmd/internal/objabi: add c-shared relocations on loong64

@xen0n
Copy link
Member

xen0n commented Feb 17, 2023

Update: it looks like this is now being actively worked on by other people in @golang/loong64, and seems to target go1.21.

xen0n pushed a commit to xen0n/go that referenced this issue Mar 9, 2023
These c-shared related CLs are follow up of CLs 455016, 455017, 455018. Here we
follow the LoongArch ELF psABI v2 standard, which requires the support of the
PCALAU12I instruction.

Updates golang#53301
Updates golang#58784

Change-Id: I7f1ddbf3b2470d610f12069d147aa9b3a6a96f32
xen0n pushed a commit to xen0n/go that referenced this issue Mar 9, 2023
Updates golang#53301
Updates golang#58784

Change-Id: I78a90155b17d7d8be04e8ba5e4d75e27d15b3311
xen0n pushed a commit to xen0n/go that referenced this issue Mar 9, 2023
…ns on loong64

Updates golang#53301
Updates golang#58784

Change-Id: Ifcb40871f609531dfd8b568db9ac14da9b451742
xen0n pushed a commit to xen0n/go that referenced this issue Mar 9, 2023
Updates golang#53301
Updates golang#58784

Change-Id: I4b726b0cc09e5e008b92b3e0a8a7bdd103b062c4
xen0n pushed a commit to xen0n/go that referenced this issue Mar 9, 2023
Updates golang#53301
Updates golang#58784

Change-Id: I4e0be140a71b86f4626ed39d76cf3ac78f842018
xen0n pushed a commit to xen0n/go that referenced this issue Mar 9, 2023
Updates golang#53301
Updates golang#58784

Change-Id: I68357e420f0920d6609d399cee40cd44af018385
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
These c-shared related CLs are follow up of CLs 455016, 455017, 455018. Here we
follow the LoongArch ELF psABI v2 standard, which requires the support of the
PCALAU12I instruction.

Updates golang#53301
Updates golang#58784

Change-Id: I7f1ddbf3b2470d610f12069d147aa9b3a6a96f32
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
Updates golang#53301
Updates golang#58784

Change-Id: I78a90155b17d7d8be04e8ba5e4d75e27d15b3311
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
…ns on loong64

Updates golang#53301
Updates golang#58784

Change-Id: Ifcb40871f609531dfd8b568db9ac14da9b451742
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
Updates golang#53301
Updates golang#58784

Change-Id: I4b726b0cc09e5e008b92b3e0a8a7bdd103b062c4
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
…ture and test on loong64

Linux kernel on loong64 has no Dup2 syscall support, so we use Dup3 to replace it like arm64 and riscv64.

Updates golang#53301
Updates golang#58784

Change-Id: I4e0be140a71b86f4626ed39d76cf3ac78f842018
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
These c-shared related CLs are follow up of CLs 455016, 455017, 455018. Here we
follow the LoongArch ELF psABI v2 standard, which requires the support of the
PCALAU12I instruction.

Updates golang#53301
Updates golang#58784

Change-Id: I7f1ddbf3b2470d610f12069d147aa9b3a6a96f32
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
Updates golang#53301
Updates golang#58784

Change-Id: I78a90155b17d7d8be04e8ba5e4d75e27d15b3311
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
…ture and test on loong64

Linux kernel on loong64 has no Dup2 syscall support, so we use Dup3 to replace it like arm64 and riscv64.

Updates golang#53301
Updates golang#58784

Change-Id: I4e0be140a71b86f4626ed39d76cf3ac78f842018
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
These c-shared related CLs are follow up of CLs 455016, 455017, 455018. Here we
follow the LoongArch ELF psABI v2 standard, which requires the support of the
PCALAU12I instruction.

Updates golang#53301
Updates golang#58784

Change-Id: I7f1ddbf3b2470d610f12069d147aa9b3a6a96f32
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
Updates golang#53301
Updates golang#58784

Change-Id: I78a90155b17d7d8be04e8ba5e4d75e27d15b3311
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
…ns on loong64

Updates golang#53301
Updates golang#58784

Change-Id: Ifcb40871f609531dfd8b568db9ac14da9b451742
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
Updates golang#53301
Updates golang#58784

Change-Id: I4b726b0cc09e5e008b92b3e0a8a7bdd103b062c4
xen0n pushed a commit to xen0n/go that referenced this issue Mar 24, 2023
…ture and test on loong64

Linux kernel on loong64 has no Dup2 syscall support, so we use Dup3 to replace it like arm64 and riscv64.

Updates golang#53301
Updates golang#58784

Change-Id: I4e0be140a71b86f4626ed39d76cf3ac78f842018
xen0n pushed a commit to xen0n/go that referenced this issue Mar 31, 2023
These c-shared related CLs are follow up of CLs 455016, 455017, 455018. Here we
follow the LoongArch ELF psABI v2 standard, which requires the support of the
PCALAU12I instruction.

Updates golang#53301
Updates golang#58784

Change-Id: I7f1ddbf3b2470d610f12069d147aa9b3a6a96f32
xen0n pushed a commit to xen0n/go that referenced this issue Mar 31, 2023
Updates golang#53301
Updates golang#58784

Change-Id: I78a90155b17d7d8be04e8ba5e4d75e27d15b3311
xen0n pushed a commit to xen0n/go that referenced this issue Mar 31, 2023
…ns on loong64

Updates golang#53301
Updates golang#58784

Change-Id: Ifcb40871f609531dfd8b568db9ac14da9b451742
xen0n pushed a commit to xen0n/go that referenced this issue Mar 31, 2023
Updates golang#53301
Updates golang#58784

Change-Id: I4b726b0cc09e5e008b92b3e0a8a7bdd103b062c4
xen0n pushed a commit to xen0n/go that referenced this issue Mar 31, 2023
…ture and test on loong64

Linux kernel on loong64 has no Dup2 syscall support, so we use Dup3 to replace it like arm64 and riscv64.

Updates golang#53301
Updates golang#58784

Change-Id: I4e0be140a71b86f4626ed39d76cf3ac78f842018
gopherbot pushed a commit that referenced this issue Apr 10, 2023
These c-shared related CLs are follow up of CLs 455016, 455017, 455018. Here we
follow the LoongArch ELF psABI v2 standard, which requires the support of the
PCALAU12I instruction.

Updates #53301
Updates #58784

Change-Id: I7f1ddbf3b2470d610f12069d147aa9b3a6a96f32
Reviewed-on: https://go-review.googlesource.com/c/go/+/425474
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
xen0n pushed a commit to xen0n/go that referenced this issue Apr 10, 2023
These c-shared related CLs are follow up of CLs 455016, 455017, 455018. Here we
follow the LoongArch ELF psABI v2 standard, which requires the support of the
PCALAU12I instruction.

Updates golang#53301
Updates golang#58784

Change-Id: I7f1ddbf3b2470d610f12069d147aa9b3a6a96f32
xen0n pushed a commit to xen0n/go that referenced this issue Apr 10, 2023
…ns on loong64

Updates golang#53301
Updates golang#58784

Change-Id: Ifcb40871f609531dfd8b568db9ac14da9b451742
gopherbot pushed a commit that referenced this issue Apr 11, 2023
…for --buildmode=c-shared on loong64

Updates #53301
Updates #58784

Change-Id: Ifcb40871f609531dfd8b568db9ac14da9b451742
Reviewed-on: https://go-review.googlesource.com/c/go/+/425476
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: WANG Xuerui <git@xen0n.name>
gopherbot pushed a commit that referenced this issue Apr 12, 2023
…ture and test on loong64

Linux kernel on loong64 has no Dup2 syscall support, so we use Dup3 to replace it like arm64 and riscv64.

Updates #53301
Fixes #58784

Change-Id: I4e0be140a71b86f4626ed39d76cf3ac78f842018
Reviewed-on: https://go-review.googlesource.com/c/go/+/425478
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
xen0n pushed a commit to xen0n/go that referenced this issue May 1, 2023
These c-shared related CLs are follow up of CLs 455016, 455017, 455018. Here we
follow the LoongArch ELF psABI v2 standard, which requires the support of the
PCALAU12I instruction.

Updates golang#53301
Updates golang#58784

Change-Id: I7f1ddbf3b2470d610f12069d147aa9b3a6a96f32
Reviewed-on: https://go-review.googlesource.com/c/go/+/425474
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 80eeec6)
xen0n pushed a commit to xen0n/go that referenced this issue May 1, 2023
…, cmd/link: add support for --buildmode=c-shared on loong64

Updates golang#53301
Updates golang#58784

Change-Id: Ifcb40871f609531dfd8b568db9ac14da9b451742
Reviewed-on: https://go-review.googlesource.com/c/go/+/425476
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: WANG Xuerui <git@xen0n.name>
(cherry picked from commit 1f908bd)
xen0n pushed a commit to xen0n/go that referenced this issue May 1, 2023
…red: enable c-shared feature and test on loong64

Linux kernel on loong64 has no Dup2 syscall support, so we use Dup3 to replace it like arm64 and riscv64.

Updates golang#53301
Fixes golang#58784

Change-Id: I4e0be140a71b86f4626ed39d76cf3ac78f842018
Reviewed-on: https://go-review.googlesource.com/c/go/+/425478
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
(cherry picked from commit b3a194a)
@gopherbot
Copy link

Change https://go.dev/cl/507815 mentions this issue: doc/go1.21: add release notes for linux/loong64

@abner-chenc abner-chenc modified the milestones: Unplanned, Go1.21 Jul 7, 2023
@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 Jul 7, 2023
@gopherbot
Copy link

Change https://go.dev/cl/510916 mentions this issue: [release-branch.go1.21] doc/go1.21: add release notes for linux/loong64

gopherbot pushed a commit that referenced this issue Jul 19, 2023
Fixes #53301

Change-Id: Id447d57d43b12c3748267295928d45a089549340
Reviewed-on: https://go-review.googlesource.com/c/go/+/507815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 7007271)
Reviewed-on: https://go-review.googlesource.com/c/go/+/510916
Reviewed-by: Heschi Kreinick <heschi@google.com>
bradfitz pushed a commit to tailscale/go that referenced this issue Aug 2, 2023
Fixes golang#53301

Change-Id: Id447d57d43b12c3748267295928d45a089549340
Reviewed-on: https://go-review.googlesource.com/c/go/+/507815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 7007271)
Reviewed-on: https://go-review.googlesource.com/c/go/+/510916
Reviewed-by: Heschi Kreinick <heschi@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-loong64 Issues solely affecting the loongson architecture. compiler/runtime Issues related to the Go compiler and/or runtime. FeatureRequest NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

9 participants