Resolving lib build dependencies in src a non-race condition prone way?

Garrett Cooper yanefbsd at gmail.com
Sun Jun 13 06:11:47 UTC 2010


I might be completely missing the boat as to what needs to be done
here, but the current code in Makefile.inc1, and lib/Makefile appears
very race condition prone:

>From Makefile.inc1:

_prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \
                ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
                ${_kerberos5_lib_libroken} \
                lib/libbz2 lib/libcom_err lib/libcrypt \
                lib/libexpat \
                ${_lib_libgssapi} ${_lib_libipx} \
                lib/libkiconv lib/libkvm lib/libmd \
                lib/ncurses/ncurses lib/ncurses/ncursesw \
                lib/libopie lib/libpam ${_lib_libthr} \
                lib/libradius lib/libsbuf lib/libtacplus \
                lib/libutil ${_lib_libypclnt} lib/libz lib/msun \
                ${_secure_lib_libcrypto} ${_secure_lib_libssh} \
                ${_secure_lib_libssl}

>From lib/Makefile:

SUBDIR_ORDERED= ${_csu} \
        libc \
        libbsm \
        libauditd \
        libcom_err \
        libcrypt \
        libelf \
        libkvm \
        msun \
        libmd \
        ncurses \
        ${_libnetgraph} \
        libradius \
        librpcsvc \
        libsbuf \
        libtacplus \
        libutil \
        ${_libypclnt}

SUBDIR= ${SUBDIR_ORDERED} \
        libalias \
        libarchive \
        ${_libatm} \

Note that if in Makefile.inc1 I place a library like libarchive, then
the process will fall over in itself (this is the case in my perforce
branch today) trying to fulfill prerequisites (libbz2, liblzma, libz).
If I place the dependencies in SUBDIR_ORDERED in lib/Makefile, then I
risk bringing in a race condition where a high enough -j value will
cause the build to fail as well.

The other thing that's curious is instead of building in the logic to
build the prerequisite libraries in the leaf Makefiles, make just
currently fails as follows:

===> lib/libpkg (all)
make: don't know how to make
/usr/obj/scratch/freebsd/perforce/pkg_install-enhancements/tmp/usr/lib/libarchive.a.
Stop

I was wondering why the DPADD code wasn't properly building
prerequisites beforehand, but it appears that the only code that
defines the targets are the respective lib Makefiles themselves.

So, to just confirm this:

Is there a race condition issue that's currently handled by explicit
manual ordering of the targets?
    - If yes, could it be fixed by adding in bits to link back the lib
make invocations at Makefile.inc1, or similar, i.e.:

LIBARCHIVE_SRCDIR=    lib/libarchive

${LIBARCHIVE}:
.for i in depend obj all install
     ${MAKE} -C ${SRCDIR}${LIBARCHIVE_SRCDIR} $i
.endfor

?

    (I realize that using the variable ${SRCDIR} won't function in all
contexts, so it probably be something like ${TOP_SRCDIR}, keeping
parity with an autotools-like paradigm -- but the name doesn't really
matter too much right now).
    - If no, what am I doing wrong?

Thanks,
-Garrett


More information about the freebsd-hackers mailing list