Skip to content

cmd/link: doesn't propagate -I flags to the external linker #22446

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

Closed
benjaminp opened this issue Oct 26, 2017 · 2 comments
Closed

cmd/link: doesn't propagate -I flags to the external linker #22446

benjaminp opened this issue Oct 26, 2017 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@benjaminp
Copy link
Contributor

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

1.9.2

Does this issue reproduce with the latest release?

yes

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

linux_amd64

The problem

When link decides to use an external linker, it turns the -r flags it received into -rpath flags for the external linker. However, it doesn't pass the -I flag through to the external linker:

$ cat main.go 
package main
func main() {}
$ $GOROOT/pkg/tool/linux_amd64/compile -shared -o main.o main.go
$ $GOROOT/pkg/tool/linux_amd64/link -I myrtld -r myrpath -buildmode pie -linkmode external -o main main.o
$ readelf -ld main | egrep interpreter\|RUNPATH\|PATH
      [Requesting program interpreter: myrtld]
 0x000000000000001d (RUNPATH)            Library runpath: [myrpath]
$ $GOROOT/pkg/tool/linux_amd64/link -I myrtld -r myrpath -buildmode pie -linkmode external -o main main.o
$ readelf -ld main | egrep interpreter\|RUNPATH\|PATH
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
 0x000000000000000f (RPATH)              Library rpath: [myrpath]

Also, --enable-new-dtags should probably be passed to external GNU ld-compatible linkers for better fidelity with the internal ELF linker.

@ianlancetaylor ianlancetaylor changed the title link doesn't propogate -I flags to the external linker cmd/link: doesn't propogate -I flags to the external linker Oct 26, 2017
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 26, 2017
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Oct 26, 2017
@ianlancetaylor ianlancetaylor added the Suggested Issues that may be good for new contributors looking for work to do. label Oct 26, 2017
@ALTree ALTree changed the title cmd/link: doesn't propogate -I flags to the external linker cmd/link: doesn't propagate -I flags to the external linker Oct 26, 2017
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/310349 mentions this issue: cmd/link: convert -I foo to -Wl,--dynamic-linker,foo when externally linking

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/341332 mentions this issue: doc/go1.17: linker passes -I to extld as -Wl,--dynamic-linker

gopherbot pushed a commit that referenced this issue Aug 11, 2021
For #22446

Change-Id: I71a30761a28e81c50b7089d5a28be99c736c2dc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/341332
Trust: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
TryBot-Result: Go Bot <[email protected]>
@golang golang locked and limited conversation to collaborators Aug 11, 2022
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. Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

3 participants