2018-04-18 03:34:24

by Stephen Rothwell

[permalink] [raw]
Subject: linux-next: build failure after merge of the arm-current tree

Hi Russell,

After merging the arm-current tree, today's linux-next build
(lots of configs) failed like this:

/bin/sh: 1: arithmetic expression: expecting primary: " "
(lots of these)

Caused by commit

fe680ca02c1e ("ARM: replace unnecessary perl with sed and the shell $(( )) operator")

(pointed out by Michael Ellerman)

Our /bin/sh is dash not bash ...

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2018-04-18 17:56:41

by Russell King

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the arm-current tree

On Wed, Apr 18, 2018 at 01:31:55PM +1000, Stephen Rothwell wrote:
> Hi Russell,
>
> After merging the arm-current tree, today's linux-next build
> (lots of configs) failed like this:
>
> /bin/sh: 1: arithmetic expression: expecting primary: " "
> (lots of these)
>
> Caused by commit
>
> fe680ca02c1e ("ARM: replace unnecessary perl with sed and the shell $(( )) operator")
>
> (pointed out by Michael Ellerman)
>
> Our /bin/sh is dash not bash ...

I tested this on 32-bit ARM with dash:

foo# dash
# echo $(($(nm /boot/vmlinux-4.16.0+ | sed -n -e 's/^\([^ ]*\) B __bss_start$/-0x\1/p' -e 's/^\([^ ]*\) B __bss_stop$/+0x\1/p') ))
6409680
#

Any clues what '/bin/sh: 1: arithmetic expression: expecting primary: " "'
actually means in reality?

I don't see why you should end up with lots of them either, unless maybe
the sed expression isn't working for you.

The sed expression should end up producing output such as:

-0xc09138c4
+0xc0f30694

and that's it, two values, one preceded by a + and the other by a -.

--
Russell King
ARM architecture Linux Kernel maintainer

2018-04-18 18:20:15

by Russell King

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the arm-current tree

On Wed, Apr 18, 2018 at 06:54:42PM +0100, Russell King wrote:
> On Wed, Apr 18, 2018 at 01:31:55PM +1000, Stephen Rothwell wrote:
> > Hi Russell,
> >
> > After merging the arm-current tree, today's linux-next build
> > (lots of configs) failed like this:
> >
> > /bin/sh: 1: arithmetic expression: expecting primary: " "
> > (lots of these)
> >
> > Caused by commit
> >
> > fe680ca02c1e ("ARM: replace unnecessary perl with sed and the shell $(( )) operator")
> >
> > (pointed out by Michael Ellerman)
> >
> > Our /bin/sh is dash not bash ...
>
> I tested this on 32-bit ARM with dash:
>
> foo# dash
> # echo $(($(nm /boot/vmlinux-4.16.0+ | sed -n -e 's/^\([^ ]*\) B __bss_start$/-0x\1/p' -e 's/^\([^ ]*\) B __bss_stop$/+0x\1/p') ))
> 6409680
> #
>
> Any clues what '/bin/sh: 1: arithmetic expression: expecting primary: " "'
> actually means in reality?
>
> I don't see why you should end up with lots of them either, unless maybe
> the sed expression isn't working for you.
>
> The sed expression should end up producing output such as:
>
> -0xc09138c4
> +0xc0f30694
>
> and that's it, two values, one preceded by a + and the other by a -.

Hmm, I guess it's a result of:

# echo $(( ))
dash: 4: arithmetic expression: expecting primary: " "

which points to the sed expression producing no output. If that's the
case, then something else went wrong with the build earlier - there
should be no case where the built vmlinux does not contain the
__bss_start and __bss_stop symbols on ARM, since every kernel contains
a .bss section.

Olof's autobuilder shows no errors, but that could be because it's
using bash - I don't know. kernelci.org also shows no failures.

I think more information is needed to debug this, such as:

- does nm of the vmlinux contain the __bss_start and __bss_stop
symbols, and are they formatted as one would expect (iow, marked
as a global BSS symbol?)
- does the nm | sed pipeline produce the expected output when run
outside of everything else?
- does dash evaluate the output correctly outside of the makefile?

As I'm not currently aware of a failing environment that I have
access to, I'm not able to debug this myself, sorry.

--
Russell King
ARM architecture Linux Kernel maintainer

2018-04-18 23:54:55

by Stephen Rothwell

[permalink] [raw]
Subject: Re: linux-next: build failure after merge of the arm-current tree

Hi Russell,

On Wed, 18 Apr 2018 19:17:23 +0100 Russell King <[email protected]> wrote:
>
> Hmm, I guess it's a result of:
>
> # echo $(( ))
> dash: 4: arithmetic expression: expecting primary: " "
>
> which points to the sed expression producing no output. If that's the
> case, then something else went wrong with the build earlier - there
> should be no case where the built vmlinux does not contain the
> __bss_start and __bss_stop symbols on ARM, since every kernel contains
> a .bss section.
>
> Olof's autobuilder shows no errors, but that could be because it's
> using bash - I don't know. kernelci.org also shows no failures.
>
> I think more information is needed to debug this, such as:
>
> - does nm of the vmlinux contain the __bss_start and __bss_stop
> symbols, and are they formatted as one would expect (iow, marked
> as a global BSS symbol?)

$ /opt/cross/gcc-4.6.3-nolibc/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-nm vmlinux | grep __bss_st
008af260 A __bss_start
008b4394 A __bss_stop

so, that's our problem. Note we are building with gcc 4.6.3 and binutils 2.22

> - does the nm | sed pipeline produce the expected output when run
> outside of everything else?
> - does dash evaluate the output correctly outside of the makefile?

so dash returns the above error for 'echo $(( ))' and bash returns '0'

I had to actually symlink /bin/sh to dash to get it to fail - running
with in dash and setting SHELL to /bin/dash was not sufficient.

So under bash, we don't get an error, but we use 0 as the bss length :-(

I will this patch to linux-next today:

From: Stephen Rothwell <[email protected]>
Date: Thu, 19 Apr 2018 09:46:22 +1000
Subject: [PATCH] arm: check for A as well as B type sybols when calculating BSS size

older compilers produce those

Fixes: 429f7a062e3b ("ARM: decompressor: fix BSS size calculation")
Signed-off-by: Stephen Rothwell <[email protected]>
---
arch/arm/boot/compressed/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index b0354dfc7055..6a4e7341ecd3 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -118,8 +118,8 @@ asflags-y := -DZIMAGE

# Supply kernel BSS size to the decompressor via a linker symbol.
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') )) )
+ sed -n -e 's/^\([^ ]*\) [AB] __bss_start$$/-0x\1/p' \
+ -e 's/^\([^ ]*\) [AB] __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)
--
2.17.0

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature