Subject: Re: PR lib/7283 - shared library builds use old dependent libraries
To: Erik E. Fair <fair@clock.org>
From: Bill Studenmund <wrstuden@nas.nasa.gov>
List: tech-userlevel
Date: 03/30/1999 15:56:30
On Mon, 29 Mar 1999, Erik E. Fair wrote:

> I just filed PR lib/7283 with a patch for bsd.lib.mk that I would like
> someone more expert than I to examine the diff and commit it. This is
> sufficiently central to the build process that I don't want to hose it in
> the middle of a release cycle, but this bug Must Be Fixed.
> 
> *** src/share/mk/bsd.lib.mk.orig        Mon Mar 29 11:30:36 1999
> --- src/share/mk/bsd.lib.mk     Mon Mar 29 11:41:00 1999
> ***************
> *** 242,251 ****
> --- 242,260 ----
>       ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE}
>         @echo building shared ${LIB} library \(version
> ${SHLIB_MAJOR}.${SHLIB_MINOR}\)
>         @rm -f lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR}
> + .if defined(DESTDIR)
> +       $(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
> +           ${SHLIB_LDSTARTFILE} \
> +           --whole-archive lib${LIB}_pic.a \
> +           -nostdlib -L${DESTDIR}${LIBDIR} -R${LIBDIR} \
> +           --no-whole-archive ${LDADD} \
> +           ${SHLIB_LDENDFILE}
> + .else
>         $(LD) -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
>             ${SHLIB_LDSTARTFILE} \
>             --whole-archive lib${LIB}_pic.a --no-whole-archive ${LDADD} \
>             ${SHLIB_LDENDFILE}
> + .endif
>   .if ${OBJECT_FMT} == "ELF"
>         rm -f lib${LIB}.so.${SHLIB_MAJOR}
>         ln -s lib${LIB}.so.${SHLIB_MAJOR}.${SHLIB_MINOR} \

I think this looks fine. It solves a problem I've run into from time to
time when libraries depend on other libraries.

The problems are quite dramatic if you're cross compiling. :-)

Take care,

Bill