Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Shlib major bumps and UPDATE builds
OK,
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/
-Wl,-rpath-link,/u/build/HEAD/dest/sgimips/lib:/u/build/HEAD/dest/sgimips/usr/lib
-L/u/build/HEAD/dest/sgimips/lib -Wl,-x -shared -Wl,-soname,libdns.so.2
-Wl,--warn-shared-textrel -o libdns.so.2.0 -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
-L/u/build/HEAD/dest/sgimips/usr/lib
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 bsd.lib.mk file:
Index: bsd.lib.mk
===================================================================
RCS file: /cvsroot/src/share/mk/bsd.lib.mk,v
retrieving revision 1.293
diff -u -p -r1.293 bsd.lib.mk
--- bsd.lib.mk 8 Jan 2009 20:03:59 -0000 1.293
+++ bsd.lib.mk 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
+DPADD+= ${SHLIB_VERSION_FILE}
+
# 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}/ -B${DESTDIR}/usr/lib/
\
- ${_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,libdns.so.2 -Wl,--warn-shared-textrel -o
libdns.so.2.0 -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,-rpath-link,/u/build/HEAD/dest/sgimips/lib:/u/build/HEAD/dest/sgimips/usr/lib
-L/u/build/HEAD/dest/sgimips/lib -Wl,--fatal-warnings
-L/u/build/HEAD/dest/sgimips/usr/lib
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...
Best regards,
- Håvard
Home |
Main Index |
Thread Index |
Old Index