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/link: doesn't propagate -I flags to the external linker #22446

Open
benjaminp opened this Issue Oct 26, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@benjaminp

benjaminp commented Oct 26, 2017

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 from link doesn't propogate -I flags to the external linker to cmd/link: doesn't propogate -I flags to the external linker Oct 26, 2017

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Oct 26, 2017

@ALTree ALTree changed the title from cmd/link: doesn't propogate -I flags to the external linker to cmd/link: doesn't propagate -I flags to the external linker Oct 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment