Skip to contentSkip to conversation

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

PATCH In review Alexey Brodkin 4 participants 10 messages Jun 3, 2019 – Jun 12, 2019 Synopsys ARC architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix

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 at synopsys.com>
Cc Masahiro Yamada <yamada.masahiro at socionext.com>
Cc Vineet Gupta <vgupta at synopsys.com>
---
 arch/arc/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
arch/arc/Makefile +4 -0
index e2b991f75bc5..9cfd2ba7a12d 100644
@@ -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
Signature · 1 line
2.16.2
#1 lore raw

Hi Alexey,

Quoted 20 lines · Alexey Brodkin

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

Quoted 6 lines

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 at pug:~$ which arc-linux-gcc
/home/masahiro/tools/arc/bin/arc-linux-gcc
masahiro at pug:~$ which dummy-linux-gcc
masahiro at pug:~$ echo $?
1

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

Does it work differently on your machine?

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw

Hi Masahiro-san,

Quoted 12 lines

-----Original Message-----
From: Masahiro Yamada <yamada.masahiro at socionext.com>
Sent: Monday, June 3, 2019 11:18 AM
To: Alexey Brodkin <abrodkin at synopsys.com>
Cc: arcml <linux-snps-arc at lists.infradead.org>; Linux Kernel Mailing List <linux- kernel at vger.kernel.org>; Vineet Gupta <Vineet.Gupta1 at 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
<[email protected]> wrote:

[snip]

Quoted 17 lines
Quoted 6 lines

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 at pug:~$ which arc-linux-gcc
/home/masahiro/tools/arc/bin/arc-linux-gcc
masahiro at pug:~$ which dummy-linux-gcc
masahiro at pug:~$ echo $?
1

Quoted 4 lines

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

#3 lore raw

Hi Alexey,

Quoted 45 lines · Alexey Brodkin

Hi Masahiro-san,

Quoted 12 lines

-----Original Message-----
From: Masahiro Yamada <yamada.masahiro at socionext.com>
Sent: Monday, June 3, 2019 11:18 AM
To: Alexey Brodkin <abrodkin at synopsys.com>
Cc: arcml <linux-snps-arc at lists.infradead.org>; Linux Kernel Mailing List <linux- kernel at vger.kernel.org>; Vineet Gupta <Vineet.Gupta1 at 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
<[email protected]> wrote:

[snip]

Quoted 17 lines
Quoted 6 lines

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 at pug:~$ which arc-linux-gcc
/home/masahiro/tools/arc/bin/arc-linux-gcc
masahiro at pug:~$ which dummy-linux-gcc
masahiro at pug:~$ echo $?
1

Quoted 4 lines

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)

Quoted 5 lines
| # /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.

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw
In reply to Alexey Brodkin
Quoted 22 lines · Alexey Brodkin

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:

Quoted 7 lines
| # 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 at synopsys.com>
Cc Masahiro Yamada <yamada.masahiro at socionext.com>
Cc Vineet Gupta <vgupta at 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

Quoted 19 lines
---
 arch/arc/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
arch/arc/Makefile +4 -0
index e2b991f75bc5..9cfd2ba7a12d 100644
@@ -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
#5 lore raw

Hi Vineet,

Quoted 34 lines

-----Original Message-----
From: Vineet Gupta <vgupta at synopsys.com>
Sent: Monday, June 3, 2019 7:25 PM
To: Alexey Brodkin <abrodkin at synopsys.com>; linux-snps-arc at lists.infradead.org
Cc: linux-kernel at vger.kernel.org; Masahiro Yamada <yamada.masahiro at socionext.com>
Subject: Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix

Quoted 26 lines · Alexey Brodkin

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'
Quoted 6 lines
Quoted 3 lines
Signed-off-by Alexey Brodkin <abrodkin at synopsys.com>
Cc Masahiro Yamada <yamada.masahiro at socionext.com>
Cc Vineet Gupta <vgupta at 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

#6 lore raw

Hi.

Quoted 36 lines · Alexey Brodkin

Hi Vineet,

Quoted 33 lines

-----Original Message-----
From: Vineet Gupta <vgupta at synopsys.com>
Sent: Monday, June 3, 2019 7:25 PM
To: Alexey Brodkin <abrodkin at synopsys.com>; linux-snps-arc at lists.infradead.org
Cc: linux-kernel at vger.kernel.org; Masahiro Yamada <yamada.masahiro at socionext.com>
Subject: Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix

Quoted 25 lines · Alexey Brodkin

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.

Signature · 2 lines
Best Regards
Masahiro Yamada
#7 lore raw
Quoted 42 lines · Masahiro Yamada

Hi.

Quoted 36 lines · Alexey Brodkin

Hi Vineet,

Quoted 33 lines

-----Original Message-----
From: Vineet Gupta <vgupta at synopsys.com>
Sent: Monday, June 3, 2019 7:25 PM
To: Alexey Brodkin <abrodkin at synopsys.com>; linux-snps-arc at lists.infradead.org
Cc: linux-kernel at vger.kernel.org; Masahiro Yamada <yamada.masahiro at socionext.com>
Subject: Re: [PATCH] ARC: build: Try to guess CROSS_COMPILE with cc-cross-prefix

Quoted 25 lines · Alexey Brodkin

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'
Quoted 5 lines

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.

Quoted 2 lines

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.

Reviewed-by
#8 lore raw
In reply to Vineet Gupta
Quoted 32 lines · Vineet Gupta
Quoted 22 lines · Alexey Brodkin

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:

Quoted 7 lines
| # 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 at synopsys.com>
Cc Masahiro Yamada <yamada.masahiro at socionext.com>
Cc Vineet Gupta <vgupta at synopsys.com>
Quoted 5 lines

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 at socionext.com>

Signature · 2 lines
Best Regards
Masahiro Yamada