GNOME Bugzilla – Bug 737702
Use -R instead of -rpath when linking libtool libraries
Last modified: 2016-01-25 04:35:13 UTC
Created attachment 287499 [details] [review] Patch to fix the problem Libtool's runpath option is confusingly -R, not -rpath. On OSX the use of -rpath failed to build because ld complained about two -rpath options in one command line. If using -R, then libtool cleans that up. I'd appreciate if this could be committed to the gnome-3-14 branch as well.
Review of attachment 287499 [details] [review]: Looks good.
OK for me to commit to both master and gnome-3-14?
Committed to both master and gnome-3-14.
But it wasn't good: -rpath for libtool means something else: "the library will be eventually installed in ...", and it is used to force a shared library instead of a static one. It has nothing to do with the actual rpath. I reverted the commit, the OS X problem will need a different fix.
OK, I see the problem. How old is that advice from libtool? Can't we just force a shared library using libtool's -shared option in LDFLAGS instead of -rpath? (Documentation reference: http://www.gnu.org/software/libtool/manual/html_node/Link-mode.html#Link-mode)
Created attachment 319645 [details] [review] I've determined that the problem comes from passing -rpath to the linker when Automake is already passing it, i.e. with --enable-installed-tests. This patch only adds -rpath /nowhere if running the tests uninstalled. It works for me on both Fedora 22 and OS X.
Whoops, that was meant for a comment, not a commit message. Fixing...
Created attachment 319646 [details] [review] build: Only force shared libraries if necessary The libtool argument -rpath /nowhere is the (bizarrely) recommended way to force generation of a shared library even if Automake thinks you should not have a shared library. This happens when your library is part of the check or noinst target. We only need to force a shared library if --enable-installed-tests is not given to configure. Normally the extra -rpath does not matter in the case of --enable-installed tests, but OS X's linker chokes if a second -rpath argument is given. This change makes sure the -rpath argument is only added when necessary.
Review of attachment 319646 [details] [review]: LGTM, thanks.
Attachment 319646 [details] pushed as a3b2207 - build: Only force shared libraries if necessary