Skip to content

Commit

Permalink
mk: Add mktool support to check-shlibs.
Browse files Browse the repository at this point in the history
mktool is an optional external tool, available from pkgtools/mktool or
"cargo install mktool", that provides significant performance improvements
compared to check-shlibs-*.awk, while being 100% compatible.

After installing, set TOOLS_PLATFORM.mktool=/path/to/mktool to enable it.

Comparing the time taken to run "bmake _check-shlibs" in a SmartOS VM in
x11/kde-workspace4, check-shlibs-elf.awk takes:

  real	0m20.441s
  user	0m7.540s
  sys	0m11.222s

while mktool takes just:

  real	0m0.607s
  user	0m0.400s
  sys	0m0.242s

A 30x speedup, but perhaps more importantly a significant reduction in
system time.

Tested on SmartOS and NetBSD (comparing against check-shlibs-elf.awk) and
macOS (comparing against check-shlibs-macho.awk).  mktool was helpful in
exposing the recent issue and bugfix in check-shlibs-macho.awk.
  • Loading branch information
jperkin committed Oct 11, 2024
1 parent 3381f57 commit f02b5bd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mk/check/check-shlibs.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: check-shlibs.mk,v 1.35 2022/11/23 11:55:43 jperkin Exp $
# $NetBSD: check-shlibs.mk,v 1.36 2024/10/11 10:22:01 jperkin Exp $
#
# This file verifies that all libraries used by the package can be found
# at run-time.
Expand Down Expand Up @@ -57,13 +57,17 @@ _CHECK_SHLIBS_FILELIST_CMD?= ${SED} -e '/^@/d' ${PLIST} | \
!empty(CHECK_SHLIBS_SUPPORTED:M[Yy][Ee][Ss]) && \
${_USE_CHECK_SHLIBS_NATIVE} == "yes"
CHECK_SHLIBS_NATIVE_ENV=
.if !empty(TOOLS_PLATFORM.mktool)
CHECK_SHLIBS_NATIVE?= ${TOOLS_PLATFORM.mktool} check-shlibs
CHECK_SHLIBS_NATIVE_ENV+= PKG_ADMIN_CMD=${PKG_ADMIN:Q}
.endif
. if ${OBJECT_FMT} == "ELF"
USE_TOOLS+= readelf
CHECK_SHLIBS_NATIVE= ${PKGSRCDIR}/mk/check/check-shlibs-elf.awk
CHECK_SHLIBS_NATIVE?= ${AWK} -f ${PKGSRCDIR}/mk/check/check-shlibs-elf.awk
CHECK_SHLIBS_NATIVE_ENV+= PLATFORM_RPATH=${_OPSYS_SYSTEM_RPATH:Q}
CHECK_SHLIBS_NATIVE_ENV+= READELF=${TOOLS_PATH.readelf:Q}
. elif ${OBJECT_FMT} == "Mach-O"
CHECK_SHLIBS_NATIVE= ${PKGSRCDIR}/mk/check/check-shlibs-macho.awk
CHECK_SHLIBS_NATIVE?= ${AWK} -f ${PKGSRCDIR}/mk/check/check-shlibs-macho.awk
. if defined(DARWIN_NO_SYSTEM_LIBS)
CHECK_SHLIBS_NATIVE_ENV+= SKIP_SYSTEM_LIBS=1
. endif
Expand Down Expand Up @@ -97,5 +101,5 @@ _check-shlibs: error-check .PHONY
esac; \
${ECHO} $$file; \
done | \
${PKGSRC_SETENV} ${CHECK_SHLIBS_NATIVE_ENV} ${AWK} -f ${CHECK_SHLIBS_NATIVE} > ${ERROR_DIR}/${.TARGET}
${PKGSRC_SETENV} ${CHECK_SHLIBS_NATIVE_ENV} ${CHECK_SHLIBS_NATIVE} > ${ERROR_DIR}/${.TARGET}
.endif

0 comments on commit f02b5bd

Please sign in to comment.