Re: [PATCH v2] kbuild: rewrite check-local-export in sh/awk

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

 



On Fri, Aug 12, 2022 at 11:36 PM Owen Rafferty <owen@xxxxxxxxxxxxxxxx> wrote:
>
> Remove the bash build dependency for those who otherwise do not
> have it installed. This also provides a significant speedup:
>
> $ make defconfig
> $ make yes2modconfig
>
> ...
>
> $ find  .  -name "*.o" | grep -v vmlinux | wc
>      3169      3169     89615
> $ export NM=nm
> $ time sh -c 'find . -name "*.o" | grep -v vmlinux | xargs -n1
> ./scripts/check-local-export'
>
> Without patch:
>     0m15.90s real     0m12.17s user     0m05.28s system
>
> With patch:
> dash + nawk
>     0m02.16s real     0m02.92s user     0m00.34s system
>
> dash + busybox awk
>     0m02.36s real     0m03.36s user     0m00.34s system
>
> dash + gawk
>     0m02.07s real     0m03.26s user     0m00.32s system
>
> bash + gawk
>     0m03.55s real     0m05.00s user     0m00.54s system
>
> Signed-off-by: Owen Rafferty <owen@xxxxxxxxxxxxxxxx>
> ---
>
> Notes:
>     [v2] commit message updated


Anyway, awk seems to be faster than bash.

Can you send v3 with the following nits fixed?
Then, I will pick it up.




>
>  scripts/check-local-export | 95 ++++++++++++++++++--------------------
>  1 file changed, 46 insertions(+), 49 deletions(-)
>
> diff --git a/scripts/check-local-export b/scripts/check-local-export
> index 6ccc2f467416..67eaa7cf08c0 100755
> --- a/scripts/check-local-export
> +++ b/scripts/check-local-export
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env bash
> +#!/bin/sh
>  # SPDX-License-Identifier: GPL-2.0-only
>  #
>  # Copyright (C) 2022 Masahiro Yamada <masahiroy@xxxxxxxxxx>


Now that you rewrote many parts of the code,
can you add your Copyright below mine?




> @@ -29,43 +16,53 @@ exit_code=0
>  # TODO:
>  # Use --quiet instead of 2>/dev/null when we upgrade the minimum version of
>  # binutils to 2.37, llvm to 13.0.0.
> -# Then, the following line will be really simple:
> -#   ${NM} --quiet ${1} |
> +# Then, the following line will be simpler:
> +#   { ${NM} --quiet ${1} || kill 0; } |


I am not a big fan of 'kill 0', but
I do not have a better idea to achieve pipefail in POSIX shell.
So, we can live with it.


> +
> +{ ${NM} ${1} 2>/dev/null || { echo "${0}: ${NM} failed" >&2; kill 0; } } |
> +awk -v "file=${1}" '


Can you use ${AWK} instead of 'awk' for consistency?

AWK is defined in the top Makefile.





> +BEGIN {
> +       exit_code = 0


'exit_code' is only used in END,
so I think this initialization can go there.







-- 
Best Regards
Masahiro Yamada



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux