Current-Users archive

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

Re: Shlib major bumps and UPDATE builds

On Wed, Jan 14, 2009 at 04:23:36PM +0100, Havard Eidnes wrote:
  | maybe my build host is too slow, but I continue to do UPDATE
  | builds of NetBSD-current.  This flagged a problem when Christos
  | recently bumped the major version of a number of our shared
  | libraries.  In short, some applications ended up linking the old
  | version of the shared libraries, resulting in warnings which are
  | transformed into errors by the use of -Werror for our in-tree
  | code.
  | Some digging with "readelf -d" revealed that some of the shared
  | libraries the application linked with had a NEEDED attribute
  | which pointed to a shared library with a now old major number.
  | I've finally found out what causes this, and it is the way we
  | link our shared libraries.  As an example I use lib/libdns, where
  | a MAKEVERBOSE=2 build resulted in:
  | /u/build/HEAD/tools/sgimips/bin/mipseb--netbsd-gcc  -Wl,-nostdlib 
-B/u/build/HEAD/dest/sgimips/usr/lib/ -B/u/build/HEAD/dest/sgimips/usr/lib/   
  -L/u/build/HEAD/dest/sgimips/lib  -Wl,-x -shared -Wl,-soname, 
-Wl,--warn-shared-textrel -o  -Wl,--whole-archive libdns.a  
-Wl,--no-whole-archive  -L/u/build/HEAD/obj/sgimips/lib/libpthread -lpthread 
-L/u/build/HEAD/obj/sgimips/lib/libcrypto -lcrypto  -Wl,--fatal-warnings   
  | You will note that -L${DESTDIR}/usr/lib and -L${DESTDIR}/lib
  | comes before the shared libraries it wants to use, and even
  | though care is taken to point to the OBJDIRS of those shared
  | libraries, the previous -L.../usr/lib and -L.../lib will override
  | those directories if the shared library is already installed in
  | DESTDIR, as it typically will be with an UPDATE build.
  | So... Because the shared libraries with the new major numbers
  | have not been installed at this point in the build process
  | (typically the "build all the libraries" phase), the shared
  | library linking command above will pick up the shared libraries
  | with the old major numbers from DESTDIR, causing conflicts/errors
  | when applications are linked later on (I saw it with
  | external/bsd/am-utils in my builds).
  | In my case, I also wanted to easily trigger a rebuild of my
  | shared libraries (without cleaning them...) so I ended up with
  | the following local patch in my file:
  | Index:
  | ===================================================================
  | RCS file: /cvsroot/src/share/mk/,v
  | retrieving revision 1.293
  | diff -u -p -r1.293
  | ---  8 Jan 2009 20:03:59 -0000       1.293
  | +++  14 Jan 2009 15:17:51 -0000
  | @@ -81,6 +81,8 @@ SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ;
  |  SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor
  |  SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny
  | +
  |  # Check for higher installed library versions.
  |  .if !defined(NOCHECKVER) && !defined(NOCHECKVER_${LIB}) && \
  |         exists(${NETBSDSRCDIR}/lib/checkver)
  | @@ -511,10 +513,10 @@ lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOL
  |         rm -f lib${LIB}.so.${SHLIB_FULLVERSION}
  |  .if defined(DESTDIR)
  |         ${LIBCC} ${LDLIBC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ 
  |  \
  | -           ${_LIBLDOPTS} \
  | -           -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} -o ${.TARGET} \
  | +           -Wl,-x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \
  |             -Wl,--whole-archive ${SOLIB} \
  |             -Wl,--no-whole-archive ${LDADD} \
  | +           ${_LIBLDOPTS} ${LDFLAGS} \
  |             -L${_GCC_LIBGCCDIR}
  |  .else
  |         ${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${LDFLAGS} \
  | With that, the linker command is then transformed to this (which
  | may not be correct...):
  | /u/build/HEAD/tools/sgimips/bin/mipseb--netbsd-gcc  -Wl,-nostdlib 
-B/u/build/HEAD/dest/sgimips/usr/lib/ -B/u/build/HEAD/dest/sgimips/usr/lib/  
-Wl,-x -shared -Wl,-soname, -Wl,--warn-shared-textrel -o  -Wl,--whole-archive libdns.a  -Wl,--no-whole-archive  
-L/u/build/HEAD/obj/sgimips/lib/libpthread -lpthread 
-L/u/build/HEAD/obj/sgimips/lib/libcrypto -lcrypto   
  -L/u/build/HEAD/dest/sgimips/lib  -Wl,--fatal-warnings   
  | However, at least my libs and applications now link correctly
  | while continuing my UPDATE builds after having touched all my
  | shlib_version files.
  | I'm a little uncertain whether some of the options I've moved
  | around have position-dependence up and above finding the shared
  | libraries, so this may not be suitable for general consumption,
  | and I may revert it locally once I've completed the current
  | round.  However, the patch is included here for those of you who
  | perform the same excercise I do...

I think your patch is correct, after considering the issues and
looking at the cvs history of

I'm slightly concerned (as you appear to be) that there may be a
lurking dependency on the position of certain arguments.

A potentially tricky situation is libraries that don't get installed
into /lib or /usr/lib (e.g., /usr/X11R7/lib); it may be worthwhile
confirming that the X11 apps are linked correctly too.

Other than that, I'd just commit the patch.


Attachment: pgpPJvhutLJYe.pgp
Description: PGP signature

Home | Main Index | Thread Index | Old Index