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

x/net: please implement recvmsg and sendmsg under gccgo #52512

Closed
jech opened this issue Apr 23, 2022 · 9 comments
Closed

x/net: please implement recvmsg and sendmsg under gccgo #52512

jech opened this issue Apr 23, 2022 · 9 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jech
Copy link

jech commented Apr 23, 2022

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

$ go-11 version
go version go1.16.5 gccgo (Debian 11.2.0-20) 11.2.0 linux/amd64

Does this issue reproduce with the latest release?

Yes (gccgo 12-20220319-1, as shipped by Debian).

What operating system and processor architecture are you using (go env)?

go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jch/.cache/go-build"
GOENV="/home/jch/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/jch/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/jch/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/gcc/x86_64-linux-gnu/11"
GOVCS=""
GOVERSION="go1.16.5 gccgo (Debian 11.2.0-20) 11.2.0"
GCCGO="/usr/bin/x86_64-linux-gnu-gccgo-11"
AR="ar"
CC="x86_64-linux-gnu-gcc-11"
CXX="x86_64-linux-gnu-g++-11"
CGO_ENABLED="1"
GOMOD="/home/jch/go/src/github.com/jech/galene/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/goild383537842=/tmp/go-build -gno-record-gcc-switches -funwind-tables"

What did you do?

git clone https://github.com/jech/galene
cd galene
go-11 build

What did you expect to see?

Build success.

What did you see instead?

$ go-11 build
# github.com/jech/galene
/usr/bin/ld: /home/jch/.cache/go-build/52/5228351bb25e08cdacb62b029a4fedd8aab4843fc74cbe78b772d49220892d5c-d(_go_.o): in function `golang_0org_1x_1net_1internal_1socket.Conn.recvMsg..func1':
/home/jch/go/pkg/mod/golang.org/x/net@v0.0.0-20220421235706-1d1ef9303861/internal/socket/sys_unix.go:38: undefined reference to `syscall.recvmsg'
/usr/bin/ld: /home/jch/.cache/go-build/52/5228351bb25e08cdacb62b029a4fedd8aab4843fc74cbe78b772d49220892d5c-d(_go_.o): in function `golang_0org_1x_1net_1internal_1socket.Conn.sendMsg..func1':
/home/jch/go/pkg/mod/golang.org/x/net@v0.0.0-20220421235706-1d1ef9303861/internal/socket/sys_unix.go:42: undefined reference to `syscall.sendmsg'
collect2: error: ld returned 1 exit status
@gopherbot gopherbot modified the milestones: Unreleased, Gccgo Apr 23, 2022
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 28, 2022
@cagedmantis
Copy link
Contributor

/cc @ianlancetaylor

@eat-swap
Copy link

eat-swap commented May 9, 2022

It seems that various of system calls were not implemented. Same and some similar errors can be reproduced using the most recent gccgo (12.1 release).

When trying to build Caddy with gccgo, the mentioned error could be reproduced:

$ go build -o ~/build/bin/caddy

# github.com/yuin/goldmark/util
/root/go/pkg/mod/github.com/yuin/goldmark@v1.4.8/util/html5entities.go: In function ‘github_0com_1yuin_1goldmark_1util..import’:
/root/go/pkg/mod/github.com/yuin/goldmark@v1.4.8/util/html5entities.go:1:1: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
    1 | package util
      | ^
# github.com/caddyserver/caddy/v2/cmd/caddy
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o): in function `golang_0org_1x_1sys_1unix.RawSyscallNoError':
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:48: undefined reference to `golang_0org_1x_1sys_1unix.realSyscallNoError'
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o): in function `golang_0org_1x_1sys_1unix.SyscallNoError':
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:21: undefined reference to `golang_0org_1x_1sys_1unix.realSyscallNoError'
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o): in function `golang_0org_1x_1sys_1unix.Syscall':
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:28: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o): in function `golang_0org_1x_1sys_1unix.Syscall6':
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:35: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o): in function `golang_0org_1x_1sys_1unix.Syscall9':
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:42: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o): in function `golang_0org_1x_1sys_1unix.RawSyscall':
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:53: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o): in function `golang_0org_1x_1sys_1unix.RawSyscall6':
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:58: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o): in function `golang_0org_1x_1sys_1unix.SyscallNoError':
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:21: undefined reference to `golang_0org_1x_1sys_1unix.realSyscallNoError'
/usr/bin/ld: /root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:21: undefined reference to `golang_0org_1x_1sys_1unix.realSyscallNoError'
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o): in function `golang_0org_1x_1sys_1unix.RawSyscall6':
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:58: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:58: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:58: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o): in function `golang_0org_1x_1sys_1unix.RawSyscallNoError':
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:48: undefined reference to `golang_0org_1x_1sys_1unix.realSyscallNoError'
/usr/bin/ld: /root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:48: undefined reference to `golang_0org_1x_1sys_1unix.realSyscallNoError'
/usr/bin/ld: /root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:48: undefined reference to `golang_0org_1x_1sys_1unix.realSyscallNoError'
/usr/bin/ld: /root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:48: undefined reference to `golang_0org_1x_1sys_1unix.realSyscallNoError'
/usr/bin/ld: /root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:48: undefined reference to `golang_0org_1x_1sys_1unix.realSyscallNoError'
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o):/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:48: more undefined references to `golang_0org_1x_1sys_1unix.realSyscallNoError' follow
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o): in function `golang_0org_1x_1sys_1unix.Syscall6':
/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:35: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:35: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:35: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:35: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:35: undefined reference to `golang_0org_1x_1sys_1unix.realSyscall'
/usr/bin/ld: /root/.cache/go-build/40/40e4efeceabe8caf9296c8402f19f610df3f3d8aa148d34f3ad9ab11b0ddbf4f-d(_go_.o):/root/go/pkg/mod/golang.org/x/sys@v0.0.0-20220209214540-3681064d5158/unix/gccgo.go:35: more undefined references to `golang_0org_1x_1sys_1unix.realSyscall' follow
/usr/bin/ld: /root/.cache/go-build/ec/ec7e9a7fec808c24bc4c1ebe49858204ccba78ad8fe93d1b68dbccfef69b19c1-d(_go_.o): in function `golang_0org_1x_1net_1internal_1socket.Conn.recvMsg..func1':
/root/go/pkg/mod/golang.org/x/net@v0.0.0-20220127200216-cd36cc0744dd/internal/socket/sys_unix.go:38: undefined reference to `syscall.recvmsg'
/usr/bin/ld: /root/.cache/go-build/ec/ec7e9a7fec808c24bc4c1ebe49858204ccba78ad8fe93d1b68dbccfef69b19c1-d(_go_.o): in function `golang_0org_1x_1net_1internal_1socket.Conn.sendMsg..func1':
/root/go/pkg/mod/golang.org/x/net@v0.0.0-20220127200216-cd36cc0744dd/internal/socket/sys_unix.go:42: undefined reference to `syscall.sendmsg'
collect2: error: ld returned 1 exit status

For your information, go and gccgo versions are:

$ go version
go version unknown linux/amd64
$ gccgo --version
gccgo (GCC) 12.1.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thanks for your effort in investigating into this problem.

@ianlancetaylor
Copy link
Contributor

ianlancetaylor commented May 13, 2022

I can't recreate the problems with golang.org/x/sys/unix.

The problems with golang.org/x/net will require some updates to that package. It is using go:linkname in a way that works with the gc compiler but not with gccgo.

@ianlancetaylor
Copy link
Contributor

I wrote proposal #52885 as a step toward cleaning this up.

@marcrittinghaus
Copy link

Hi @ianlancetaylor,
as your proposal has been accepted, is there any way to fix this now?

@ianlancetaylor
Copy link
Contributor

It should now be possible to rewrite the code in x/net to call unix.RecvmsgBuffers and unix.SendmsgBuffers. I haven't gotten around to doing that. Please feel free to take a look yourself, though.

@marcrittinghaus
Copy link

I am working on a project where we port a larger GO application to a different platform and use gccgo for that purpose. For now, I stubbed the calls as the functionality might actually not needed. If I run into troubles, I will look into this! Thanks for the info!

@gopherbot
Copy link

Change https://go.dev/cl/419175 mentions this issue: internal/socket: support building with gccgo

@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 25, 2022
@jech
Copy link
Author

jech commented Aug 4, 2022

@ianlancetaylor Thanks a lot, that's appreciated.

WeiminShang added a commit to WeiminShang/net that referenced this issue Nov 16, 2022
Update x/sys to permit calling RecvmsgBuffers and SendmsgBuffers.

The zos changes are wholly untested.

Fixes golang/go#52512

Change-Id: I8fae9f4db2e0b83c99a7c0f3cadc83b5868683e6
Reviewed-on: https://go-review.googlesource.com/c/net/+/419175
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
@golang golang locked and limited conversation to collaborators Aug 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants