Re: Passing LD_RUN_PATH through to the linker

Tim Rice <[email protected]> Thu, 15 Dec 2022 11:08:09 -0800 (PST)
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <alpine.UW2.2.11.2212151050020.13544@server01.int.multitalents.net>
Kevin,

On Wed, 14 Dec 2022, Kevin R. Bulgrien wrote:

> During attempts to build top-of-tree libssh2 on a dinosaur (SCO OpenServer 5.0.7),
> an issue with loading indirect dependencies of libssh2.so is occurring.  They can
> be worked around by setting LD_LIBRARY_PATH at run-time, however it seems much
> simpler to depend on DT_RPATH so the run-time environment does not require
> management.
> 
> The linker behaves as defined at the link following (ironically, more completely
> documented on this list than in the official documentation):
> 
>   https://lists.gnu.org/archive/html/bug-libtool/2002-08/msg00026.html
> 
[snip]
> 
> Can anyone offer a pointer on where to look in autotools/libtool structure
> to get DT_RPATH set in the linked binaries or comment on whether this is
> even an option with libtool?   I'm finding difficulty differentiating
> between -R and -rpath for libtool versus similar switches for ld.

On OpenServer, I usually just build with the SONAME being a full path name.

I am attaching a patch to the libtool 2.4.6 generated during
a libssh2-1.8.0 build.

Once all testing is complete, I do
......
rm src/libssh2.la
SCOABSPATH=1 ; export SCOABSPATH
gmake 2>&1 | tee x.log
......
then package.

Note: the last hunk is to address a regression introduced in 2.4.6
with the freebsd reorg.

-- 
Tim Rice				Multitalents
[email protected]
libtool-2.4.6-fullpath-soname.patch (text/plain, 1.5 KB)
--- libtool.old	2022-12-15 13:35:00.869441000 +0000
+++ libtool	2022-12-15 13:38:25.699441000 +0000
@@ -359,8 +359,8 @@
 old_archive_from_expsyms_cmds=""
 
 # Commands used to build a shared archive.
-archive_cmds="\$CC -G \$wl-h,\$soname -o \$lib \$libobjs \$deplibs \$compiler_flags"
-archive_expsym_cmds="\$CC -G \$wl-Bexport:\$export_symbols \$wl-h,\$soname -o \$lib \$libobjs \$deplibs \$compiler_flags"
+archive_cmds="\$CC -G \${wl}-h,\\\${SCOABSPATH:+\${install_libdir}/}\$soname -o \$lib \$libobjs \$deplibs \$compiler_flags"
+archive_expsym_cmds="\$CC -G \${wl}-Bexport:\$export_symbols \${wl}-h,\\\${SCOABSPATH:+\${install_libdir}/}\$soname -o \$lib \$libobjs \$deplibs \$compiler_flags"
 
 # Commands used to build a loadable module if different from building
 # a shared archive.
@@ -378,7 +378,7 @@
 
 # Flag to hardcode $libdir into a binary during linking.
 # This must work even if $libdir does not exist
-hardcode_libdir_flag_spec="\$wl-R,\$libdir"
+hardcode_libdir_flag_spec="\`test -z \"\$SCOABSPATH\" && echo -R\$libdir | sed 's|-R/opt/xinuos/lib | |'\`"
 
 # Whether we need a single "-rpath" flag with a separated argument.
 hardcode_libdir_separator=":"
@@ -7552,6 +7552,7 @@
 	;;
 
       -module)
+	unset SCOABSPATH
 	module=yes
 	continue
 	;;
@@ -9314,7 +9315,7 @@
 	    age=$number_minor
 	    revision=$number_revision
 	    ;;
-	  freebsd-aout|qnx|sunos)
+	  freebsd-aout|qnx|sco|sunos)
 	    current=$number_major
 	    revision=$number_minor
 	    age=0