libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Libtool sysroot RPATH problems


From: Richard Purdie
Subject: Libtool sysroot RPATH problems
Date: Tue, 11 Jan 2011 23:06:13 +0000

Hi,

I work on OpenEmbedded/Poky and we're been experimenting with the recent
libtool sysroot support. To say I'm pleased to have this is an
understatement! We're having a few problems around incorrect RPATHs
being encoded into libraries however.

Firstly, for the first time ever for us, it appears libtool is no longer
relinking our libraries at install time. This is welcome as we're cross
compiling to a sysroot and we'd never want to actually run them in situ
so this could probably save us some build time. It does however mean we
never go for a relink step so we're hitting codepaths and issues that
I've never seen. For reference, we always used to set installed="no" in
our "staged" libraries prior to sysroot support since this let us hack
around the lack of sysroot support easier.

Anyhow, the problem I'm seeing is that the final library has an RPATH
including the sysroot prefix when make is calling libtool with
-rpath /usr/lib at link time. I looked at the code in ltmain.m4sh
starting at line 7240 (see the end of the email for a quotation) and
firstly, I don't understand why the func_replace_sysroot call is inside
the $hardcode_libdir_separator test? Surely it should be outside it and
happen whenever $hardcode_libdir_flag_spec is set?

Changing that helps a bit and I end up with an RPATH of "=/usr/lib" so
the sysroot prefix is gone but the "=" is there. I suspect that isn't
valid so I added the following code after the func_replace_sysroot call

func_stripname '=' '' "$libdir"
libdir=$func_stripname_result

and then I get an RPATH of "/usr/lib" which is ok to a point.

Of course this is listed in $sys_lib_dlsearch_path_spec so shouldn't be
getting added at all. Its coming to this function via $compile_rpath
which is being set around line 5939 which in turn is coming from absdir.
absdir is being compared against $sys_lib_dlsearch_path_spec but without
adding/removing any sysroot prefixes.

I'd really therefore like to ask what behaviour to be expecting from
libtool before I try and write patches to fix any of this. To summarise
some of my questions:

a) If I'm using a sysroot can I expect to install without a relink step 
   (I hope so!)
b) I couldn't see a function to add/prepend a sysroot without a = in 
   there. I assume given these usecases we should add one?
c) An RPATH starting with an "=" is invalid, correct?
d) Should the absdir comparisions with sys_lib_dlsearch_path_spec have 
   the sysroot stripped? Are there other rpath variables that need this 
   treatment when comparing to sys_lib_dlsearch_path_spec?
e) The sysroot treatment should apply whenever 
   $hardcode_libdir_flag_spec is set and not on 
   $hardcode_libdir_separator?

If someone could explain the correct behaviour I might be able to come
up with some patches to help fix things! :)

Cheers,

Richard

http://git.savannah.gnu.org/cgit/libtool.git/tree/libltdl/config/ltmain.m4sh?id=9167aecabd12c5afe7a65d45dc73f8c92ab42f05
line 7240:
      # Test again, we may have decided not to build it any more
      if test "$build_libtool_libs" = yes; then
        # Remove ${wl} instances when linking with ld.
        # FIXME: should test the right _cmds variable.
        case $archive_cmds in
          *\$LD\ *) wl= ;;
        esac
        if test "$hardcode_into_libs" = yes; then
          # Hardcode the library paths
          hardcode_libdirs=
          dep_rpath=
          rpath="$finalize_rpath"
          test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
          for libdir in $rpath; do
            if test -n "$hardcode_libdir_flag_spec"; then
              if test -n "$hardcode_libdir_separator"; then
                func_replace_sysroot "$libdir"
                libdir=$func_replace_sysroot_result
                if test -z "$hardcode_libdirs"; then
                  hardcode_libdirs="$libdir"
line 5929:
          if test "$linkmode" = lib &&
             test "$hardcode_into_libs" = yes; then
            # Hardcode the library path.
            # Skip directories that are in the system default run-time
            # search path.
            case " $sys_lib_dlsearch_path " in
            *" $absdir "*) ;;
            *)
              case "$compile_rpath " in
              *" $absdir "*) ;;
              *) func_append compile_rpath " $absdir" ;;
              esac
              ;;
            esac




reply via email to

[Prev in Thread] Current Thread [Next in Thread]