libtool
[Top][All Lists]
Advanced

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

Re: Q: Forcing a -Wl,-rpath arg to static lib users


From: Oleg Smolsky
Subject: Re: Q: Forcing a -Wl,-rpath arg to static lib users
Date: Wed, 16 Nov 2022 14:00:04 -0800



On Mon, Nov 14, 2022 at 8:36 PM Oleg Smolsky <osmolsky@netskope.com> wrote:
Hello folks! I've been using libtool (via autotools) for a while, but have been unable to find a clean solution to the following problem:

I have a static `liblocal.la` (built in my build system) that links to a third-party shared lib. Obviously I can use my own lib to express that dependency:

liblocal_la_LIBADD = -lexternal -L/somewhere/lib

The missing bit of functionality is -Wl,-rpath,/somewhere/lib that I need to impose onto the leaf-level executables that link my local lib. Unfortunately these attempts do not work:
 1. Cannot add that flag to _LIBADD as libtool complains: "...belong in 'liblocal_la_LDFLAGS"
 2. Cannot add that flag to _LDFLAGS as it does not carry all the way to the leaf-level executable

I have found that I can manually jam the flag into the `inherited_linker_flags` variable inside the .la file and that gives me the desired result... but I don't know how to do that via Makefile.am.

...and I found a hack that lets me jam these flags into the `inherited_linker_flags` variable. Here is a patch for the `libtool` script generated by libtool into $builddir:

```
--- libtool.base        2022-11-14 21:18:04.867760568 -0800
+++ libtool.patched     2022-11-14 21:17:32.967784300 -0800
@@ -7826,6 +7826,7 @@
        ;;

       -Wl,*)
+       func_append new_inherited_linker_flags " $arg"
        func_stripname '-Wl,' '' "$arg"
        args=$func_stripname_result
        arg=

```

Leaving it here for posterity. Perhaps someone will do this with a bit more finesse and turn it into a proper feature.

Oleg.

reply via email to

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