Re: [PATCH] init/Kconfig: fix CC_HAS_ASM_GOTO_TIED_OUTPUT test with dash

From: Richard Purdie
Date: Mon Aug 22 2022 - 17:59:54 EST


On Fri, 2022-08-19 at 17:40 +0900, Masahiro Yamada wrote:
> On Fri, Aug 19, 2022 at 6:46 AM Richard Purdie
> <richard.purdie@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> > On Fri, 2022-08-19 at 04:31 +0900, Masahiro Yamada wrote:
> > > On Thu, Aug 18, 2022 at 6:14 PM Richard Purdie
> > > <richard.purdie@xxxxxxxxxxxxxxxxxxx> wrote:
> > > >
> > > > This problem is a little more subtle.
> > > >
> > > > As far as I could work out, exec() is used on entries like this in
> > > > kConfig. exec() falls back to /bin/sh so it is hard to see where this
> > > > would be changed to be /bin/bash.
> > >
> > >
> > >
> > > Kconfig uses popen() to execute a shell command.
> > >
> > > See do_shell() in scripts/kconfig/preprocess.c
> > >
> > > popen(3) says that
> > > "the command is passed to /bin/sh using the -c flag.
> > > interpretation, if any, is performed by the shell."
> > >
> > > GNU Make is the same.
> > > Make uses /bin/sh to execute commands in
> > > recipe lines and $(shell ...) functions.
> > > You can change the default shell via 'SHELL' variable.
> >
> > That makes sense. I don't think we can easily change the shell popen()
> > uses.
> >
> > >
> > > BTW, Richard is here, so let me ask about BitBake.
> > >
> > > The manual [3] clearly says:
> > >
> > > "When you create these types of functions in your recipe or class files,
> > > you need to follow the shell programming rules. The scripts are
> > > executed by /bin/sh,
> > > which may not be a bash shell but might be something such as dash.
> > > You should not use Bash-specific script (bashisms)"
> > >
> > > I just thought BitBake ran shell code in bash before,
> > > but I might have misunderstood.
> > > Do OE/Yocto allow only POSIX shell code?
> >
> > Bitbake runs shell code with /bin/sh so we don't allow bashisms and
> > that has always been the case.
> >
> > Like this case in the kernel, we do get people submitting changes which
> > were only tested with bash which can be frustrating but the manual and
> > our policy is quite clear. We just fix any that do creep through and
> > have test systems that have dash to try and catch them too.
> >
> > Cheers,
> >
> > Richard
>
> Thanks.
> So, Bitbake is the same approach as the kernel.

Yes, effectively.
>
> This is a patch set to use bash forcibly. FWIW.
>
> https://lore.kernel.org/lkml/20220819065604.295572-1-masahiroy@xxxxxxxxxx/

Thanks, I'm watching with interest to see what happens.

The original patch causing issues was backported into several stable
releases and this won't be so we have a bit of a challenge there but we
have also started carrying patches to fix that too so as long as things
get fixed in master we should be ok in the long run and I'm happy.

Cheers,

Richard