Browse files

build: fixed our soname version function to find libs outside of /usr…


previously, we were only able to determine the sonames of libs in gcc's
default search paths. Instead, we should be using linker paths since it's
next to impossible to change where gcc looks. Use ld's paths instead for

There are two primary reasons for this change:
1. Allow the use of libs in /usr/local, or anywhere else libs may be configured
2. Simplify cross builds where libs may be coming from a staging dir.

In the 2nd case, adding a path to LDFLAGS means that we'll be able to find the

This works by doing a dumb "link" on the libname, so it uses the same mechanism
as our dyloader.
  • Loading branch information...
theuni committed Sep 3, 2011
1 parent 5068ab1 commit c6ff9328e20e64d9be87edd9132fb53d1e4c5c3f
Showing with 4 additions and 4 deletions.
  1. +4 −4
@@ -20,10 +20,10 @@ AC_DEFUN([XB_FIND_SONAME],
if [[ "$host_vendor" != "apple" ]]; then
AC_MSG_CHECKING([for lib$2 soname])
- $1_SONAME=$( $CC -print-file-name=lib$ | \
- while read output; do objdump -p $output | \
- grep "SONAME" | \
- sed -e 's/ *SONAME *//'; done 2> /dev/null )
+ $1_FILENAME=$($LD $LDFLAGS -l$2 -M -o /dev/null 2>/dev/null | grep "^LOAD.*$2" | awk '{V=2; print $V}')
+ if [[ ! -z $$1_FILENAME ]]; then
+ $1_SONAME=$(objdump -p $$1_FILENAME | grep "SONAME.*$2" | awk '{V=2; print $V}')
+ fi
AC_MSG_CHECKING([for lib$2 dylib])
gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]

0 comments on commit c6ff932

Please sign in to comment.