mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Hebb <tommyhebb@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Thomas Hebb <tommyhebb@gmail.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Ian Rogers <irogers@google.com>,
	James Clark <James.Clark@arm.com>
Subject: [PATCH 3/3] libsubcmd: Get rid of useless conditional assignments
Date: Sun, 26 Jul 2020 21:08:16 -0700	[thread overview]
Message-ID: <1f8ccfa329a210e2d58608b62c7f731de9fa60c2.1595822871.git.tommyhebb@gmail.com> (raw)
In-Reply-To: <0a6e69d1736b0fa231a648f50b0cce5d8a6734ef.1595822871.git.tommyhebb@gmail.com>

Conditional assignment does not work properly for variables that Make
implicitly sets, among which are CC and AR. To quote
tools/scripts/Makefile.include, which handles this properly:

  # Makefiles suck: This macro sets a default value of $(2) for the
  # variable named by $(1), unless the variable has been set by
  # environment or command line. This is necessary for CC and AR
  # because make sets default values, so the simpler ?= approach
  # won't work as expected.

In other words, the conditional assignments will not run even if the
variables are not overridden in the environment; Make will set CC and AR
to default values when it starts[1], meaning they're not empty by the
time the conditional assignments are evaluated.

Since the assignments never run, we can just get rid of them. CC and AR
are already set properly by Makefile.include using the macro mentioned
in the quote above. In addition, we can get rid of the LD assignment,
because it's also set by Makefile.include.

[1] https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
---

 tools/lib/subcmd/Makefile | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/tools/lib/subcmd/Makefile b/tools/lib/subcmd/Makefile
index 1c777a72bb39..5f2058a6a1ce 100644
--- a/tools/lib/subcmd/Makefile
+++ b/tools/lib/subcmd/Makefile
@@ -9,10 +9,6 @@ srctree := $(patsubst %/,%,$(dir $(srctree)))
 #$(info Determined 'srctree' to be $(srctree))
 endif
 
-CC ?= $(CROSS_COMPILE)gcc
-LD ?= $(CROSS_COMPILE)ld
-AR ?= $(CROSS_COMPILE)ar
-
 RM = rm -f
 
 MAKEFLAGS += --no-print-directory
-- 
2.27.0


  parent reply	other threads:[~2020-07-27  4:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27  4:08 [PATCH 1/3] tools build feature: Use CC and CXX from parent Thomas Hebb
2020-07-27  4:08 ` [PATCH 2/3] tools lib api: Get rid of useless conditional assignments Thomas Hebb
2020-07-27  4:08 ` Thomas Hebb [this message]
2020-07-28 14:42 ` [PATCH 1/3] tools build feature: Use CC and CXX from parent Jiri Olsa
2020-07-28 15:09   ` Arnaldo Carvalho de Melo

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=1f8ccfa329a210e2d58608b62c7f731de9fa60c2.1595822871.git.tommyhebb@gmail.com \
    --to=tommyhebb@gmail.com \
    --cc=James.Clark@arm.com \
    --cc=acme@redhat.com \
    --cc=irogers@google.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®