Subject: Circular symlink created when only SHLIB_MAJOR is defined
To: None <>
From: Jeremie Le Hen <>
List: tech-toolchain
Date: 01/23/2007 17:31:34
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi list,

(Please Cc: in your reply, I'm not subscribed.) supports multiple levels of precision for shared libraries
version numbering as the following code snippet shows:

% .if defined(SHLIB_MAJOR) && !empty(SHLIB_MAJOR)                         # {
% .if defined(SHLIB_MINOR) && !empty(SHLIB_MINOR)
% .if defined(SHLIB_TEENY) && !empty(SHLIB_TEENY)
% .else
% .endif
% .else
% .endif
% .endif                                                                  # }

The problem I've been faced occurs in the later case when you only
define SHLIB_MAJOR.  Here is what happens during the linkage of my
shared library:

% #     build  poolexecutor/
% rm -f
% cc -Wl,-x -shared -Wl,-soname,   -o   -Wl,-rpath-link,/lib:/usr/lib  -L/lib  -Wl,--whole-archive libzthreadstub_pic.a -Wl,--no-whole-archive -lpthread
% ln -sf
% mv -f
% ln -sf
% mv -f

This results in a circular symlink for

% octobrebsd:poolexecutor$ stat -f "%N -> %Y"
% ->

According to the CVS repository, this ln(1)/mv(1) dance is used to
prevent small races during parallel builds where could no
longer exist for a small time (see rev. 1.177).  The proposed fix
is attached.

This works for me, at least.
Best regards,
Jeremie Le Hen
< jeremie at le-hen dot org >< ttz at chchile dot org >

Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="nbsd.shlib_major_only.patch"

RCS file: /pub/NetBSD-CVS/src/share/mk/,v
retrieving revision 1.270
diff -u -r1.270
---  23 Nov 2006 12:05:26 -0000      1.270
+++  23 Jan 2007 16:20:41 -0000
@@ -469,8 +469,10 @@
 #  We don't use INSTALL_SYMLINK here because this is just
 #  happening inside the build directory/objdir. XXX Why does
 #  this spend so much effort on libraries that aren't live??? XXX
 	${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.${SHLIB_MAJOR}.tmp
 	mv -f lib${LIB}.so.${SHLIB_MAJOR}.tmp lib${LIB}.so.${SHLIB_MAJOR}
 	${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp
 	mv -f lib${LIB}.so.tmp lib${LIB}.so