rpaths in llvm binaries

Hello LLVM devs,

I am trying to package llvm for NetBSD. The package checker scripts are complaining about bad rpaths in the binaries. I see that they are relative to the build directory. I have no idea why that would be. Can you explain?

If I build as myself, for testing (e.g.):

$ readelf -d ~/downloads/llvm-2.6/Release/bin/llvm-ar

Dynamic section at offset 0x15af28 contains 25 entries:
  Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
0x00000001 (NEEDED) Shared library: [libm.so.0]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.12]
0x0000000f (RPATH) Library rpath: [/home/tim/downloads/llvm-2.6/Release/bin]
0x0000000c (INIT) 0x804dfe0
.............

As root, for packaging:

# readelf -d /usr/pkg/bin/llvm-ar

Dynamic section at offset 0x152028 contains 25 entries:
  Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libpthread.so.0]
0x00000001 (NEEDED) Shared library: [libstdc++.so.6]
0x00000001 (NEEDED) Shared library: [libm.so.0]
0x00000001 (NEEDED) Shared library: [libgcc_s.so.1]
0x00000001 (NEEDED) Shared library: [libc.so.12]
0x0000000f (RPATH) Library rpath: [/usr/pkg/lib:/usr/pkgsrc/wip/llvm/work.i386/llvm-2.6/Release/bin]
0x0000000c (INIT) 0x804e1c0
.......

In the latter case, it ought to find the binaries in /usr/pkg/lib and never need to worry about the second path, but that second (in the former case, only) path ought not be there anyway. Should it? Why would you include an rpath from the build directory?

Thanks,
Tim

PS Please cc me on replies.

"Larson, Timothy E." <TELarson@west.com> writes:

Hello LLVM devs,

I am trying to package llvm for NetBSD. The package checker scripts
are complaining about bad rpaths in the binaries. I see that they are
relative to the build directory. I have no idea why that would be.
Can you explain?

Are you using cmake for building LLVM?

If the answer is yes, please ask on the cmake mailing list.

Usually cmake sets the RPATH when building LLVM as shared objects. But
on my Linux box it does not set RPATH when building LLVM as static
libraries.

Are you using cmake for building LLVM?

If the answer is yes, please ask on the cmake mailing list.

Usually cmake sets the RPATH when building LLVM as shared objects. But
on my Linux box it does not set RPATH when building LLVM as static
libraries.

I do not have cmake installed - and when packaging for NetBSD (IIRC) you need to explicitly tell it that cmake is used, which I haven't done - so I'd have to answer "no".

I do see LIBS="$LIBS -L${llvm_cv_oppath} -Wl,-rpath,${llvm_cv_oppath}" in autoconf/configure.ac, and hardcode_libdir_flag_spec'${wl}-rpath ${wl}$libdir' and hardcode_libdir_flag_spec_ld='-rpath $libdir' in configure, though. Do these need to be there?

Tim

I didn't get any response, so asking again.

> Are you using cmake for building LLVM?
>
> If the answer is yes, please ask on the cmake mailing list.
>
> Usually cmake sets the RPATH when building LLVM as shared objects.
But
> on my Linux box it does not set RPATH when building LLVM as static
> libraries.

I do not have cmake installed - and when packaging for NetBSD (IIRC)
you need to explicitly tell it that cmake is used, which I haven't done
- so I'd have to answer "no".

I do see LIBS="$LIBS -L${llvm_cv_oppath} -Wl,-rpath,${llvm_cv_oppath}"
in autoconf/configure.ac, and hardcode_libdir_flag_spec'${wl}-rpath
${wl}$libdir' and hardcode_libdir_flag_spec_ld='-rpath $libdir' in
configure, though. Do these need to be there?

It seems to be explicitly asking for RPATHs, contrary to Oscar's experience. Am I misinterpreting this? Does RPATH really need to be set for this to work correctly? Why am I getting RPATH set to the build directory?

Thanks,
Tim