mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nick Terrell <terrelln@fb.com>
To: "Alex Xu (Hello71)" <alex_y_xu@yahoo.ca>
Cc: Michael Forney <forney@google.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Michal Marek <michal.lkml@markovi.net>,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	Ingo Molnar <mingo@kernel.org>,
	"Sedat Dilek" <sedat.dilek@gmail.com>,
	Kees Cook <keescook@chromium.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-kbuild@vger.kernel.org" <linux-kbuild@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] kbuild: use perl instead of shell to get file size
Date: Fri, 3 Dec 2021 00:45:46 +0000	[thread overview]
Message-ID: <5AD03AD1-4422-4F91-85DF-086E11A47FA9@fb.com> (raw)
In-Reply-To: <20211124153105.155739-1-alex_y_xu@yahoo.ca>



> On Nov 24, 2021, at 7:31 AM, Alex Xu (Hello71) <alex_y_xu@yahoo.ca> wrote:
> 
> This makes it easier to get the size of multiple files. Perl is already
> a requirement for all builds to do header checks, so this is not an
> additional dependency.
> ---
> arch/arm/boot/deflate_xip_data.sh | 2 +-
> arch/powerpc/boot/wrapper         | 2 +-
> scripts/Makefile.lib              | 9 ++-------
> scripts/file-size.pl              | 8 ++++++++
> scripts/file-size.sh              | 4 ----
> scripts/link-vmlinux.sh           | 4 ++--
> 6 files changed, 14 insertions(+), 15 deletions(-)
> create mode 100755 scripts/file-size.pl
> delete mode 100755 scripts/file-size.sh
> 
> diff --git a/arch/arm/boot/deflate_xip_data.sh b/arch/arm/boot/deflate_xip_data.sh
> index 304495c3c2c5..14cfa2babb93 100755
> --- a/arch/arm/boot/deflate_xip_data.sh
> +++ b/arch/arm/boot/deflate_xip_data.sh
> @@ -43,7 +43,7 @@ data_start=$(($__data_loc - $base_offset))
> data_end=$(($_edata_loc - $base_offset))
> 
> # Make sure data occupies the last part of the file.
> -file_end=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" "$XIPIMAGE")
> +file_end=$(${PERL} "${srctree}/scripts/file-size.pl" "$XIPIMAGE")
> if [ "$file_end" != "$data_end" ]; then
> 	printf "end of xipImage doesn't match with _edata_loc (%#x vs %#x)\n" \
> 	       $(($file_end + $base_offset)) $_edata_loc 1>&2
> diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
> index 9184eda780fd..9f9ee8613432 100755
> --- a/arch/powerpc/boot/wrapper
> +++ b/arch/powerpc/boot/wrapper
> @@ -380,7 +380,7 @@ vmz="$tmpdir/`basename \"$kernel\"`.$ext"
> 
> # Calculate the vmlinux.strip size
> ${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
> -strip_size=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" "$vmz.$$")
> +strip_size=$(${PERL} "${srctree}/scripts/file-size.pl" "$vmz.$$")
> 
> if [ -z "$cacheit" -o ! -f "$vmz$compression" -o "$vmz$compression" -ot "$kernel" ]; then
>     # recompress the image if we need to
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index d1f865b8c0cb..ca901814986a 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -379,13 +379,8 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
> 
> # Bzip2 and LZMA do not include size in file... so we have to fake that;
> # append the size as a 32-bit littleendian number as gzip does.
> -size_append = printf $(shell						\
> -dec_size=0;								\
> -for F in $(real-prereqs); do					\
> -	fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F);	\
> -	dec_size=$$(expr $$dec_size + $$fsize);				\
> -done;									\
> -printf "%08x\n" $$dec_size |						\
> +total_size = $(shell $(PERL) $(srctree)/scripts/file-size.pl $(real-prereqs))
> +size_append = printf $(shell printf "%08x\n" $(total_size) |		\
> 	sed 's/\(..\)/\1 /g' | {					\
> 		read ch0 ch1 ch2 ch3;					\
> 		for ch in $$ch3 $$ch2 $$ch1 $$ch0; do			\
> diff --git a/scripts/file-size.pl b/scripts/file-size.pl
> new file mode 100755
> index 000000000000..170bb6d048fa
> --- /dev/null
> +++ b/scripts/file-size.pl
> @@ -0,0 +1,8 @@
> +#!/usr/bin/perl -w
> +# SPDX-License-Identifier: GPL-2.0
> +my $total = 0;
> +foreach (@ARGV) {
> +    @stat = stat $_ or die "$_: $!";
> +    $total += $stat[7];
> +}
> +print "$total\n";
> diff --git a/scripts/file-size.sh b/scripts/file-size.sh
> deleted file mode 100755
> index 7eb7423416b5..000000000000
> --- a/scripts/file-size.sh
> +++ /dev/null
> @@ -1,4 +0,0 @@
> -#!/bin/sh
> -# SPDX-License-Identifier: GPL-2.0
> -set -- $(ls -dn "$1")
> -printf '%s\n' "$5"
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index 5cdd9bc5c385..c3fa38bd18ab 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -384,8 +384,8 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
> 	kallsyms_step 2
> 
> 	# step 3
> -	size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso_prev})
> -	size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
> +	size1=$(${PERL} "${srctree}/scripts/file-size.pl" ${kallsymso_prev})
> +	size2=$(${PERL} "${srctree}/scripts/file-size.pl" ${kallsymso})
> 
> 	if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
> 		kallsyms_step 3
> -- 
> 2.34.0
> 

You can add:

Tested-by: Nick Terrell <terrelln@fb.com>

  parent reply	other threads:[~2021-12-03  0:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20211124153105.155739-1-alex_y_xu.ref@yahoo.ca>
2021-11-24 15:31 ` Alex Xu (Hello71)
2021-11-24 15:31   ` [PATCH v2 2/2] kbuild: pass --stream-size --no-content-size to zstd Alex Xu (Hello71)
2021-12-03  0:49     ` Nick Terrell
2021-12-05 22:52     ` Masahiro Yamada
2021-12-06 18:42       ` Nick Terrell
2021-12-17  8:51     ` Sedat Dilek
2021-12-17 13:44       ` Sedat Dilek
2021-12-03  0:45   ` Nick Terrell [this message]
2021-12-17 13:45   ` [PATCH v2 1/2] kbuild: use perl instead of shell to get file size Sedat Dilek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5AD03AD1-4422-4F91-85DF-086E11A47FA9@fb.com \
    --to=terrelln@fb.com \
    --cc=alex_y_xu@yahoo.ca \
    --cc=forney@google.com \
    --cc=keescook@chromium.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=mingo@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=sedat.dilek@gmail.com \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®