All of lore.kernel.org
 help / color / mirror / Atom feed
From: Schwarz, Konrad <konrad.schwarz@siemens.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/3] package/environment-setup: make script idempotent
Date: Thu, 7 Jan 2021 09:57:34 +0000	[thread overview]
Message-ID: <8ad435cc3aa244418144fe451e23430f@siemens.com> (raw)
In-Reply-To: <CANQCQpZzAiF1AsrJThuH_H+cc3TXRykEMFkEXWkbPczPaN48yQ@mail.gmail.com>

Hi Matt,

> -----Original Message-----
> From: Matthew Weber <matthew.weber@collins.com>
> Sent: Wednesday, January 6, 2021 18:34
> To: Schwarz, Konrad (T RDA IOT SES-DE) <konrad.schwarz@siemens.com>
> Cc: buildroot <buildroot@buildroot.org>
> Subject: Re: [Buildroot] [PATCH 2/3] package/environment-setup: make script idempotent
> 
> > One (slight) problem with this kind of environment setup files is when
> > they are executed repeatedly (e.g., because something else is not
> > quite right yet), they tend to extend the PATH variable with the same
> > directory, creating a very unwieldy search path and potentially
> > slowing down searches for executable files.
> >
> > This fix adds a test such that PATH is extended only when necessary.
> >
[...]
> +       'export "CROSS_COMPILE=$(TARGET_CROSS)"\n'\
[...]
> > +       'if ! command -v $${CROSS_COMPILE}gcc > /dev/null\n'\
> > +       'then   export PATH="$$SDK_PATH/bin:$$SDK_PATH/sbin:$$PATH"\n'\
> > +       'fi\n'\
> 
> Does this new path check work as you intend if the main system has the normal gcc tools installed?  Maybe checking for the cross
> variable not being empty would be a better option?

As an aside: if the main system hast the "normal gcc tools" installed (I'm assuming you mean the native tools) and visible on PATH you wouldn't want PATH extended either, right?

As written, the code extends PATH only when the Buildroot-specific cross-compilation toolchain cannot be found (using a PATH search).  Conversely: if the Buildroot-specific toolchain is already in PATH, PATH won't be extended.

The only situation I see in which this might be undesirable is if an identically-prefixed toolchain that should not be used were already in the PATH; the original code would simply override that (because it prefixes PATH).   I consider this a remote possibility, because the "vendor" part of the GNU target triplet should be unique to Buildroot, at least when using the internal compilation toolchain option; but fundamentally the same reasoning should apply to the external toolchain option (e.g., buildroot assumes the user knows what he is doing in this case).

When debugging PATH problems, I'd much prefer to have as clean of a PATH as possible; elimination of (redundant) duplicates is a key part of this.

Note that the script itself sets CROSS_COMPILE at the start, so I don't see when it would be empty.

--
Konrad

  reply	other threads:[~2021-01-07  9:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-31 21:29 [Buildroot] [PATCH 0/3] package/environment-setup: minor improvements to Konrad Schwarz
2020-12-31 21:29 ` [Buildroot] [PATCH 1/3] package/environment-setup: fix spelling of the script file in the manual Konrad Schwarz
2021-01-03 17:29   ` [Buildroot] [PATCH 4/4] " Konrad Schwarz
2021-01-06 16:37     ` Matthew Weber
2021-01-07 22:13     ` Arnout Vandecappelle
2021-01-08  7:46   ` [Buildroot] [PATCH 1/3] " Peter Korsgaard
2020-12-31 21:29 ` [Buildroot] [PATCH 2/3] package/environment-setup: make script idempotent Konrad Schwarz
2021-01-06 17:34   ` Matthew Weber
2021-01-07  9:57     ` Schwarz, Konrad [this message]
2021-01-07 18:57       ` [Buildroot] [External] " Matthew Weber
2021-01-07 21:15         ` Schwarz, Konrad
2021-01-07 21:27           ` Arnout Vandecappelle
2021-01-08 13:10             ` Schwarz, Konrad
2021-01-11 21:18               ` Arnout Vandecappelle
2021-01-07 21:43   ` [Buildroot] " Arnout Vandecappelle
2021-01-08 12:32     ` Schwarz, Konrad
2021-01-11 21:58       ` Arnout Vandecappelle
2020-12-31 21:29 ` [Buildroot] [PATCH 3/3] package/environment-setup: improve legibility Konrad Schwarz

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=8ad435cc3aa244418144fe451e23430f@siemens.com \
    --to=konrad.schwarz@siemens.com \
    --cc=buildroot@busybox.net \
    /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.