diff mbox series

[01/16] lib/raid6/test: fix build on distros whose /bin/sh is not bash

Message ID 20200324084821.29944-2-masahiroy@kernel.org (mailing list archive)
State Not Applicable
Delegated to: Herbert Xu
Headers show
Series x86, crypto: remove always-defined CONFIG_AS_* and cosolidate Kconfig/Makefiles | expand

Commit Message

Masahiro Yamada March 24, 2020, 8:48 a.m. UTC
You can test raid6 library code from user-space, like this:

  $ cd lib/raid6/test
  $ make

The command in $(shell ...) function is evaluated by /bin/sh by default.
(or, you can change the default shell by setting 'SHELL' in Makefile)

Currently '>&/dev/null' is used to sink both stdout and stderr. Because
this code is bash-ism, it only works when /bin/sh is a symbolic link to
bash (this is the case on RHEL etc.)

This does not work on Ubuntu where /bin/sh is a symbolic link to dash.

I see lots of

  /bin/sh: 1: Syntax error: Bad fd number

and

  warning "your version of binutils lacks ... support"

Replace it with portable '>/dev/null 2>&1'.

Fixes: 4f8c55c5ad49 ("lib/raid6: build proper files on corresponding arch")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---

 lib/raid6/test/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Nick Desaulniers March 24, 2020, 4:36 p.m. UTC | #1
On Tue, Mar 24, 2020 at 1:49 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> You can test raid6 library code from user-space, like this:
>
>   $ cd lib/raid6/test
>   $ make
>
> The command in $(shell ...) function is evaluated by /bin/sh by default.
> (or, you can change the default shell by setting 'SHELL' in Makefile)
>
> Currently '>&/dev/null' is used to sink both stdout and stderr. Because
> this code is bash-ism, it only works when /bin/sh is a symbolic link to
> bash (this is the case on RHEL etc.)
>
> This does not work on Ubuntu where /bin/sh is a symbolic link to dash.
>
> I see lots of
>
>   /bin/sh: 1: Syntax error: Bad fd number
>
> and
>
>   warning "your version of binutils lacks ... support"
>
> Replace it with portable '>/dev/null 2>&1'.
>
> Fixes: 4f8c55c5ad49 ("lib/raid6: build proper files on corresponding arch")
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Acked-by: H. Peter Anvin (Intel) <hpa@zytor.com>
> ---
>
>  lib/raid6/test/Makefile | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/raid6/test/Makefile b/lib/raid6/test/Makefile
> index 3ab8720aa2f8..b9e6c3648be1 100644
> --- a/lib/raid6/test/Makefile
> +++ b/lib/raid6/test/Makefile
> @@ -35,13 +35,13 @@ endif
>  ifeq ($(IS_X86),yes)
>          OBJS   += mmx.o sse1.o sse2.o avx2.o recov_ssse3.o recov_avx2.o avx512.o recov_avx512.o
>          CFLAGS += $(shell echo "pshufb %xmm0, %xmm0" |         \
> -                    gcc -c -x assembler - >&/dev/null &&       \
> +                    gcc -c -x assembler - >/dev/null 2>&1 &&   \
>                      rm ./-.o && echo -DCONFIG_AS_SSSE3=1)
>          CFLAGS += $(shell echo "vpbroadcastb %xmm0, %ymm1" |   \
> -                    gcc -c -x assembler - >&/dev/null &&       \
> +                    gcc -c -x assembler - >/dev/null 2>&1 &&   \
>                      rm ./-.o && echo -DCONFIG_AS_AVX2=1)
>         CFLAGS += $(shell echo "vpmovm2b %k1, %zmm5" |          \
> -                   gcc -c -x assembler - >&/dev/null &&        \
> +                   gcc -c -x assembler - >/dev/null 2>&1 &&    \

These should all use $(CC) rather than hardcode gcc.

>                     rm ./-.o && echo -DCONFIG_AS_AVX512=1)
>  else ifeq ($(HAS_NEON),yes)
>          OBJS   += neon.o neon1.o neon2.o neon4.o neon8.o recov_neon.o recov_neon_inner.o
> --
> 2.17.1
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200324084821.29944-2-masahiroy%40kernel.org.
Masahiro Yamada March 26, 2020, 6:48 a.m. UTC | #2
On Wed, Mar 25, 2020 at 1:36 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Tue, Mar 24, 2020 at 1:49 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > You can test raid6 library code from user-space, like this:
> >
> >   $ cd lib/raid6/test
> >   $ make
> >
> > The command in $(shell ...) function is evaluated by /bin/sh by default.
> > (or, you can change the default shell by setting 'SHELL' in Makefile)
> >
> > Currently '>&/dev/null' is used to sink both stdout and stderr. Because
> > this code is bash-ism, it only works when /bin/sh is a symbolic link to
> > bash (this is the case on RHEL etc.)
> >
> > This does not work on Ubuntu where /bin/sh is a symbolic link to dash.
> >
> > I see lots of
> >
> >   /bin/sh: 1: Syntax error: Bad fd number
> >
> > and
> >
> >   warning "your version of binutils lacks ... support"
> >
> > Replace it with portable '>/dev/null 2>&1'.
> >
> > Fixes: 4f8c55c5ad49 ("lib/raid6: build proper files on corresponding arch")
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > Acked-by: H. Peter Anvin (Intel) <hpa@zytor.com>
> > ---
> >
> >  lib/raid6/test/Makefile | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/raid6/test/Makefile b/lib/raid6/test/Makefile
> > index 3ab8720aa2f8..b9e6c3648be1 100644
> > --- a/lib/raid6/test/Makefile
> > +++ b/lib/raid6/test/Makefile
> > @@ -35,13 +35,13 @@ endif
> >  ifeq ($(IS_X86),yes)
> >          OBJS   += mmx.o sse1.o sse2.o avx2.o recov_ssse3.o recov_avx2.o avx512.o recov_avx512.o
> >          CFLAGS += $(shell echo "pshufb %xmm0, %xmm0" |         \
> > -                    gcc -c -x assembler - >&/dev/null &&       \
> > +                    gcc -c -x assembler - >/dev/null 2>&1 &&   \
> >                      rm ./-.o && echo -DCONFIG_AS_SSSE3=1)
> >          CFLAGS += $(shell echo "vpbroadcastb %xmm0, %ymm1" |   \
> > -                    gcc -c -x assembler - >&/dev/null &&       \
> > +                    gcc -c -x assembler - >/dev/null 2>&1 &&   \
> >                      rm ./-.o && echo -DCONFIG_AS_AVX2=1)
> >         CFLAGS += $(shell echo "vpmovm2b %k1, %zmm5" |          \
> > -                   gcc -c -x assembler - >&/dev/null &&        \
> > +                   gcc -c -x assembler - >/dev/null 2>&1 &&    \
>
> These should all use $(CC) rather than hardcode gcc.


Right, I had noticed this.

We often fall between
"let's fix this too while we are here"
vs
"do not do multiple things in a single patch"


If we replace gcc -> $(CC),
we also need to touch line 51 for consistency:

       gcc -c -x c - >/dev/null && rm ./-.o && echo yes)

..., which is not our main interest now.

So, I leave it to a follow-up patch
if somebody has interest in it.
Nick Desaulniers March 26, 2020, 5:27 p.m. UTC | #3
On Wed, Mar 25, 2020 at 11:49 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Wed, Mar 25, 2020 at 1:36 AM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> >
> > On Tue, Mar 24, 2020 at 1:49 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > >
> > > You can test raid6 library code from user-space, like this:
> > >
> > >   $ cd lib/raid6/test
> > >   $ make
> > >
> > > The command in $(shell ...) function is evaluated by /bin/sh by default.
> > > (or, you can change the default shell by setting 'SHELL' in Makefile)
> > >
> > > Currently '>&/dev/null' is used to sink both stdout and stderr. Because
> > > this code is bash-ism, it only works when /bin/sh is a symbolic link to
> > > bash (this is the case on RHEL etc.)
> > >
> > > This does not work on Ubuntu where /bin/sh is a symbolic link to dash.
> > >
> > > I see lots of
> > >
> > >   /bin/sh: 1: Syntax error: Bad fd number
> > >
> > > and
> > >
> > >   warning "your version of binutils lacks ... support"
> > >
> > > Replace it with portable '>/dev/null 2>&1'.
> > >
> > > Fixes: 4f8c55c5ad49 ("lib/raid6: build proper files on corresponding arch")
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > Acked-by: H. Peter Anvin (Intel) <hpa@zytor.com>
> > > ---
> > >
> > >  lib/raid6/test/Makefile | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/lib/raid6/test/Makefile b/lib/raid6/test/Makefile
> > > index 3ab8720aa2f8..b9e6c3648be1 100644
> > > --- a/lib/raid6/test/Makefile
> > > +++ b/lib/raid6/test/Makefile
> > > @@ -35,13 +35,13 @@ endif
> > >  ifeq ($(IS_X86),yes)
> > >          OBJS   += mmx.o sse1.o sse2.o avx2.o recov_ssse3.o recov_avx2.o avx512.o recov_avx512.o
> > >          CFLAGS += $(shell echo "pshufb %xmm0, %xmm0" |         \
> > > -                    gcc -c -x assembler - >&/dev/null &&       \
> > > +                    gcc -c -x assembler - >/dev/null 2>&1 &&   \
> > >                      rm ./-.o && echo -DCONFIG_AS_SSSE3=1)
> > >          CFLAGS += $(shell echo "vpbroadcastb %xmm0, %ymm1" |   \
> > > -                    gcc -c -x assembler - >&/dev/null &&       \
> > > +                    gcc -c -x assembler - >/dev/null 2>&1 &&   \
> > >                      rm ./-.o && echo -DCONFIG_AS_AVX2=1)
> > >         CFLAGS += $(shell echo "vpmovm2b %k1, %zmm5" |          \
> > > -                   gcc -c -x assembler - >&/dev/null &&        \
> > > +                   gcc -c -x assembler - >/dev/null 2>&1 &&    \
> >
> > These should all use $(CC) rather than hardcode gcc.
>
>
> Right, I had noticed this.
>
> We often fall between
> "let's fix this too while we are here"
> vs
> "do not do multiple things in a single patch"
>
>
> If we replace gcc -> $(CC),
> we also need to touch line 51 for consistency:
>
>        gcc -c -x c - >/dev/null && rm ./-.o && echo yes)
>
> ..., which is not our main interest now.
>
> So, I leave it to a follow-up patch
> if somebody has interest in it.

Haha, ok, no worries.
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
diff mbox series

Patch

diff --git a/lib/raid6/test/Makefile b/lib/raid6/test/Makefile
index 3ab8720aa2f8..b9e6c3648be1 100644
--- a/lib/raid6/test/Makefile
+++ b/lib/raid6/test/Makefile
@@ -35,13 +35,13 @@  endif
 ifeq ($(IS_X86),yes)
         OBJS   += mmx.o sse1.o sse2.o avx2.o recov_ssse3.o recov_avx2.o avx512.o recov_avx512.o
         CFLAGS += $(shell echo "pshufb %xmm0, %xmm0" |		\
-                    gcc -c -x assembler - >&/dev/null &&	\
+                    gcc -c -x assembler - >/dev/null 2>&1 &&	\
                     rm ./-.o && echo -DCONFIG_AS_SSSE3=1)
         CFLAGS += $(shell echo "vpbroadcastb %xmm0, %ymm1" |	\
-                    gcc -c -x assembler - >&/dev/null &&	\
+                    gcc -c -x assembler - >/dev/null 2>&1 &&	\
                     rm ./-.o && echo -DCONFIG_AS_AVX2=1)
 	CFLAGS += $(shell echo "vpmovm2b %k1, %zmm5" |          \
-		    gcc -c -x assembler - >&/dev/null &&        \
+		    gcc -c -x assembler - >/dev/null 2>&1 &&	\
 		    rm ./-.o && echo -DCONFIG_AS_AVX512=1)
 else ifeq ($(HAS_NEON),yes)
         OBJS   += neon.o neon1.o neon2.o neon4.o neon8.o recov_neon.o recov_neon_inner.o