All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <petr.vorel@gmail.com>
To: Arnout Vandecappelle <arnout@mind.be>
Cc: "Yann E. MORIN" <yann.morin.1998@free.fr>,
	David Laight <David.Laight@aculab.com>,
	Markus Mayer <mmayer@broadcom.com>,
	Buildroot Mailing List <buildroot@buildroot.org>
Subject: Re: [Buildroot] [PATCH 0/1] Build issue related to "command -v"
Date: Wed, 29 Sep 2021 22:11:46 +0200	[thread overview]
Message-ID: <YVTIghzHs82uFBIe@pevik> (raw)
In-Reply-To: <a87c586e-1e73-a3e3-7722-c56e48809d76@mind.be>

Hi Markus, Arnout, all,

>  Hi Markus,

>  Thank you for this extensive investigation!

> On 28/09/2021 21:55, Markus Mayer wrote:
> > Hi all,

> > After commit ca6a2907c27c[1], our automated nightly builds started
> > experiencing build failures. It took a little while to track down what
> > was happening. I think I understand now what is going on.

> > This is a bit of a lengthy email as it was a bit of a lengthy
> > investigation, and I want to relay my findings and some concerns.

> [snip]

> > One thing of note is that our post-build script calls "make legal-info",
> > and that is when the problem happens. The purpose of doing it like this
> > is to include the result of "make legal-info" in the image.

>  Calling into Buildroot's Makefile recursively from within a post-build
> script (or a package or whatever) is not something that is supported, in the
> sense that it's not something that anybody ever tests. The use case
> definitely makes sense though. I even heard of people starting the build of
> a different configuration in a post-build script (e.g. for an initramfs).

>  So maybe we should add a test in support/testing that validates this scenario.
+1


> > However, when make is invoked a second time with HOSTCC already
> > defined to call ccache, it'll still assign
> >     HOSTCC_NOCCACHE := $(HOSTCC)
> > which now redefines HOSTCC_NOCCACHE to *INCLUDE* ccache (since HOSTCC
> > does, from earlier)!

>  This is clearly wrong. Your patch helps, but we still have a similar
> situation with HOSTCC which will be .../ccache .../ccache /usr/bin/gcc in
> the recursive invocation (i.e. with two times ccache). Although maybe that's
> not really an issue - "ccache ccache gcc -v" at least gives the expected
> results.
Ah, sorry for not catching this.

>  I'm thinking that maybe we should detect recursive invocation in the
> top-level Makefile and behave differently. For example, everything that is
> exported doesn't need to be exported again, and stuff like that. Or at least
> we could protect the entire HOSTCC etc. block against recursive override.
+1

>  Also, the entire handling of HOSTCC is a bit flaky. It is still from
> prehistoric commit 8027784 with no clear requirements (e.g. is HOSTCC
> allowed to be a command with arguments? Is it allowed to be a relative
> path?). It has been documented after-the-fact in
> docs/manual/common-usage.txt, but I wonder if we really still need it? I
> guess it's a way for people to use a host compiler that is more recent that
> the distro-provided one, but it could just as well be added to $PATH and be
> done with it...

> [snip]

> > Here is where it gets interesting. "which" will return two lines, one
> > for each of the commands:

> > $ which $HOSTCC_NOCCACHE
> > /local/users/mmayer/buildroot/output/arm64/host/bin/ccache
> > /usr/bin/gcc

>  As mentioned by Nicolas, we really should quote the argument to "command
> -v", or apply $(firstword ...) to avoid this issue. Indepedent of which or
> command -v.
+1 
IMHO quoting would require fixing unwanted redefinition
HOSTCC_NOCCACHE, ($(firstword ...) would not but hide the issue, thus I'd prefer
fixing the redefinition.

> [snip]

> > 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.

>  It is solving an actual problem (i.e. that "which" is deprecated in some
> distros), so the best we can do is make the change early enough before a
> release so people can discover problems with it.


> > 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.

>  That issue exists regardless of "which" (which BTW has different
> implementations on different distros anyway, so it can also cause problems).
+1 FYI there is LTP script to cover some which functionality [1]. IMHO type or
command -v are more tested in shell implementation than this simple test.
> We try to minimise the external dependencies of Buildroot, and removing
> "which" from the external dependencies is a good thing IMHO.


>  Bottom line: I think we need to take four actions here.

> 1. Apply your patch.
> 2. Improve on it by detecting that the Buildroot overrides have already been
> exported and don't need to be exported again.
> 3. Verify all calls to "command -v" and make sure the argument is either
> quoted or uses $(firstword).
> 4. Consider the removal of HOSTCC and friends as user-settable variables.

Thanks for further investigation.

Kind regards,
Petr

>  Regards,
>  Arnout

[1] https://github.com/linux-test-project/ltp/blob/master/testcases/commands/which/which01.sh
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2021-09-29 20:11 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 ` [Buildroot] [PATCH 0/1] Build issue related to "command -v" Nicolas Cavallari
2021-09-29 16:14   ` David Laight
2021-09-29 17:30     ` Petr Vorel
2021-09-29 19:59 ` Arnout Vandecappelle
2021-09-29 20:11   ` Petr Vorel [this message]
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=YVTIghzHs82uFBIe@pevik \
    --to=petr.vorel@gmail.com \
    --cc=David.Laight@aculab.com \
    --cc=arnout@mind.be \
    --cc=buildroot@buildroot.org \
    --cc=mmayer@broadcom.com \
    --cc=yann.morin.1998@free.fr \
    /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.