pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/check mk: check performance improvements.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2e0ac2b31411
branches:  trunk
changeset: 388600:2e0ac2b31411
user:      jperkin <jperkin%pkgsrc.org@localhost>
date:      Wed Nov 23 11:55:43 2022 +0000

description:
mk: check performance improvements.

Inline ${RUN} calls where appropriate.  Avoid useless use of cat(1).  Avoid
unnecessary calls to rm.  Use xargs(1) to reduce number of calls to egrep,
previously it was called once per file.

The last change in particular can have huge performance improvements, for
example saving around 5,000 execs during the build of ansible-core, and
significantly reducing the build and system times.

diffstat:

 mk/check/check-files.mk       |  29 +++++++++++++----------------
 mk/check/check-headers.mk     |   6 +++---
 mk/check/check-interpreter.mk |   7 ++++---
 mk/check/check-perms.mk       |   7 ++++---
 mk/check/check-pie.mk         |  27 +++++++++++++--------------
 mk/check/check-portability.mk |   4 ++--
 mk/check/check-relro.mk       |   7 +++----
 mk/check/check-shlibs.mk      |  11 +++++------
 mk/check/check-ssp.mk         |   9 ++++-----
 mk/check/check-stripped.mk    |   7 ++++---
 mk/check/check-wrkref.mk      |  22 ++++++++++++----------
 11 files changed, 67 insertions(+), 69 deletions(-)

diffs (truncated from 332 to 300 lines):

diff -r 6b5c81f2bd59 -r 2e0ac2b31411 mk/check/check-files.mk
--- a/mk/check/check-files.mk   Wed Nov 23 11:40:51 2022 +0000
+++ b/mk/check/check-files.mk   Wed Nov 23 11:55:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-files.mk,v 1.37 2020/12/20 19:49:25 gutteridge Exp $
+# $NetBSD: check-files.mk,v 1.38 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that the list of installed files matches the PLIST.
 # For that purpose it records the file list of LOCALBASE before and
@@ -279,7 +279,7 @@
 
 ${_CHECK_FILES_MISSING_REAL}: ${_CHECK_FILES_MISSING}
        ${RUN}                                  \
-       ${CAT} ${_CHECK_FILES_MISSING} | ${_CHECK_FILES_SKIP_FILTER}    \
+       ${_CHECK_FILES_SKIP_FILTER} < ${_CHECK_FILES_MISSING}           \
                > ${.TARGET} || ${TRUE}
 
 ${_CHECK_FILES_MISSING_SKIP}:                                          \
@@ -305,29 +305,26 @@
                ${_CHECK_FILES_MISSING_REAL}                            \
                ${_CHECK_FILES_MISSING_SKIP}                            \
                ${_CHECK_FILES_EXTRA}
-       ${RUN}${RM} -f ${.TARGET}
-       ${RUN}                                  \
-       if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_DELETED}; then         \
+       ${RUN}                                                          \
+       ${RM} -f ${.TARGET};                                            \
+       if [ -s ${_CHECK_FILES_DELETED} ]; then                         \
                ${ECHO} "The following files have been deleted"         \
                        "from ${PREFIX}!";                              \
                ${SED} "s|^|        |" ${_CHECK_FILES_DELETED};         \
-       fi >> ${.TARGET}
-       ${RUN}                                  \
-       if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_MISSING_REAL}; then    \
+       fi >> ${.TARGET};                                               \
+       if [ -s ${_CHECK_FILES_MISSING_REAL} ]; then                    \
                ${ECHO} "************************************************************"; \
                ${ECHO} "The following files are in the"                \
-                       "PLIST but not in ${DESTDIR}${PREFIX}:";                        \
+                       "PLIST but not in ${DESTDIR}${PREFIX}:";        \
                ${SED} "s|^|        |" ${_CHECK_FILES_MISSING_REAL};    \
-       fi >> ${.TARGET}
-       ${RUN}                                  \
-       if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_EXTRA}; then           \
+       fi >> ${.TARGET};                                               \
+       if [ -s ${_CHECK_FILES_EXTRA} ]; then                           \
                ${ECHO} "************************************************************"; \
                ${ECHO} "The following files are in"                    \
-                       "${DESTDIR}${PREFIX} but not in the PLIST:";            \
+                       "${DESTDIR}${PREFIX} but not in the PLIST:";    \
                ${SED} "s|^|        |" ${_CHECK_FILES_EXTRA};           \
-       fi >> ${.TARGET}
-       ${RUN}                                  \
-       if ${_NONZERO_FILESIZE_P} ${_CHECK_FILES_MISSING_SKIP}; then    \
+       fi >> ${.TARGET};                                               \
+       if [ -s ${_CHECK_FILES_MISSING_SKIP} ]; then                    \
                ${ECHO} "************************************************************"; \
                ${ECHO} "The following files are in both the"           \
                        "PLIST and CHECK_FILES_SKIP:";                  \
diff -r 6b5c81f2bd59 -r 2e0ac2b31411 mk/check/check-headers.mk
--- a/mk/check/check-headers.mk Wed Nov 23 11:40:51 2022 +0000
+++ b/mk/check/check-headers.mk Wed Nov 23 11:55:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-headers.mk,v 1.7 2014/10/12 23:39:17 joerg Exp $
+# $NetBSD: check-headers.mk,v 1.8 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks the C and C++ header files for possible problems.
 #
@@ -32,9 +32,9 @@
 
 .PHONY: _check-headers
 _check-headers:
-       @${STEP_MSG} "Checking for possible problems in header files"
        ${RUN}                                                          \
+       ${STEP_MSG} "Checking for possible problems in header files";   \
        [ -d ${WRKSRC}/. ] || exit 0;                                   \
        cd ${WRKSRC};                                                   \
-       env     SKIP_FILTER=${CHECK_HEADERS_SKIP:@p@${p}) skip=yes;;@:Q} \
+       env SKIP_FILTER=${CHECK_HEADERS_SKIP:@p@${p}) skip=yes;;@:Q}    \
                sh ${PKGSRCDIR}/mk/check/check-headers.sh
diff -r 6b5c81f2bd59 -r 2e0ac2b31411 mk/check/check-interpreter.mk
--- a/mk/check/check-interpreter.mk     Wed Nov 23 11:40:51 2022 +0000
+++ b/mk/check/check-interpreter.mk     Wed Nov 23 11:55:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-interpreter.mk,v 1.31 2016/03/11 21:11:47 dholland Exp $
+# $NetBSD: check-interpreter.mk,v 1.32 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that after installation, all files of the package
 # that start with a "#!" line will find their interpreter. Files that
@@ -45,8 +45,9 @@
 .endif
 
 _check-interpreter: error-check .PHONY
-       @${STEP_MSG} "Checking for non-existent script interpreters in ${PKGNAME}"
-       ${RUN} cd ${DESTDIR}${PREFIX};                                  \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Checking for non-existent script interpreters in ${PKGNAME}"; \
+       cd ${DESTDIR}${PREFIX};                                         \
        ${_CHECK_INTERP_FILELIST_CMD} | ${SORT} | ${SED} 's,\\,\\\\,g' |\
        while read file; do                                             \
                case "$$file" in                                        \
diff -r 6b5c81f2bd59 -r 2e0ac2b31411 mk/check/check-perms.mk
--- a/mk/check/check-perms.mk   Wed Nov 23 11:40:51 2022 +0000
+++ b/mk/check/check-perms.mk   Wed Nov 23 11:55:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-perms.mk,v 1.22 2020/03/13 08:04:08 rillig Exp $
+# $NetBSD: check-perms.mk,v 1.23 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that after installation of a package, all files and
 # directories of that package have sensible permissions set.
@@ -73,8 +73,9 @@
        }
 
 _check-perms: .PHONY
-       @${STEP_MSG} "Checking file permissions in ${PKGNAME}"
-       ${RUN} ${HOST_PKG_INFO} -qe "checkperms>=1.1"                   \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Checking file permissions in ${PKGNAME}";          \
+       ${HOST_PKG_INFO} -qe "checkperms>=1.1"                          \
        || {                                                            \
                ${WARNING_MSG} "[check-perms.mk] Skipping file permissions check."; \
                ${WARNING_MSG} "[check-perms.mk] Install sysutils/checkperms to enable this check."; \
diff -r 6b5c81f2bd59 -r 2e0ac2b31411 mk/check/check-pie.mk
--- a/mk/check/check-pie.mk     Wed Nov 23 11:40:51 2022 +0000
+++ b/mk/check/check-pie.mk     Wed Nov 23 11:55:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-pie.mk,v 1.3 2022/03/07 16:53:08 nia Exp $
+# $NetBSD: check-pie.mk,v 1.4 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file verifies that MKPIE (position-independent executables) was applied
 # accordingly at build-time.
@@ -60,18 +60,17 @@
        !empty(_CHECK_PIE_CMD)
 privileged-install-hook: _check-pie
 _check-pie: error-check .PHONY
-       @${STEP_MSG} "Checking for PIE in ${PKGNAME}"
-       ${RUN} rm -f ${ERROR_DIR}/${.TARGET}
        ${RUN}                                                          \
-               cd ${DESTDIR:Q}${PREFIX:Q};                             \
-               ${_CHECK_PIE_FILELIST_CMD} |                            \
-               ${EGREP} -h ${_CHECK_PIE_ERE:Q} |                       \
-               while read file; do                                     \
-                       case "$$file" in                                \
-                               ${CHECK_PIE_SKIP:@p@${p}) continue;;@}  \
-                               *) ${ECHO} "$$file";                    \
-                       esac;                                           \
-               done |                                                  \
-               ${PKGSRC_SETENV} ${_CHECK_PIE_ENV} ${_CHECK_PIE_CMD}    \
-                       > ${ERROR_DIR}/${.TARGET}
+       ${STEP_MSG} "Checking for PIE in ${PKGNAME}";                   \
+       cd ${DESTDIR:Q}${PREFIX:Q};                                     \
+       ${_CHECK_PIE_FILELIST_CMD} |                                    \
+       ${EGREP} -h ${_CHECK_PIE_ERE:Q} |                               \
+       while read file; do                                             \
+               case "$$file" in                                        \
+                       ${CHECK_PIE_SKIP:@p@${p}) continue;;@}          \
+                       *) ${ECHO} "$$file";                            \
+               esac;                                                   \
+       done |                                                          \
+       ${PKGSRC_SETENV} ${_CHECK_PIE_ENV} ${_CHECK_PIE_CMD}            \
+               > ${ERROR_DIR}/${.TARGET}
 .endif
diff -r 6b5c81f2bd59 -r 2e0ac2b31411 mk/check/check-portability.mk
--- a/mk/check/check-portability.mk     Wed Nov 23 11:40:51 2022 +0000
+++ b/mk/check/check-portability.mk     Wed Nov 23 11:55:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-portability.mk,v 1.19 2020/06/07 10:42:04 rillig Exp $
+# $NetBSD: check-portability.mk,v 1.20 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that the extracted shell programs don't contain
 # bashisms or other constructs that only work on some platforms.
@@ -44,8 +44,8 @@
 .endif
 .PHONY: _check-portability
 _check-portability:
-       @${STEP_MSG} "Checking for portability problems in extracted files"
        ${RUN}                                                          \
+       ${STEP_MSG} "Checking for portability problems in extracted files"; \
        [ -d ${WRKSRC}/. ] || exit 0;                                   \
        cd ${WRKSRC};                                                   \
        ${SETENV}                                                       \
diff -r 6b5c81f2bd59 -r 2e0ac2b31411 mk/check/check-relro.mk
--- a/mk/check/check-relro.mk   Wed Nov 23 11:40:51 2022 +0000
+++ b/mk/check/check-relro.mk   Wed Nov 23 11:55:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-relro.mk,v 1.7 2022/08/18 00:19:34 joerg Exp $
+# $NetBSD: check-relro.mk,v 1.8 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file verifies that RELRO (read-only relocations) was applied
 # accordingly at build-time.
@@ -69,9 +69,8 @@
 
 privileged-install-hook: _check-relro
 _check-relro: error-check .PHONY
-       @${STEP_MSG} "Checking for RELRO in ${PKGNAME}"
-       ${RUN} rm -f ${ERROR_DIR}/${.TARGET}
-       ${RUN}                                  \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Checking for RELRO in ${PKGNAME}";                 \
        cd ${DESTDIR:Q}${PREFIX:Q};                                     \
        ${_CHECK_RELRO_FILELIST_CMD} |                                  \
        ${EGREP} -h ${_CHECK_RELRO_ERE:Q} |                             \
diff -r 6b5c81f2bd59 -r 2e0ac2b31411 mk/check/check-shlibs.mk
--- a/mk/check/check-shlibs.mk  Wed Nov 23 11:40:51 2022 +0000
+++ b/mk/check/check-shlibs.mk  Wed Nov 23 11:55:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-shlibs.mk,v 1.34 2021/10/11 20:26:28 jperkin Exp $
+# $NetBSD: check-shlibs.mk,v 1.35 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file verifies that all libraries used by the package can be found
 # at run-time.
@@ -49,9 +49,9 @@
 _CHECK_SHLIBS_ERE=     (bin/|sbin/|libexec/|\.(dylib|sl|so)$$|lib/lib.*\.(dylib|sl|so))
 
 _CHECK_SHLIBS_FILELIST_CMD?=   ${SED} -e '/^@/d' ${PLIST} |            \
-       (while read file; do                                            \
+       while read file; do                                             \
                ${TEST} -h "$$file" || ${ECHO} "$$file";                \
-       done)
+       done
 
 .if !empty(CHECK_SHLIBS:M[Yy][Ee][Ss]) && \
     !empty(CHECK_SHLIBS_SUPPORTED:M[Yy][Ee][Ss]) && \
@@ -85,9 +85,8 @@
 
 privileged-install-hook: _check-shlibs
 _check-shlibs: error-check .PHONY
-       @${STEP_MSG} "Checking for missing run-time search paths in ${PKGNAME}"
-       ${RUN} rm -f ${ERROR_DIR}/${.TARGET}
-       ${RUN}                                  \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Checking for missing run-time search paths in ${PKGNAME}"; \
        cd ${DESTDIR:Q}${PREFIX:Q};                                     \
        ${_CHECK_SHLIBS_FILELIST_CMD} |                                 \
        ${EGREP} -h ${_CHECK_SHLIBS_ERE:Q} |                            \
diff -r 6b5c81f2bd59 -r 2e0ac2b31411 mk/check/check-ssp.mk
--- a/mk/check/check-ssp.mk     Wed Nov 23 11:40:51 2022 +0000
+++ b/mk/check/check-ssp.mk     Wed Nov 23 11:55:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-ssp.mk,v 1.3 2020/03/23 09:25:58 jperkin Exp $
+# $NetBSD: check-ssp.mk,v 1.4 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file verifies that stack-smashing protection, commonly known as SSP,
 # was applied correctly at build-time.
@@ -42,9 +42,9 @@
 _CHECK_SSP_ERE=                (bin/|sbin/|libexec/|\.so$$|lib/lib.*\.so)
 
 _CHECK_SSP_FILELIST_CMD?=      ${SED} -e '/^@/d' ${PLIST} |            \
-       (while read file; do                                            \
+       while read file; do                                             \
                ${TEST} -h "$$file" || ${ECHO} "$$file";                \
-       done)
+       done
 
 .if !empty(CHECK_SSP:M[Yy][Ee][Ss]) && \
     !empty(CHECK_SSP_SUPPORTED:M[Yy][Ee][Ss]) && \
@@ -67,9 +67,8 @@
 
 privileged-install-hook: _check-ssp
 _check-ssp: error-check .PHONY
-       @${STEP_MSG} "Checking for SSP in ${PKGNAME}"
-       ${RUN} rm -f ${ERROR_DIR}/${.TARGET}
        ${RUN}                                                  \
+       ${STEP_MSG} "Checking for SSP in ${PKGNAME}";           \
        cd ${DESTDIR:Q}${PREFIX:Q};                             \
        ${_CHECK_SSP_FILELIST_CMD} |                            \
        ${EGREP} -h ${_CHECK_SSP_ERE:Q} |                       \
diff -r 6b5c81f2bd59 -r 2e0ac2b31411 mk/check/check-stripped.mk
--- a/mk/check/check-stripped.mk        Wed Nov 23 11:40:51 2022 +0000
+++ b/mk/check/check-stripped.mk        Wed Nov 23 11:55:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-stripped.mk,v 1.6 2014/10/12 23:39:17 joerg Exp $
+# $NetBSD: check-stripped.mk,v 1.7 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that after installation, all binaries conform to the
 # setting of INSTALL_UNSTRIPPED.
@@ -37,8 +37,9 @@
 .endif
 
 _check-stripped: error-check .PHONY
-       @${STEP_MSG} "Checking whether binaries are ${_INSTALL_UNSTRIPPED:Dun:U}stripped."
-       ${RUN} cd ${DESTDIR}${PREFIX};                                  \
+       ${RUN}                                                          \
+       ${STEP_MSG} "Checking whether binaries are ${_INSTALL_UNSTRIPPED:Dun:U}stripped."; \
+       cd ${DESTDIR}${PREFIX};                                         \
        want_stripped=${_INSTALL_UNSTRIPPED:Dno:Uyes};                  \
        ${_CHECK_STRIPPED_FILELIST_CMD} | ${SORT} | ${SED} 's,\\,\\\\,g'\
        | while read file; do                                           \
diff -r 6b5c81f2bd59 -r 2e0ac2b31411 mk/check/check-wrkref.mk
--- a/mk/check/check-wrkref.mk  Wed Nov 23 11:40:51 2022 +0000
+++ b/mk/check/check-wrkref.mk  Wed Nov 23 11:55:43 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: check-wrkref.mk,v 1.25 2020/04/26 14:23:25 rillig Exp $
+# $NetBSD: check-wrkref.mk,v 1.26 2022/11/23 11:55:43 jperkin Exp $
 #
 # This file checks that the installed files don't contain any strings
 # that point to the directory where the package had been built, to make
@@ -82,10 +82,8 @@
 .endif
 



Home | Main Index | Thread Index | Old Index