-
Notifications
You must be signed in to change notification settings - Fork 296
Use patchelf to set RPATH #7
Comments
Ok forgot to mention that I also had to adjust |
@aktau The compiler name issue (gcc/g++ vs gcc-4.2/g++-4.2) is now fixed. |
@aktau Hi Nicolas, Homebrew is usually installed in On Linux, /usr/local/lib is not in the default library search path. One simple solution is to add the Homebrew library path to the ld.so config file, Cheers, |
Actually, we could also just set it as a flag to gcc if and when that compiler is used, to obviate the need for
Actually I'm not entirely sure if the -Wl, is necessary when it's put in LDFLAGS... |
This issue affects the master branch of Homebrew just as well as Linuxbrew. Would you open an issue at http://github.com/mxcl/homebrew? It would be good to see it solved upstream. |
The problem discussed here is IMHO actually a bit more complex, and not yet resolved (despite the referenced issue #9 being marked as closed). Quite many libraries are keg-only, and hence dependent binaries must include The hackish solution is to update every single formula to add |
Does linuxbrew use superenv? If so, it wouldn't be difficult to add to flags automatically based on the existing code there. |
Well, of course {home,linux}brew might just do it based on the listed dependencies. Would that be safe? |
@mistydemeo Linuxbrew does not currently use superenv. It would require a few patches to Library/ENV to get it going, I think. @themiwi How does this work on Mac OS? |
@sjackman It's been a while I used Mac OS, but if I remember correctly, each dylib contains an embedded path (the so-called install_name, something like the SONAME on Linux, but usually it is absolute), and this is then used when linking. Hence, (almost) every binary references its libraries via an absolute path, and thus the issue does not exist. I think you can dump this info using |
Otherwise the libraries will not be found in the $HOMEBREW_PREFIX/opt/<formula>/lib directory on Linux. Refer to Linuxbrew#7. Signed-off-by: Michael Wild <themiwi@users.sourceforge.net>
Otherwise the libraries will not be found in the $HOMEBREW_PREFIX/opt/<formula>/lib directory on Linux. Refer to Linuxbrew#7. Signed-off-by: Michael Wild <themiwi@users.sourceforge.net>
@aktau Absolutely, I stumbled across this issue myself just recently (both with ViM and also with GTK+ programs no longer working properly because those got linked). For linuxbrew it probably is almost always a bad idea to link |
@aktau @themiwi Could you please test the branch I'm using this patch to implement portable bottles on Linux. I've tested building a bottle on Ubuntu 14.04 and running it on CentOS 5.10, and it works! I'm pretty happy with that result. Cheers, |
I'd appreciate your help if you could also test |
Don't have any systems I can safely mess up at the moment.
Pretty great, but it's still risky unless all libraries have been source from homebrew's own I guess. I like the rpath fix much more for not having to mess with my Could you details a few steps for how I would go about testing this? I'm not a homebrew/ruby expert by any stretch of the imagination. |
Hi, Nicolas. Checkout the |
Apparently it didn't work: ➜ .linuxbrew git:(34b4c36) cd
➜ ~ brew install ag
==> Installing dependencies for the_silver_searcher: autoconf, automake, pkg-config, pcre, xz
==> Installing the_silver_searcher dependency: autoconf
==> Downloading http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/home/player/.linuxbrew/Cellar/autoconf/2.69
==> make install
==> Caveats
This formula is keg-only, so it was not symlinked into /home/player/.linuxbrew.
Xcode provides this software prior to version 4.3.
==> Summary
/home/player/.linuxbrew/Cellar/autoconf/2.69: 66 files, 3.2M, built in 11 seconds
==> Installing the_silver_searcher dependency: automake
==> Downloading http://ftpmirror.gnu.org/automake/automake-1.14.1.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/home/player/.linuxbrew/Cellar/automake/1.14.1
==> make install
==> Caveats
This formula is keg-only, so it was not symlinked into /home/player/.linuxbrew.
Xcode provides this software prior to version 4.3.
==> Summary
/home/player/.linuxbrew/Cellar/automake/1.14.1: 131 files, 3.3M, built in 11 seconds
==> Installing the_silver_searcher dependency: pkg-config
==> Downloading http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/home/player/.linuxbrew/Cellar/pkg-config/0.28 --disable-host-tool --with-internal-glib --with-pc-path=/home/player/.linuxbrew/lib/pkgconfig:/home/player/.linuxbrew/sha
==> make
==> make check
==> make install
/home/player/.linuxbrew/Cellar/pkg-config/0.28: 10 files, 644K, built in 96 seconds
==> Installing the_silver_searcher dependency: pcre
==> Downloading https://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/home/player/.linuxbrew/Cellar/pcre/8.35 --enable-utf8 --enable-pcre8 --enable-pcre16 --enable-pcre32 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregr
==> make
==> make test
==> make install
/home/player/.linuxbrew/Cellar/pcre/8.35: 146 files, 5.5M, built in 2.2 minutes
==> Installing the_silver_searcher dependency: xz
==> Downloading http://fossies.org/linux/misc/xz-5.0.5.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/home/player/.linuxbrew/Cellar/xz/5.0.5
==> make install
/home/player/.linuxbrew/Cellar/xz/5.0.5: 63 files, 1.7M, built in 30 seconds
==> Installing the_silver_searcher
==> Downloading https://github.com/ggreer/the_silver_searcher/archive/0.23.0.tar.gz
######################################################################## 100.0%
==> Downloading https://github.com/thomasf/the_silver_searcher/commit/867dff8631bc80d760268f653265e4d3caf44f16.diff
######################################################################## 100.0%
==> Patching
patching file ag.bashcomp.sh
==> aclocal -I /home/player/.linuxbrew/share/aclocal
==> autoconf
==> autoheader
==> automake --add-missing
==> ./configure --prefix=/home/player/.linuxbrew/Cellar/the_silver_searcher/0.23.0
==> make
==> make install
==> Caveats
Bash completion has been installed to:
/home/player/.linuxbrew/etc/bash_completion.d
==> Summary
/home/player/.linuxbrew/Cellar/the_silver_searcher/0.23.0: 8 files, 148K, built in 12 seconds
You have new mail.
➜ ~ which ag
/home/player/.linuxbrew/bin/ag
➜ ~ ag -v
ag: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory This was on a fresh linuxbrew install. Not sure what I did wrong. |
Reported too soon. I had forgotten to install ➜ ~ brew install patchelf
==> Downloading https://github.com/NixOS/patchelf/archive/0.8.tar.gz
######################################################################## 100.0%
==> ./bootstrap.sh
==> ./configure --disable-silent-rules --prefix=/home/player/.linuxbrew/Cellar/patchelf/0.8
==> make install
/home/player/.linuxbrew/Cellar/patchelf/0.8: 6 files, 172K, built in 11 seconds
➜ ~ brew remove ag
Uninstalling /home/player/.linuxbrew/Cellar/the_silver_searcher/0.23.0...
➜ ~ brew install ag
==> Downloading https://github.com/ggreer/the_silver_searcher/archive/0.23.0.tar.gz
Already downloaded: /home/player/.cache/Homebrew/the_silver_searcher-0.23.0.tar.gz
==> Downloading https://github.com/thomasf/the_silver_searcher/commit/867dff8631bc80d760268f653265e4d3caf44f16.diff
Already downloaded: /home/player/.cache/Homebrew/the_silver_searcher--patch-09502c60a11658d9a08a6825e78defad96318bd9.diff
==> Patching
patching file ag.bashcomp.sh
==> aclocal -I /home/player/.linuxbrew/share/aclocal
==> autoconf
==> autoheader
==> automake --add-missing
==> ./configure --prefix=/home/player/.linuxbrew/Cellar/the_silver_searcher/0.23.0
==> make
==> make install
==> Caveats
Bash completion has been installed to:
/home/player/.linuxbrew/etc/bash_completion.d
==> Summary
/home/player/.linuxbrew/Cellar/the_silver_searcher/0.23.0: 8 files, 152K, built in 8 seconds
➜ ~ ag -v
ERR: What do you want to search for?
➜ ~ which ag
/home/player/.linuxbrew/bin/ag |
@sjackman need any more input? It seems to work fine here. About the only suggestion I'd make is to make it more obvious that In fact, if it were up to me, I'd make |
I've create a new wiki page with instructions for a Standalone Installation of Linuxbrew. Would you be able to test it out? |
@aktau With the recent commits to |
Very nice :). It's good that there's a fallback to patchelf. Especially when/if there are toolchains that don't have the concept of |
Closes Linuxbrew#7. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Also set the dynamic loader ld.so if glibc is installed. Closes Linuxbrew/legacy-linuxbrew#7
Nicolas Hillegeer wrote...
Hey!
I just tried to post an issue to the issue tracker but it seems it won't budge, so I'll just paste my findings over to you:
NOTE: this issue might be double-posted, I think there was some issue with github so it didn't appear for me...
I really wanted ag, the silver searcher and I really wanted it through homebrew because I like pretty colours and upgrades, and dependency building, and rainbows.
I basically installed with
So, that left me with three tiny hacks to get it to work:
brew doctor
, it seems to assume mktemp is in/usr/bin/mktemp, on debian it's in /bin/mktempSuccess!!!
ag
installs, drags inpcre
kicking and screaming, and I am the proud father of a new compiled silver searcher.But wait... it says that it can't find
libpcre.so.1
when it runs. But I do have it, it got installed to/opt/homebrew/lib
as part of the dependency resolving phase. What do we do?But, is there a way to change the LD_LIBRARY_PATH for just one executable? Well yea, we could write a wrapper script! There are a lot of packages that do that. And it's bad, but not quite as evil as changing LD_LIBRARY_PATH. So, I could hack homebrew to have it generate wrappers instead of symlinks.
But that's so dirty...
And I'm so lazy...
And I don't know ruby...
So I bust out google-fu and find that in fact, there is a solution that works for many unices. Basically, every executable has the possibility to have a RPATH and a RUNPATH. It's basically exactly what we want, the runtime linker will look first in RPATH, then in the normal path and last but not least in RUNPATH. At least that's my understanding.
But I find that you can set this variable at link-time, with a switch to
ld
orgcc
. :(That would mean hacking homebrew again.
I google once more before giving up and I find the venerable
patchelf
. Which... patches elfs to have a different RUNPATH. Exactly what we need.Does it work? Why yes, it works. Now I can run homebrew on my debian wheezy. Nice.
The text was updated successfully, but these errors were encountered: