-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/link: wrong dynamic linker path when cross-compiling to OpenBSD #47760
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
Comments
Untested, but building from Linux using
may workaround this issue. |
This might be broken in general, and not specific to OpenBSD linking. From OpenBSD, if I target illumos (because illumos builds also require dynamic linking, and they use the ELF format), it is using the openbsd dynamic linker path /usr/libexec/ld.so:
The
|
Interesting. I cross-compile from macOS and do not get the same behavior. I think it might have something to do with make.bash now set GO_LDSO more aggressively. @ston1th how do you install Go 1.17? Download from https://golang.org/dl or build from source? Thanks. |
Maybe we should ignore GO_LDSO if GOOS/GOARCH is not the same as host (but what happens with cross-compiling to a different machine with same architecture/OS?) Maybe we should use GO_LDSO only on Linux? |
Cross compiling a PIE for Linux from OpenBSD also has the same issue. |
Change https://golang.org/cl/343010 mentions this issue: |
@gopherbot please backport this to Go 1.17. This is a regression. Thanks. |
Backport issue(s) opened: #47782 (for 1.17). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
Change https://golang.org/cl/343309 mentions this issue: |
GO_LDSO is a setting that is set when the toolchain is build. It only makes sense to use it on the host platform. Do not use it when targetting a different platform. In the past it was not a problem as GO_LDSO was almost always unset. Now, with CL 301989 it is almost always set (maybe we want to revisit it). Updates #47760. Fixes #47782. Change-Id: I2704b9968781f46e2d2f8624090db19689b1a32f Reviewed-on: https://go-review.googlesource.com/c/go/+/343010 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> (cherry picked from commit ddfcc02) Reviewed-on: https://go-review.googlesource.com/c/go/+/343309
What version of Go are you using (
go version
)?What did you do?
https://play.golang.org/p/HmnNoBf0p1z
I have cross compiled the above playground link from linux/amd64 to openbsd/amd64 using the following command:
The resulting binary is not runnable on OpenBSD since the interpreter path has changed to a non-existing path:
The path
/lib64/ld-linux-x86-64.so.2
does not exist on OpenBSD - it should be/usr/libexec/ld.so
Here I'm trying to run the file on OpenBSD:
What did you expect to see?
Using go version
1.16.7
the interpreter path is the correct one (/usr/libexec/ld.so
):There is a workaround to run these programs on OpenBSD. One needs to create the
/lib64
directory and in there a symlink to/usr/libexec/ld.so
:After this is done the
ldd
command on OpenBSD works again:And so does running the program:
The text was updated successfully, but these errors were encountered: