All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
To: Markus Mayer <mmayer@broadcom.com>,
	Arnout Vandecappelle <arnout@mind.be>,
	Petr Vorel <petr.vorel@gmail.com>
Cc: Buildroot Mailing List <buildroot@buildroot.org>
Subject: Re: [Buildroot] [PATCH 0/1] Build issue related to "command -v"
Date: Wed, 29 Sep 2021 10:24:51 +0200	[thread overview]
Message-ID: <a3acad98-edb0-1ac7-8d84-a3937a405646@green-communications.fr> (raw)
In-Reply-To: <20210928195533.1736944-1-mmayer@broadcom.com>

On 28/09/2021 21:55, Markus Mayer via buildroot wrote:
> Please note that "command -v" in bash does*NOT*  do this! Bash's
> "command -v" seems to behave just like "which" used to. Yikes!
> 
> bash$ command -v $HOSTCC_NOCCACHE
> /local/users/mmayer/buildroot/output/arm64/host/bin/ccache
> /usr/bin/gcc
> 
> bash$ `command -v $HOSTCC_NOCCACHE` -v 2>&1 | grep 'gcc version'
> gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)
> 
> I can't stress this enough. "command -v" behaves differently for bash
> and dash! This does not give me the warm and fuzzies.

POSIX 2008 is very clear on this: additional parameters to command -v 
must be ignored, so bash is non-conformant.

Additionally, the dependencies.sh script should probably quote the shell 
variables that it uses. This would have caught the problem much earlier.
Unless HOSTCC is allowed to contain multiple parameters, but i'm not 
sure if buildroot maintainers consider this to be allowed.

> As such, relying on "command -v" seems a little risky in that it opens
> up the possibility for strange build errors that others cannot reproduce
> and that nobody would ever think to investigate as being related to the
> "command -v" implementation of a specific shell.
 >
> There is also the issue of some developers working with different
> distributions. Somebody developing a feature on distro 1 might create
> build problems for others using distro 2 and vice versa. Neither would
> have a way of knowing ahead of time that there will be an issue.

This is why there are standards and why respecting them is important, 
otherwise it would be impossible to get anything done.

command -v is defined since 2008 and any shell that misbehave has a bug 
that need to be fixed. Of course there can be workaround here and here. 
For example, there are 'command -v CMD || type -p CMD' patterns in the 
main Makefile already.

Meanwhile, 'which' is not standard, and right now, it misbehaves on 
Debian by filling the screen with warnings.

> I am wondering if it might be prudent to provide a host-which package,
> such that Buildroot can build its own "which" command if the system
> doesn't have one and stick to using "which" despite it being deprecated.
> At least for the time being and until "command -v" can be explored and
> evaluated a bit more.

This is a chicken-and-egg problem. How do you compile host-which without 
being able to test if gcc or make are available ?
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2021-09-29  8:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 19:55 [Buildroot] [PATCH 0/1] Build issue related to "command -v" Markus Mayer via buildroot
2021-09-28 19:55 ` [Buildroot] [PATCH 1/1] Makefile: set HOST*_NOCCACHE variables only if unset Markus Mayer via buildroot
2021-09-29 19:27   ` Petr Vorel
2021-12-28 21:18   ` Thomas Petazzoni
2021-12-28 21:26     ` Nicolas Cavallari
2021-12-29  9:00       ` Thomas Petazzoni
2021-12-29  9:12   ` Thomas Petazzoni
2021-09-29  8:24 ` Nicolas Cavallari [this message]
2021-09-29 16:14   ` [Buildroot] [PATCH 0/1] Build issue related to "command -v" David Laight
2021-09-29 17:30     ` Petr Vorel
2021-09-29 19:59 ` Arnout Vandecappelle
2021-09-29 20:11   ` Petr Vorel
2021-10-01 17:53     ` Markus Mayer via buildroot
2021-10-01 18:17       ` Yann E. MORIN
2021-10-02 19:23         ` Petr Vorel

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=a3acad98-edb0-1ac7-8d84-a3937a405646@green-communications.fr \
    --to=nicolas.cavallari@green-communications.fr \
    --cc=arnout@mind.be \
    --cc=buildroot@buildroot.org \
    --cc=mmayer@broadcom.com \
    --cc=petr.vorel@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.