From 447bb5a3bdc87f6d8ba268e7372033970bdc84c4 Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Tue, 14 Jun 2016 16:19:44 +0000 Subject: [PATCH] WITH_META_MODE+WITH_DEBUG_FILES: Fix library symlinks causing bogus rebuilds. A simplified example of the library targets with WITH_DEBUG_FILES is: libgeom.so.5: libgeom.so.5.full cp libgeom.so.5.full libgeom.so.5 libgeom.so.5.full: ln -s libgeom.so.5 libgeom.so cc -o libgeom.so.5.full *.o Before, or without, WITH_DEBUG_FILES it is: libgeom.so.5: ln -s libgeom.so.5 libgeom.so cc -o libgeom.so.5 *.o The problem is that bmake considers the link source for the libgeom.so link in the libgeom.so.5.full target as being a dependency for libgeom.so.5.full. That resolves to libgeom.so.5. Thus a cyclic dependency is created. The result of this is that if libgeom.so.5 is created with a newer timestamp than libgeom.so.5.full, then libgeom.so.5.full will be rebuilt on the next build. This causes a chain reaction of everything in the build relinking, or hitting the problem itself. Moving the link creation to the target that actually creates libgeom.so.5 fixes the problem. The simplest fix here is to just duplicate the logic. Submitted by: sjg Approved by: re (implicit) --- share/mk/bsd.lib.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 971577c9a9e..0b7bb0230ab 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -244,7 +244,7 @@ CLEANFILES+= ${SHLIB_LINK} ${SHLIB_NAME_FULL}: ${SOBJS} @${ECHO} building shared library ${SHLIB_NAME} @rm -f ${SHLIB_NAME} ${SHLIB_LINK} -.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld) +.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld) && ${MK_DEBUG_FILES} == "no" @${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${SHLIB_NAME} ${SHLIB_LINK} .endif ${_LD:N${CCACHE_BIN}} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \ @@ -259,6 +259,9 @@ CLEANFILES+= ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug ${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug ${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.debug \ ${SHLIB_NAME_FULL} ${.TARGET} +.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld) + @${INSTALL_SYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${SHLIB_NAME} ${SHLIB_LINK} +.endif ${SHLIB_NAME}.debug: ${SHLIB_NAME_FULL} ${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET}