All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Lucas Stach <l.stach@pengutronix.de>,
	Jiri Olsa <jolsa@kernel.org>,
	linux-kernel@vger.kernel.org, kernel@pengutronix.de,
	patchwork-lst@pengutronix.de, Wang Nan <wangnan0@huawei.com>,
	acme@kernel.org
Subject: Re: [PATCH] tools lib api: respect CROSS_COMPILE for the linker
Date: Fri, 18 Mar 2016 12:16:23 -0500	[thread overview]
Message-ID: <20160318171623.mih7ozxyinn33ads@treble.redhat.com> (raw)
In-Reply-To: <20160318164522.GB2701@redhat.com>

On Fri, Mar 18, 2016 at 01:45:22PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Fri, Mar 18, 2016 at 11:38:15AM -0500, Josh Poimboeuf escreveu:
> > On Fri, Mar 18, 2016 at 01:25:47PM -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Thu, Mar 17, 2016 at 06:27:50PM +0100, Lucas Stach escreveu:
> > > > This fixes cross compilation of libapi.
> > > 
> > > Humm, I guess that tools/lib/subcmd/Makefile has the same problem? And
> > > there are also other cases where LD is not being set with CROSS_COMPILE,
> > > Jiri, is there something else at play here?
> > > 
> > > /me needs to cross compile all this code...
> > 
> > Yeah, I already fixed the libsubcmd issue with commit c1d45c3abd49 in
> > tip/core/objtool.  (Sorry, I probably should have CC'ed you and Jiri.)
> 
> Not a problem, it will all get merged eventually, but I noticed this:
> 
> -CC = $(CROSS_COMPILE)gcc
> -AR = $(CROSS_COMPILE)ar
> +CC ?= $(CROSS_COMPILE)gcc
> +LD ?= $(CROSS_COMPILE)ld
> +AR ?= $(CROSS_COMPILE)ar
> 
> This is how you fixed it, which is different from what other places do
> for cross compiling, for instance, this is how tools/lib/bpf/Makefile
> does (and it isn't setting LD as well):
> 
> # Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
> $(call allow-override,CC,$(CROSS_COMPILE)gcc)
> $(call allow-override,AR,$(CROSS_COMPILE)ar)
> 
> Which is different from what the kernel does in its main Makefile:
> 
> # Make variables (CC, etc...)
> AS              = $(CROSS_COMPILE)as
> LD              = $(CROSS_COMPILE)ld
> CC              = $(CROSS_COMPILE)gcc
> 
> I wonder if we could settle in one of these styles or if there is really
> a reason to be creative :-)
> 
> Better, all this could go to tools/scripts/Makefile.include?

Yeah, I agree that it would be good to come up with a common and
consistent approach tools-wide if possible.

The reason I used '?=' is because objtool needs to be built with the
host compiler, and the tools kbuild doesn't have hostprogs and HOSTCC.
So I and overrode the CC variable.  From tools/objtool/Makefile:

  # always use the host compiler
  CC = gcc
  LD = ld
  AR = ar

So the 'CC ?= $(CROSS_COMPILE)gcc' in tools/lib/subcmd/Makefile allows
the objtool Makefile to override the cross-compilation and use the host
compiler instead.

I _think_ 'allow-override' would also work, because the objtool Makefile
exports the CC/LD/AR variables to the environment before descending into
the subcmd directory.  And 'allow-override' seems to allow overriding
those variables if they were set in the environment.

So 'allow-override' would probably be a good option.

-- 
Josh

  reply	other threads:[~2016-03-18 17:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17 17:27 [PATCH] tools lib api: respect CROSS_COMPILE for the linker Lucas Stach
2016-03-18 16:25 ` Arnaldo Carvalho de Melo
2016-03-18 16:38   ` Josh Poimboeuf
2016-03-18 16:43     ` Josh Poimboeuf
2016-03-18 17:39       ` Arnaldo Carvalho de Melo
2016-03-18 16:45     ` Arnaldo Carvalho de Melo
2016-03-18 17:16       ` Josh Poimboeuf [this message]
2016-03-18 17:38         ` Arnaldo Carvalho de Melo
2016-03-18 17:42           ` Josh Poimboeuf
2016-03-21  8:08           ` Jiri Olsa
2016-03-21 20:40             ` Arnaldo Carvalho de Melo
2016-03-22  7:10               ` Jiri Olsa
2016-03-22 12:50                 ` Steven Rostedt
2016-03-22 14:42                   ` Arnaldo Carvalho de Melo
2016-03-22 18:22                     ` David Sharp
2016-03-22 18:38                       ` David Sharp
2016-06-01  9:18 ` Lucas Stach
2016-06-01 13:07   ` Arnaldo Carvalho de Melo
2016-06-08  8:37 ` [tip:perf/core] tools lib api: Respect " tip-bot for Lucas Stach

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=20160318171623.mih7ozxyinn33ads@treble.redhat.com \
    --to=jpoimboe@redhat.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=jolsa@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=l.stach@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patchwork-lst@pengutronix.de \
    --cc=wangnan0@huawei.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.