ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix
diff mbox series

Message ID 20190603063119.36544-1-abrodkin@synopsys.com
State New
Headers show
Series
  • ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix
Related show

Commit Message

Alexey Brodkin June 3, 2019, 6:31 a.m. UTC
For a long time we used to hard-code CROSS_COMPILE prefix
for ARC until it started to cause problems, so we decided to
solely rely on CROSS_COMPILE externally set by a user:
commit 40660f1fcee8 ("ARC: build: Don't set CROSS_COMPILE in arch's Makefile").

While it works perfectly fine for build-systems where the prefix
gets defined anyways for us human beings it's quite an annoying
requirement especially given most of time the same one prefix
"arc-linux-" is all what we need.

It looks like finally we're getting the best of both worlds:
 1. W/o cross-toolchain we still may install headers, build .dtb etc
 2. W/ cross-toolchain get the kerne built with only ARCH=arc

Inspired by [1] & [2].

[1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-May/005788.html
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc2b47b55f17

A side note: even though "cc-cross-prefix" does its job it pollutes
console with output of "which" for all the prefixes it didn't manage to find
a matching cross-compiler for like that:
| # ARCH=arc make defconfig
| which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
| *** Default configuration is based on 'nsim_hs_defconfig'

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
---
 arch/arc/Makefile | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Masahiro Yamada June 3, 2019, 8:18 a.m. UTC | #1
Hi Alexey,

On Mon, Jun 3, 2019 at 3:42 PM Alexey Brodkin
<Alexey.Brodkin@synopsys.com> wrote:
>
> For a long time we used to hard-code CROSS_COMPILE prefix
> for ARC until it started to cause problems, so we decided to
> solely rely on CROSS_COMPILE externally set by a user:
> commit 40660f1fcee8 ("ARC: build: Don't set CROSS_COMPILE in arch's Makefile").
>
> While it works perfectly fine for build-systems where the prefix
> gets defined anyways for us human beings it's quite an annoying
> requirement especially given most of time the same one prefix
> "arc-linux-" is all what we need.
>
> It looks like finally we're getting the best of both worlds:
>  1. W/o cross-toolchain we still may install headers, build .dtb etc
>  2. W/ cross-toolchain get the kerne built with only ARCH=arc
>
> Inspired by [1] & [2].
>
> [1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-May/005788.html
> [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc2b47b55f17
>
> A side note: even though "cc-cross-prefix" does its job it pollutes
> console with output of "which" for all the prefixes it didn't manage to find
> a matching cross-compiler for like that:
> | # ARCH=arc make defconfig
> | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
> | *** Default configuration is based on 'nsim_hs_defconfig'


Oh really?

masahiro@pug:~$ which arc-linux-gcc
/home/masahiro/tools/arc/bin/arc-linux-gcc
masahiro@pug:~$ which dummy-linux-gcc
masahiro@pug:~$ echo $?
1


When 'which' cannot find the given command,
it does not print anything to stderr.

Does it work differently on your machine?
Alexey Brodkin June 3, 2019, 8:31 a.m. UTC | #2
Hi Masahiro-san,

> -----Original Message-----
> From: Masahiro Yamada <yamada.masahiro@socionext.com>
> Sent: Monday, June 3, 2019 11:18 AM
> To: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: arcml <linux-snps-arc@lists.infradead.org>; Linux Kernel Mailing List <linux-
> kernel@vger.kernel.org>; Vineet Gupta <Vineet.Gupta1@synopsys.com>
> Subject: Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix
> 
> Hi Alexey,
> 
> On Mon, Jun 3, 2019 at 3:42 PM Alexey Brodkin
> <Alexey.Brodkin@synopsys.com> wrote:

[snip]

> > A side note: even though "cc-cross-prefix" does its job it pollutes
> > console with output of "which" for all the prefixes it didn't manage to find
> > a matching cross-compiler for like that:
> > | # ARCH=arc make defconfig
> > | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
> > | *** Default configuration is based on 'nsim_hs_defconfig'
> 
> 
> Oh really?
> 
> masahiro@pug:~$ which arc-linux-gcc
> /home/masahiro/tools/arc/bin/arc-linux-gcc
> masahiro@pug:~$ which dummy-linux-gcc
> masahiro@pug:~$ echo $?
> 1
> 
> 
> When 'which' cannot find the given command,
> it does not print anything to stderr.
> 
> Does it work differently on your machine?

Well on Ubuntu 18.04 indeed which doesn't show anything
but on my build-server with CentOS 7 I'm getting mentioned verbose output:
| # cat /etc/redhat-release
| CentOS Linux release 7.3.1611 (Core)

| # /usr/bin/which -v
| GNU which v2.20, Copyright (C) 1999 - 2008 Carlo Wood.
| GNU which comes with ABSOLUTELY NO WARRANTY;
| This program is free software; your freedom to use, change
| and distribute this program is protected by the GPL.

-Alexey
Masahiro Yamada June 3, 2019, 9:01 a.m. UTC | #3
Hi Alexey,

On Mon, Jun 3, 2019 at 5:34 PM Alexey Brodkin
<Alexey.Brodkin@synopsys.com> wrote:
>
> Hi Masahiro-san,
>
> > -----Original Message-----
> > From: Masahiro Yamada <yamada.masahiro@socionext.com>
> > Sent: Monday, June 3, 2019 11:18 AM
> > To: Alexey Brodkin <abrodkin@synopsys.com>
> > Cc: arcml <linux-snps-arc@lists.infradead.org>; Linux Kernel Mailing List <linux-
> > kernel@vger.kernel.org>; Vineet Gupta <Vineet.Gupta1@synopsys.com>
> > Subject: Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix
> >
> > Hi Alexey,
> >
> > On Mon, Jun 3, 2019 at 3:42 PM Alexey Brodkin
> > <Alexey.Brodkin@synopsys.com> wrote:
>
> [snip]
>
> > > A side note: even though "cc-cross-prefix" does its job it pollutes
> > > console with output of "which" for all the prefixes it didn't manage to find
> > > a matching cross-compiler for like that:
> > > | # ARCH=arc make defconfig
> > > | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
> > > | *** Default configuration is based on 'nsim_hs_defconfig'
> >
> >
> > Oh really?
> >
> > masahiro@pug:~$ which arc-linux-gcc
> > /home/masahiro/tools/arc/bin/arc-linux-gcc
> > masahiro@pug:~$ which dummy-linux-gcc
> > masahiro@pug:~$ echo $?
> > 1
> >
> >
> > When 'which' cannot find the given command,
> > it does not print anything to stderr.
> >
> > Does it work differently on your machine?
>
> Well on Ubuntu 18.04 indeed which doesn't show anything
> but on my build-server with CentOS 7 I'm getting mentioned verbose output:
> | # cat /etc/redhat-release
> | CentOS Linux release 7.3.1611 (Core)
>
> | # /usr/bin/which -v
> | GNU which v2.20, Copyright (C) 1999 - 2008 Carlo Wood.
> | GNU which comes with ABSOLUTELY NO WARRANTY;
> | This program is free software; your freedom to use, change
> | and distribute this program is protected by the GPL.


OK, confirmed.

Probably using 'which' is a bad idea
since this is not portable.

I will send a fix-up patch soon.
Vineet Gupta June 3, 2019, 4:24 p.m. UTC | #4
On 6/2/19 11:31 PM, Alexey Brodkin wrote:
> For a long time we used to hard-code CROSS_COMPILE prefix
> for ARC until it started to cause problems, so we decided to
> solely rely on CROSS_COMPILE externally set by a user:
> commit 40660f1fcee8 ("ARC: build: Don't set CROSS_COMPILE in arch's Makefile").
>
> While it works perfectly fine for build-systems where the prefix
> gets defined anyways for us human beings it's quite an annoying
> requirement especially given most of time the same one prefix
> "arc-linux-" is all what we need.
>
> It looks like finally we're getting the best of both worlds:
>  1. W/o cross-toolchain we still may install headers, build .dtb etc
>  2. W/ cross-toolchain get the kerne built with only ARCH=arc
>
> Inspired by [1] & [2].
>
> [1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-May/005788.html
> [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc2b47b55f17
>
> A side note: even though "cc-cross-prefix" does its job it pollutes
> console with output of "which" for all the prefixes it didn't manage to find
> a matching cross-compiler for like that:
> | # ARCH=arc make defconfig
> | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
> | *** Default configuration is based on 'nsim_hs_defconfig'
>
> Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> Cc: Vineet Gupta <vgupta@synopsys.com>

Not a big deal but I'd propose we add "Suggested-by: vgupta" since that is where
it came from.

@Masahiro san I suppose you are OK with this, so perhaps an Ack etc would be nice
to have.

Thx,
-Vineet

> ---
>  arch/arc/Makefile | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/arch/arc/Makefile b/arch/arc/Makefile
> index e2b991f75bc5..9cfd2ba7a12d 100644
> --- a/arch/arc/Makefile
> +++ b/arch/arc/Makefile
> @@ -8,6 +8,10 @@
>  
>  KBUILD_DEFCONFIG := nsim_hs_defconfig
>  
> +ifeq ($(CROSS_COMPILE),)
> +CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux-)
> +endif
> +
>  cflags-y	+= -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
>  cflags-$(CONFIG_ISA_ARCOMPACT)	+= -mA7
>  cflags-$(CONFIG_ISA_ARCV2)	+= -mcpu=hs38
Alexey Brodkin June 3, 2019, 4:34 p.m. UTC | #5
Hi Vineet,

> -----Original Message-----
> From: Vineet Gupta <vgupta@synopsys.com>
> Sent: Monday, June 3, 2019 7:25 PM
> To: Alexey Brodkin <abrodkin@synopsys.com>; linux-snps-arc@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org; Masahiro Yamada <yamada.masahiro@socionext.com>
> Subject: Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix
> 
> On 6/2/19 11:31 PM, Alexey Brodkin wrote:
> > For a long time we used to hard-code CROSS_COMPILE prefix
> > for ARC until it started to cause problems, so we decided to
> > solely rely on CROSS_COMPILE externally set by a user:
> > commit 40660f1fcee8 ("ARC: build: Don't set CROSS_COMPILE in arch's Makefile").
> >
> > While it works perfectly fine for build-systems where the prefix
> > gets defined anyways for us human beings it's quite an annoying
> > requirement especially given most of time the same one prefix
> > "arc-linux-" is all what we need.
> >
> > It looks like finally we're getting the best of both worlds:
> >  1. W/o cross-toolchain we still may install headers, build .dtb etc
> >  2. W/ cross-toolchain get the kerne built with only ARCH=arc
> >
> > Inspired by [1] & [2].
> >
> > [1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-May/005788.html
> > [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc2b47b55f17
> >
> > A side note: even though "cc-cross-prefix" does its job it pollutes
> > console with output of "which" for all the prefixes it didn't manage to find
> > a matching cross-compiler for like that:
> > | # ARCH=arc make defconfig
> > | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
> > | *** Default configuration is based on 'nsim_hs_defconfig'
> >
> > Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
> > Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> > Cc: Vineet Gupta <vgupta@synopsys.com>
> 
> Not a big deal but I'd propose we add "Suggested-by: vgupta" since that is where
> it came from.

Ooops, indeed that should have been added, but instead I just
mentioned your earlier email in the mailing list.

Care to add yourself on patch application?

-Alexey
Christoph Hellwig June 3, 2019, 4:40 p.m. UTC | #6
I wish we could just set CROSS_COMPILE and ARCH in .config.  That would
make everyones life compile testing on multiple architectures so much
easier.
Masahiro Yamada June 4, 2019, 12:39 a.m. UTC | #7
On Tue, Jun 4, 2019 at 1:27 AM Vineet Gupta <Vineet.Gupta1@synopsys.com> wrote:
>
> On 6/2/19 11:31 PM, Alexey Brodkin wrote:
> > For a long time we used to hard-code CROSS_COMPILE prefix
> > for ARC until it started to cause problems, so we decided to
> > solely rely on CROSS_COMPILE externally set by a user:
> > commit 40660f1fcee8 ("ARC: build: Don't set CROSS_COMPILE in arch's Makefile").
> >
> > While it works perfectly fine for build-systems where the prefix
> > gets defined anyways for us human beings it's quite an annoying
> > requirement especially given most of time the same one prefix
> > "arc-linux-" is all what we need.
> >
> > It looks like finally we're getting the best of both worlds:
> >  1. W/o cross-toolchain we still may install headers, build .dtb etc
> >  2. W/ cross-toolchain get the kerne built with only ARCH=arc
> >
> > Inspired by [1] & [2].
> >
> > [1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-May/005788.html
> > [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc2b47b55f17
> >
> > A side note: even though "cc-cross-prefix" does its job it pollutes
> > console with output of "which" for all the prefixes it didn't manage to find
> > a matching cross-compiler for like that:
> > | # ARCH=arc make defconfig
> > | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
> > | *** Default configuration is based on 'nsim_hs_defconfig'
> >
> > Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
> > Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> > Cc: Vineet Gupta <vgupta@synopsys.com>
>
> Not a big deal but I'd propose we add "Suggested-by: vgupta" since that is where
> it came from.
>
> @Masahiro san I suppose you are OK with this, so perhaps an Ack etc would be nice
> to have.

FWIW,
Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada June 12, 2019, 11:17 a.m. UTC | #8
Hi.

On Tue, Jun 4, 2019 at 2:49 AM Alexey Brodkin
<Alexey.Brodkin@synopsys.com> wrote:
>
> Hi Vineet,
>
> > -----Original Message-----
> > From: Vineet Gupta <vgupta@synopsys.com>
> > Sent: Monday, June 3, 2019 7:25 PM
> > To: Alexey Brodkin <abrodkin@synopsys.com>; linux-snps-arc@lists.infradead.org
> > Cc: linux-kernel@vger.kernel.org; Masahiro Yamada <yamada.masahiro@socionext.com>
> > Subject: Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix
> >
> > On 6/2/19 11:31 PM, Alexey Brodkin wrote:
> > > For a long time we used to hard-code CROSS_COMPILE prefix
> > > for ARC until it started to cause problems, so we decided to
> > > solely rely on CROSS_COMPILE externally set by a user:
> > > commit 40660f1fcee8 ("ARC: build: Don't set CROSS_COMPILE in arch's Makefile").
> > >
> > > While it works perfectly fine for build-systems where the prefix
> > > gets defined anyways for us human beings it's quite an annoying
> > > requirement especially given most of time the same one prefix
> > > "arc-linux-" is all what we need.
> > >
> > > It looks like finally we're getting the best of both worlds:
> > >  1. W/o cross-toolchain we still may install headers, build .dtb etc
> > >  2. W/ cross-toolchain get the kerne built with only ARCH=arc
> > >
> > > Inspired by [1] & [2].
> > >
> > > [1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-May/005788.html
> > > [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc2b47b55f17
> > >
> > > A side note: even though "cc-cross-prefix" does its job it pollutes
> > > console with output of "which" for all the prefixes it didn't manage to find
> > > a matching cross-compiler for like that:
> > > | # ARCH=arc make defconfig
> > > | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
> > > | *** Default configuration is based on 'nsim_hs_defconfig'


I just noticed this patch is queued on top of v5.2-rc4.
(2bc42bfba9b247abd)

This 'side note' is no longer needed or reproducible
because -rc4 contains my fix-up (913ab9780fc0212).

I do not know if the ARC maitainer is happy to rebase.

Just for your information.
Vineet Gupta June 12, 2019, 3:40 p.m. UTC | #9
On 6/12/19 4:17 AM, Masahiro Yamada wrote:
> Hi.
> 
> On Tue, Jun 4, 2019 at 2:49 AM Alexey Brodkin
> <Alexey.Brodkin@synopsys.com> wrote:
>>
>> Hi Vineet,
>>
>>> -----Original Message-----
>>> From: Vineet Gupta <vgupta@synopsys.com>
>>> Sent: Monday, June 3, 2019 7:25 PM
>>> To: Alexey Brodkin <abrodkin@synopsys.com>; linux-snps-arc@lists.infradead.org
>>> Cc: linux-kernel@vger.kernel.org; Masahiro Yamada <yamada.masahiro@socionext.com>
>>> Subject: Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix
>>>
>>> On 6/2/19 11:31 PM, Alexey Brodkin wrote:
>>>> For a long time we used to hard-code CROSS_COMPILE prefix
>>>> for ARC until it started to cause problems, so we decided to
>>>> solely rely on CROSS_COMPILE externally set by a user:
>>>> commit 40660f1fcee8 ("ARC: build: Don't set CROSS_COMPILE in arch's Makefile").
>>>>
>>>> While it works perfectly fine for build-systems where the prefix
>>>> gets defined anyways for us human beings it's quite an annoying
>>>> requirement especially given most of time the same one prefix
>>>> "arc-linux-" is all what we need.
>>>>
>>>> It looks like finally we're getting the best of both worlds:
>>>>  1. W/o cross-toolchain we still may install headers, build .dtb etc
>>>>  2. W/ cross-toolchain get the kerne built with only ARCH=arc
>>>>
>>>> Inspired by [1] & [2].
>>>>
>>>> [1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-May/005788.html
>>>> [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fc2b47b55f17
>>>>
>>>> A side note: even though "cc-cross-prefix" does its job it pollutes
>>>> console with output of "which" for all the prefixes it didn't manage to find
>>>> a matching cross-compiler for like that:
>>>> | # ARCH=arc make defconfig
>>>> | which: no arceb-linux-gcc in (~/.local/bin:~/bin:/usr/bin:/usr/sbin)
>>>> | *** Default configuration is based on 'nsim_hs_defconfig'
> 
> 
> I just noticed this patch is queued on top of v5.2-rc4.
> (2bc42bfba9b247abd)
> 
> This 'side note' is no longer needed or reproducible
> because -rc4 contains my fix-up (913ab9780fc0212).

But 2bc42bfba9b247abd was to address my complaint that we need to specify
CROSS_COMPILE prefix on cmdline.

When doing the needful Alexey found the "noise" when a prefix didn't exist, which
913ab9780fc0212 address.

So these seem like orthogonal to me - that is unless I got the wired crossed somewhow.

> 
> I do not know if the ARC maitainer is happy to rebase.

I would happily do that on next rc if that is infact needed.

Patch
diff mbox series

diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index e2b991f75bc5..9cfd2ba7a12d 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -8,6 +8,10 @@ 
 
 KBUILD_DEFCONFIG := nsim_hs_defconfig
 
+ifeq ($(CROSS_COMPILE),)
+CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- arceb-linux-)
+endif
+
 cflags-y	+= -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
 cflags-$(CONFIG_ISA_ARCOMPACT)	+= -mA7
 cflags-$(CONFIG_ISA_ARCV2)	+= -mcpu=hs38