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

net: sendfile needs -lsendfile for external linker on Solaris #12390

Closed
mamash opened this issue Aug 28, 2015 · 9 comments

Comments

Projects
None yet
7 participants
@mamash
Copy link

commented Aug 28, 2015

With Go 1.5.0 on SunOS/amd64 (namely SmartOS), packages employing the external linker and net/* packages (e.g. CouchBase or github.com/mongodb/mongo-tools) will fail due to an undefined 'sendfile' symbol.

The following patch (from pkgsrc's package for go-1.5.0) works around the problem:

https://github.com/jsonn/pkgsrc/blob/37075a88350da1870518cdd61bd6609bbf1c16c5/lang/go/patches/patch-src_net_sendfile__solaris.go

Steps to repeat:

git clone https://github.com/mongodb/mongo-tools
cd mongo-tools
. ./set_gopath.sh
mkdir bin
go build -o bin/mongoimport -tags sasl mongoimport/main/mongoimport.go

Output:

# command-line-arguments
/opt/local/go/pkg/tool/solaris_amd64/link: running gcc failed: exit status 1
Undefined                       first referenced
 symbol                             in file
sendfile                            /tmp/go-link-666650609/go.o
ld: fatal: symbol referencing errors. No output written to $WORK/command-line-arguments/_obj/exe/a.out
collect2: error: ld returned 1 exit status

@bradfitz bradfitz changed the title SunOS sendfile support needs -lsendfile for external linker net: SunOS sendfile support needs -lsendfile for external linker Aug 28, 2015

@bradfitz bradfitz added the OS-Solaris label Aug 28, 2015

@bradfitz bradfitz added this to the Go1.6 milestone Aug 28, 2015

@4ad 4ad changed the title net: SunOS sendfile support needs -lsendfile for external linker net: sendfile needs -lsendfile for external linker on Solaris Aug 28, 2015

@minux

This comment has been minimized.

Copy link
Member

commented Aug 29, 2015

@4ad 4ad modified the milestones: Go1.5.1, Go1.6 Aug 29, 2015

@4ad

This comment has been minimized.

Copy link
Member

commented Aug 29, 2015

I don't understand why we need -lsendfile, but not, say, -lsocket.

@minux

This comment has been minimized.

Copy link
Member

commented Aug 29, 2015

@4ad

This comment has been minimized.

Copy link
Member

commented Aug 30, 2015

Sounds better.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Aug 30, 2015

@minux cgo_import_dynamic is a directive for internal linking mode. I'm not sure it makes sense for it to affect how the external linker is used. Passing flags to the external linker seems more a job for cgo LDFLAGS or //go:cgo_ldflag.

@gopherbot

This comment has been minimized.

Copy link

commented Aug 30, 2015

CL https://golang.org/cl/14072 mentions this issue.

@minux minux closed this in 5f2c420 Aug 30, 2015

@mamash

This comment has been minimized.

Copy link
Author

commented Aug 31, 2015

Thanks, guys, confirming the problem to be fixed.

@binarycrusader

This comment has been minimized.

Copy link
Contributor

commented Aug 31, 2015

For the record, libsocket, libnsl, and libsendfile may be filter libraries in a future release of Solaris -- typically such libraries are merged into libc. So this change won't cause any problems, as the filter libraries will provide the necessary symbol compatibility, but is unnecessary starting with a future release:

https://blogs.oracle.com/rie/entry/shared_object_filters
http://docs.oracle.com/cd/E36784_01/html/E36857/chapter4-4.html

@gopherbot

This comment has been minimized.

Copy link

commented Sep 3, 2015

CL https://golang.org/cl/14246 mentions this issue.

minux added a commit that referenced this issue Sep 3, 2015

[release-branch.go1.5] net: add -lsendfile to cgo LDFLAGS for solaris
Fixes external linking of net/http tests (or anything that uses
sendfile).

Fixes #12390.

Change-Id: Iee08998cf66e7b0ce851db138a00ebae6dc2395e
Reviewed-on: https://go-review.googlesource.com/14072
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-on: https://go-review.googlesource.com/14246
Run-TryBot: Chris Broadfoot <cbro@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>

@golang golang locked and limited conversation to collaborators Sep 4, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.