BUILD_SHARED_LIBS build

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Nov 5 08:38:25 PST 2014


Adding llvm-commits. This is a summary about using PRIVATE for share
libraries when building with cmake (see attached patch).

On 5 November 2014 10:37, NAKAMURA Takumi <geek4civic at gmail.com> wrote:
> I wonder it would work on darwin.
>
> On my hosts, it doesn't work since ld won't seek $ORIGIN. It's the
> reason why I add -rpath-link.

The static linker should not read $ORIGIN. In fact, it should never
follow the dt_needed of a shared library. bfd ld is just broken.

To see it, try linking  bin/llvm-readobj. I will fail with bfd ld
because it will try to find libLLVMAnalysis.so which is used by
lib/libLLVMAArch64CodeGen.so, but it has *no* business in finding such
a library. lib/libLLVMAArch64CodeGen.so already exists, just use it.
The very same link works with gold.

The reduced testcase is attached. Build it with

gcc test3.c -fPIC -shared -o test3.so
gcc test2.c -fPIC -shared -o test2.so test3.so
gcc test.c -o test test2.so -fuse-ld=gold # works
gcc test.c -o test test2.so -fuse-ld=bfd #fails

Maybe we should just require a non-broken linker for BUILD_SHARED_LIBS?

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.c
Type: text/x-csrc
Size: 40 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141105/47e08ee7/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.c
Type: text/x-csrc
Size: 38 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141105/47e08ee7/attachment-0001.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test3.c
Type: text/x-csrc
Size: 17 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141105/47e08ee7/attachment-0002.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: text/x-patch
Size: 900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141105/47e08ee7/attachment.bin>


More information about the llvm-commits mailing list