* [PATCH] Replace unnecessary perl with sed, printf, and the shell $(( )) operator.
@ 2018-04-12 1:38 Rob Landley
2018-04-16 12:09 ` Russell King - ARM Linux
0 siblings, 1 reply; 3+ messages in thread
From: Rob Landley @ 2018-04-12 1:38 UTC (permalink / raw)
To: linux-kernel, linux, kstewart, pombredanne, tglx, gregkh,
linux-arm-kernel, Tony Lindgren, Keerthy, Russell King
You can build a kernel in a cross compiling environment that doesn't have perl
in the $PATH. Commit 429f7a062e3b broke that for 32 bit arm. Fix it.
Signed-off-by: Rob Landley <rob@landley.net>
---
arch/arm/boot/compressed/Makefile | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 45a6b9b..33ebeb2 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -117,11 +117,10 @@ ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
asflags-y := -DZIMAGE
# Supply kernel BSS size to the decompressor via a linker symbol.
-KBSS_SZ = $(shell $(CROSS_COMPILE)nm $(obj)/../../../../vmlinux | \
- perl -e 'while (<>) { \
- $$bss_start=hex($$1) if /^([[:xdigit:]]+) B __bss_start$$/; \
- $$bss_end=hex($$1) if /^([[:xdigit:]]+) B __bss_stop$$/; \
- }; printf "%d\n", $$bss_end - $$bss_start;')
+KBSS_SZ := $(shell echo $$(($$(printf '%d+%d' $$( \
+ $(CROSS_COMPILE)nm $(obj)/../../../../vmlinux | \
+ sed -n -e 's/^\([^ ]*\) B __bss_start$$/-0x\1/p' \
+ -e 's/^\([^ ]*\) B __bss_stop$$/0x\1/p') ) )) )
LDFLAGS_vmlinux = --defsym _kernel_bss_size=$(KBSS_SZ)
# Supply ZRELADDR to the decompressor via a linker symbol.
ifneq ($(CONFIG_AUTO_ZRELADDR),y)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Replace unnecessary perl with sed, printf, and the shell $(( )) operator.
2018-04-12 1:38 [PATCH] Replace unnecessary perl with sed, printf, and the shell $(( )) operator Rob Landley
@ 2018-04-16 12:09 ` Russell King - ARM Linux
2018-04-16 12:19 ` Rob Landley
0 siblings, 1 reply; 3+ messages in thread
From: Russell King - ARM Linux @ 2018-04-16 12:09 UTC (permalink / raw)
To: Rob Landley
Cc: linux-kernel, kstewart, pombredanne, tglx, gregkh,
linux-arm-kernel, Tony Lindgren, Keerthy
On Wed, Apr 11, 2018 at 08:38:37PM -0500, Rob Landley wrote:
> You can build a kernel in a cross compiling environment that doesn't have perl
> in the $PATH. Commit 429f7a062e3b broke that for 32 bit arm. Fix it.
>
> Signed-off-by: Rob Landley <rob@landley.net>
> ---
>
> arch/arm/boot/compressed/Makefile | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
> index 45a6b9b..33ebeb2 100644
> --- a/arch/arm/boot/compressed/Makefile
> +++ b/arch/arm/boot/compressed/Makefile
> @@ -117,11 +117,10 @@ ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
> asflags-y := -DZIMAGE
>
> # Supply kernel BSS size to the decompressor via a linker symbol.
> -KBSS_SZ = $(shell $(CROSS_COMPILE)nm $(obj)/../../../../vmlinux | \
> - perl -e 'while (<>) { \
> - $$bss_start=hex($$1) if /^([[:xdigit:]]+) B __bss_start$$/; \
> - $$bss_end=hex($$1) if /^([[:xdigit:]]+) B __bss_stop$$/; \
> - }; printf "%d\n", $$bss_end - $$bss_start;')
> +KBSS_SZ := $(shell echo $$(($$(printf '%d+%d' $$( \
> + $(CROSS_COMPILE)nm $(obj)/../../../../vmlinux | \
> + sed -n -e 's/^\([^ ]*\) B __bss_start$$/-0x\1/p' \
> + -e 's/^\([^ ]*\) B __bss_stop$$/0x\1/p') ) )) )
This looks more complicated than necessary, and therefore less readable.
What's wrong with:
KBSS_SZ := $(shell echo $$(($$($(CROSS_COMPILE)nm $(obj)/../../../../vmlinux | \
sed -n -e 's/^\([^ ]*\) B __bss_start$$/-0x\1/p' \
-e 's/^\([^ ]*\) B __bss_stop$$/+0x\1/p') ))
The sed command produces output such as:
-0xc0955e58
+0xc10b0f9c
which the shell is then able to evaluate and produce a decimal number.
This seems to work fine with both bash and dash.
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Replace unnecessary perl with sed, printf, and the shell $(( )) operator.
2018-04-16 12:09 ` Russell King - ARM Linux
@ 2018-04-16 12:19 ` Rob Landley
0 siblings, 0 replies; 3+ messages in thread
From: Rob Landley @ 2018-04-16 12:19 UTC (permalink / raw)
To: Russell King - ARM Linux
Cc: linux-kernel, kstewart, pombredanne, tglx, gregkh,
linux-arm-kernel, Tony Lindgren, Keerthy
On 04/16/2018 07:09 AM, Russell King - ARM Linux wrote:
> On Wed, Apr 11, 2018 at 08:38:37PM -0500, Rob Landley wrote:
>> You can build a kernel in a cross compiling environment that doesn't have perl
>> in the $PATH. Commit 429f7a062e3b broke that for 32 bit arm. Fix it.
...
> This looks more complicated than necessary, and therefore less readable.
> What's wrong with:
>
> KBSS_SZ := $(shell echo $$(($$($(CROSS_COMPILE)nm $(obj)/../../../../vmlinux | \
> sed -n -e 's/^\([^ ]*\) B __bss_start$$/-0x\1/p' \
> -e 's/^\([^ ]*\) B __bss_stop$$/+0x\1/p') ))
>
> The sed command produces output such as:
>
> -0xc0955e58
> +0xc10b0f9c
>
> which the shell is then able to evaluate and produce a decimal number.
> This seems to work fine with both bash and dash.
Yes, that is better.
Acked-by: Rob Landley <rob@landley.net>
Thanks,
Rob
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-04-16 12:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-12 1:38 [PATCH] Replace unnecessary perl with sed, printf, and the shell $(( )) operator Rob Landley
2018-04-16 12:09 ` Russell King - ARM Linux
2018-04-16 12:19 ` Rob Landley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).