I think we can just ingnore the "-rpath-link" option. And that can be considered as expected implementation.
My arguments for that below.
Consider we have following sources:
shared2.cpp:
int B() { return 0; }
shared.cpp:
int B(); int A() { return B(); }
main.cpp:
int A(); int main() { return A(); }
- If I link this using bfd (from path /home/umb/tests/59rpath), I get an error:
/home/umb/LLVM/build/bin/clang -shared -fuse-ld=bfd -fPIC shared2.cpp -o shared2.so
/home/umb/LLVM/build/bin/clang -shared -fuse-ld=bfd -fPIC shared.cpp shared2.so -o shared.so
/home/umb/LLVM/build/bin/clang -fuse-ld=bfd main.cpp shared.so -o test
++ /home/umb/LLVM/build/bin/clang -fuse-ld=bfd main.cpp shared.so -o test
/usr/local/bin/ld.bfd: warning: ./shared/shared2.so, needed by shared.so, not found (try using -rpath or -rpath-link)
shared.so: undefined reference to `B()'
clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation)
- When I add the -rpath-link to commandline, it links fine as expected:
/home/umb/LLVM/build/bin/clang -shared -fuse-ld=bfd -fPIC shared2.cpp -o shared2.so
/home/umb/LLVM/build/bin/clang -shared -fuse-ld=bfd -fPIC shared.cpp shared2.so -o shared.so
/home/umb/LLVM/build/bin/clang -fuse-ld=bfd main.cpp shared.so -o test -Wl,-rpath-link,/home/umb/tests/59rpath
<no errors here>
- But at the same time if I link the same using gold then with or without -rpath-link, it is also fine for me.
/home/umb/LLVM/build/bin/clang -shared -fuse-ld=gold -fPIC shared2.cpp -o shared2.so
/home/umb/LLVM/build/bin/clang -shared -fuse-ld=gold -fPIC shared.cpp shared2.so -o shared.so
/home/umb/LLVM/build/bin/clang -fuse-ld=gold main.cpp shared.so -o test
<no errors here>
/home/umb/LLVM/build/bin/clang -shared -fuse-ld=gold -fPIC shared2.cpp -o shared2.so
/home/umb/LLVM/build/bin/clang -shared -fuse-ld=gold -fPIC shared.cpp shared2.so -o shared.so
/home/umb/LLVM/build/bin/clang -fuse-ld=gold main.cpp shared.so -o test -Wl,-rpath-link,/home/umb/tests/59rpath
<no errors here>
So I think we can ignore that in the same way as gold do. And that is 'natural' support in lld. I mean 'natural' is that we do not change anything
to have the same behavior.