Description
I'm having trouble linking a Rust program to a non-position-independent C library. When I manually remove the -pie
flag from the ld step that rustc runs, everything works correctly. I think that -C relocation-model=dynamic-no-pic
should remove the -pie
flag for me, but it doesn't.
Here's what I think is going on:
When I run
strace -s 300 -e execve -f rustup run nightly rustc hello.rs -v -C relocation-model=dynamic-no-pic
It runs ld with the -pie
flag:
execve("/usr/bin/ld", ["/usr/bin/ld", "-pie"
But when I read the rustc code here, it seems like the intention is that -pie
should only be passed to ld when relocation-model=pic
. That is, if we're not compiling a position independent executable, then we should not pass the position independent executable -pie
flag to ld.
I think what may be happening here is that somehow the defaults from
rust/src/librustc_back/target/mod.rs
Line 315 in 5229e0e
This happens with stable and also the nightly I tried:
rustc 1.12.0-nightly (9316ae515 2016-07-24)
binary: rustc
commit-hash: 9316ae515e2f8f3f497fb4f1559910c1eef2433d
commit-date: 2016-07-24
host: x86_64-unknown-linux-gnu
release: 1.12.0-nightly