2012-05-12 20:39:18

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 1/4] [-next] Makefile: Do not call cc-option before including the arch's Makefile

On architectures that setup CROSS_COMPILE in their arch/*/Makefile
(blackfin, h8300, m68k, mips, parisc, score, sh, tile, unicore32, xtensa),
cc-option may check against the wrong compiler, causing errors like

cc1: error: unrecognized command line option "-fno-ipa-cp-clone"

if the host gcc supports -fno-ipa-cp-clone, while the cross compiler
doesn't support that option.

Move the CONFIG_READABLE_ASM section below the inclusion of the arch's
Makefile to fix this.

Signed-off-by: Geert Uytterhoeven <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Michal Marek <[email protected]>
Cc: [email protected]
---
Makefile | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index d17a616..77355ba 100644
--- a/Makefile
+++ b/Makefile
@@ -561,6 +561,8 @@ else
KBUILD_CFLAGS += -O2
endif

+include $(srctree)/arch/$(SRCARCH)/Makefile
+
ifdef CONFIG_READABLE_ASM
# Disable optimizations that make assembler listings hard to read.
# reorder blocks reorders the control in the function
@@ -571,8 +573,6 @@ KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
$(call cc-option,-fno-partial-inlining)
endif

-include $(srctree)/arch/$(SRCARCH)/Makefile
-
ifneq ($(CONFIG_FRAME_WARN),0)
KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
endif
--
1.7.0.4


2012-05-12 20:39:32

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 2/4] m68k: Setup CROSS_COMPILE at the top

CROSS_COMPILE must be setup before using e.g. cc-option (and a few other
as-*, cc-*, ld-* macros), else they will check against the wrong compiler
when cross-compiling, and may invoke the cross compiler with wrong or
suboptimal compiler options.

Signed-off-by: Geert Uytterhoeven <[email protected]>
Cc: Greg Ungerer <[email protected]>
Cc: [email protected]
---
arch/m68k/Makefile | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index 804f139..b7f2e2d 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -16,6 +16,13 @@

KBUILD_DEFCONFIG := multi_defconfig

+ifneq ($(SUBARCH),$(ARCH))
+ ifeq ($(CROSS_COMPILE),)
+ CROSS_COMPILE := $(call cc-cross-prefix, \
+ m68k-linux-gnu- m68k-linux- m68k-unknown-linux-gnu-)
+ endif
+endif
+
#
# Enable processor type. Ordering of these is important - we want to
# use the minimum processor type of the range we support. The logic
@@ -62,12 +69,6 @@ endif

LDFLAGS := -m m68kelf
KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds
-ifneq ($(SUBARCH),$(ARCH))
- ifeq ($(CROSS_COMPILE),)
- CROSS_COMPILE := $(call cc-cross-prefix, \
- m68k-linux-gnu- m68k-linux- m68k-unknown-linux-gnu-)
- endif
-endif

ifdef CONFIG_SUN3
LDFLAGS_vmlinux = -N
--
1.7.0.4

2012-05-12 20:40:06

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 4/4] xtensa: Setup CROSS_COMPILE at the top

CROSS_COMPILE must be setup before using e.g. cc-option (and a few other
as-*, cc-*, ld-* macros), else they will check against the wrong compiler
when cross-compiling, and may invoke the cross compiler with wrong or
suboptimal compiler options.

Signed-off-by: Geert Uytterhoeven <[email protected]>
Cc: Chris Zankel <[email protected]>
---
arch/xtensa/Makefile | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile
index 7608559..d41f9ed 100644
--- a/arch/xtensa/Makefile
+++ b/arch/xtensa/Makefile
@@ -21,6 +21,18 @@ variant-$(CONFIG_XTENSA_VARIANT_LINUX_CUSTOM) := custom
VARIANT = $(variant-y)
export VARIANT

+# Test for cross compiling
+
+ifneq ($(VARIANT),)
+ COMPILE_ARCH = $(shell uname -m)
+
+ ifneq ($(COMPILE_ARCH), xtensa)
+ ifndef CROSS_COMPILE
+ CROSS_COMPILE = xtensa_$(VARIANT)-
+ endif
+ endif
+endif
+
# Platform configuration

platform-$(CONFIG_XTENSA_PLATFORM_XT2000) := xt2000
@@ -54,18 +66,6 @@ KBUILD_DEFCONFIG := iss_defconfig

core-$(CONFIG_EMBEDDED_RAMDISK) += arch/xtensa/boot/ramdisk/

-# Test for cross compiling
-
-ifneq ($(VARIANT),)
- COMPILE_ARCH = $(shell uname -m)
-
- ifneq ($(COMPILE_ARCH), xtensa)
- ifndef CROSS_COMPILE
- CROSS_COMPILE = xtensa_$(VARIANT)-
- endif
- endif
-endif
-
# Only build variant and/or platform if it includes a Makefile

buildvar := $(shell test -a $(srctree)/arch/xtensa/variants/$(VARIANT)/Makefile && echo arch/xtensa/variants/$(VARIANT)/)
--
1.7.0.4

2012-05-12 20:40:00

by Geert Uytterhoeven

[permalink] [raw]
Subject: [PATCH 3/4] sh: Setup CROSS_COMPILE at the top

CROSS_COMPILE must be setup before using e.g. cc-option (and a few other
as-*, cc-*, ld-* macros), else they will check against the wrong compiler
when cross-compiling, and may invoke the cross compiler with wrong or
suboptimal compiler options.

Signed-off-by: Geert Uytterhoeven <[email protected]>
Cc: Paul Mundt <[email protected]>
Cc: [email protected]
---
arch/sh/Makefile | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 46edf07..0d7bbaf 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -9,6 +9,12 @@
# License. See the file "COPYING" in the main directory of this archive
# for more details.
#
+ifneq ($(SUBARCH),$(ARCH))
+ ifeq ($(CROSS_COMPILE),)
+ CROSS_COMPILE := $(call cc-cross-prefix, $(UTS_MACHINE)-linux- $(UTS_MACHINE)-linux-gnu- $(UTS_MACHINE)-unknown-linux-gnu-)
+ endif
+endif
+
isa-y := any
isa-$(CONFIG_SH_DSP) := sh
isa-$(CONFIG_CPU_SH2) := sh2
@@ -106,12 +112,6 @@ LDFLAGS_vmlinux += --defsym phys_stext=_stext-$(CONFIG_PAGE_OFFSET) \
KBUILD_DEFCONFIG := cayman_defconfig
endif

-ifneq ($(SUBARCH),$(ARCH))
- ifeq ($(CROSS_COMPILE),)
- CROSS_COMPILE := $(call cc-cross-prefix, $(UTS_MACHINE)-linux- $(UTS_MACHINE)-linux-gnu- $(UTS_MACHINE)-unknown-linux-gnu-)
- endif
-endif
-
ifdef CONFIG_CPU_LITTLE_ENDIAN
ld-bfd := elf32-$(UTS_MACHINE)-linux
LDFLAGS_vmlinux += --defsym 'jiffies=jiffies_64' --oformat $(ld-bfd)
--
1.7.0.4

2012-05-13 01:01:18

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH 1/4] [-next] Makefile: Do not call cc-option before including the arch's Makefile

On Sat, May 12, 2012 at 10:39:05PM +0200, Geert Uytterhoeven wrote:
> On architectures that setup CROSS_COMPILE in their arch/*/Makefile
> (blackfin, h8300, m68k, mips, parisc, score, sh, tile, unicore32, xtensa),
> cc-option may check against the wrong compiler, causing errors like
>
> cc1: error: unrecognized command line option "-fno-ipa-cp-clone"
>
> if the host gcc supports -fno-ipa-cp-clone, while the cross compiler
> doesn't support that option.
>
> Move the CONFIG_READABLE_ASM section below the inclusion of the arch's
> Makefile to fix this.

Thanks Geert for tracking that down.

Michael, are the patches already in the queue or should I resubmit them?

-Andi

2012-05-13 11:38:59

by Greg Ungerer

[permalink] [raw]
Subject: Re: [PATCH 2/4] m68k: Setup CROSS_COMPILE at the top

On 05/13/2012 06:39 AM, Geert Uytterhoeven wrote:
> CROSS_COMPILE must be setup before using e.g. cc-option (and a few other
> as-*, cc-*, ld-* macros), else they will check against the wrong compiler
> when cross-compiling, and may invoke the cross compiler with wrong or
> suboptimal compiler options.
>
> Signed-off-by: Geert Uytterhoeven<[email protected]>
> Cc: Greg Ungerer<[email protected]>

Acked-by: Greg Ungerer<[email protected]>

Regards
Greg


> Cc: [email protected]
> ---
> arch/m68k/Makefile | 13 +++++++------
> 1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
> index 804f139..b7f2e2d 100644
> --- a/arch/m68k/Makefile
> +++ b/arch/m68k/Makefile
> @@ -16,6 +16,13 @@
>
> KBUILD_DEFCONFIG := multi_defconfig
>
> +ifneq ($(SUBARCH),$(ARCH))
> + ifeq ($(CROSS_COMPILE),)
> + CROSS_COMPILE := $(call cc-cross-prefix, \
> + m68k-linux-gnu- m68k-linux- m68k-unknown-linux-gnu-)
> + endif
> +endif
> +
> #
> # Enable processor type. Ordering of these is important - we want to
> # use the minimum processor type of the range we support. The logic
> @@ -62,12 +69,6 @@ endif
>
> LDFLAGS := -m m68kelf
> KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds
> -ifneq ($(SUBARCH),$(ARCH))
> - ifeq ($(CROSS_COMPILE),)
> - CROSS_COMPILE := $(call cc-cross-prefix, \
> - m68k-linux-gnu- m68k-linux- m68k-unknown-linux-gnu-)
> - endif
> -endif
>
> ifdef CONFIG_SUN3
> LDFLAGS_vmlinux = -N


--
------------------------------------------------------------------------
Greg Ungerer -- Principal Engineer EMAIL: [email protected]
SnapGear Group, McAfee PHONE: +61 7 3435 2888
8 Gardner Close, FAX: +61 7 3891 3630
Milton, QLD, 4064, Australia WEB: http://www.SnapGear.com

2012-05-20 09:27:49

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH 1/4] [-next] Makefile: Do not call cc-option before including the arch's Makefile

On Sat, May 12, 2012 at 10:39:05PM +0200, Geert Uytterhoeven wrote:
> On architectures that setup CROSS_COMPILE in their arch/*/Makefile
> (blackfin, h8300, m68k, mips, parisc, score, sh, tile, unicore32, xtensa),
> cc-option may check against the wrong compiler, causing errors like
>
> cc1: error: unrecognized command line option "-fno-ipa-cp-clone"
>
> if the host gcc supports -fno-ipa-cp-clone, while the cross compiler
> doesn't support that option.
>
> Move the CONFIG_READABLE_ASM section below the inclusion of the arch's
> Makefile to fix this.
>
> Signed-off-by: Geert Uytterhoeven <[email protected]>
> Cc: Andi Kleen <[email protected]>
> Cc: H. Peter Anvin <[email protected]>
> Cc: Michal Marek <[email protected]>
> Cc: [email protected]

Michal - was this serie ever applied to kbuild?

Acked-by: Sam Ravnborg <[email protected]>

Sam

2012-05-25 12:24:18

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH 1/4] [-next] Makefile: Do not call cc-option before including the arch's Makefile

Dne 20.5.2012 11:27, Sam Ravnborg napsal(a):
> On Sat, May 12, 2012 at 10:39:05PM +0200, Geert Uytterhoeven wrote:
>> On architectures that setup CROSS_COMPILE in their arch/*/Makefile
>> (blackfin, h8300, m68k, mips, parisc, score, sh, tile, unicore32, xtensa),
>> cc-option may check against the wrong compiler, causing errors like
>>
>> cc1: error: unrecognized command line option "-fno-ipa-cp-clone"
>>
>> if the host gcc supports -fno-ipa-cp-clone, while the cross compiler
>> doesn't support that option.
>>
>> Move the CONFIG_READABLE_ASM section below the inclusion of the arch's
>> Makefile to fix this.
>>
>> Signed-off-by: Geert Uytterhoeven <[email protected]>
>> Cc: Andi Kleen <[email protected]>
>> Cc: H. Peter Anvin <[email protected]>
>> Cc: Michal Marek <[email protected]>
>> Cc: [email protected]
>
> Michal - was this serie ever applied to kbuild?

The first patch has to go to the tip tree, where the CONFIG_READABLE_ASM
option is introduced. The remaining patches can go to the individual
arch trees, I see Geert already pushed the m68k one.

Michal

2012-05-25 20:29:44

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH 1/4] [-next] Makefile: Do not call cc-option before including the arch's Makefile

On Fri, May 25, 2012 at 02:29:40PM +0200, Michal Marek wrote:
> Dne 20.5.2012 11:27, Sam Ravnborg napsal(a):
> > On Sat, May 12, 2012 at 10:39:05PM +0200, Geert Uytterhoeven wrote:
> >> On architectures that setup CROSS_COMPILE in their arch/*/Makefile
> >> (blackfin, h8300, m68k, mips, parisc, score, sh, tile, unicore32, xtensa),
> >> cc-option may check against the wrong compiler, causing errors like
> >>
> >> cc1: error: unrecognized command line option "-fno-ipa-cp-clone"
> >>
> >> if the host gcc supports -fno-ipa-cp-clone, while the cross compiler
> >> doesn't support that option.
> >>
> >> Move the CONFIG_READABLE_ASM section below the inclusion of the arch's
> >> Makefile to fix this.
> >>
> >> Signed-off-by: Geert Uytterhoeven <[email protected]>
> >> Cc: Andi Kleen <[email protected]>
> >> Cc: H. Peter Anvin <[email protected]>
> >> Cc: Michal Marek <[email protected]>
> >> Cc: [email protected]
> >
> > Michal - was this serie ever applied to kbuild?
>
> The first patch has to go to the tip tree, where the CONFIG_READABLE_ASM
> option is introduced.
OK - I had not seen this.

So tip-folks - please apply this.

Sam

2012-05-25 20:35:20

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH 1/4] [-next] Makefile: Do not call cc-option before including the arch's Makefile

On 05/25/2012 05:29 AM, Michal Marek wrote:
>>
>> Michal - was this serie ever applied to kbuild?
>
> The first patch has to go to the tip tree, where the CONFIG_READABLE_ASM
> option is introduced. The remaining patches can go to the individual
> arch trees, I see Geert already pushed the m68k one.
>

OK, can you ack it, please?

-hpa

2012-05-26 10:41:56

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH 1/4] [-next] Makefile: Do not call cc-option before including the arch's Makefile

"H. Peter Anvin" <[email protected]> wrote:

>On 05/25/2012 05:29 AM, Michal Marek wrote:
>>>
>>> Michal - was this serie ever applied to kbuild?
>>
>> The first patch has to go to the tip tree, where the
>CONFIG_READABLE_ASM
>> option is introduced. The remaining patches can go to the individual
>> arch trees, I see Geert already pushed the m68k one.
>>
>
>OK, can you ack it, please?
>
> -hpa

Acked-by: Michal Marek <[email protected]>
--
Sent from my phone. Please excuse my brevity.

2012-06-06 09:49:21

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 1/4] [-next] Makefile: Do not call cc-option before including the arch's Makefile


* Sam Ravnborg <[email protected]> wrote:

> On Fri, May 25, 2012 at 02:29:40PM +0200, Michal Marek wrote:
> > Dne 20.5.2012 11:27, Sam Ravnborg napsal(a):
> > > On Sat, May 12, 2012 at 10:39:05PM +0200, Geert Uytterhoeven wrote:
> > >> On architectures that setup CROSS_COMPILE in their arch/*/Makefile
> > >> (blackfin, h8300, m68k, mips, parisc, score, sh, tile, unicore32, xtensa),
> > >> cc-option may check against the wrong compiler, causing errors like
> > >>
> > >> cc1: error: unrecognized command line option "-fno-ipa-cp-clone"
> > >>
> > >> if the host gcc supports -fno-ipa-cp-clone, while the cross compiler
> > >> doesn't support that option.
> > >>
> > >> Move the CONFIG_READABLE_ASM section below the inclusion of the arch's
> > >> Makefile to fix this.
> > >>
> > >> Signed-off-by: Geert Uytterhoeven <[email protected]>
> > >> Cc: Andi Kleen <[email protected]>
> > >> Cc: H. Peter Anvin <[email protected]>
> > >> Cc: Michal Marek <[email protected]>
> > >> Cc: [email protected]
> > >
> > > Michal - was this serie ever applied to kbuild?
> >
> > The first patch has to go to the tip tree, where the CONFIG_READABLE_ASM
> > option is introduced.
> OK - I had not seen this.
>
> So tip-folks - please apply this.

it's now all upstream so you can route it via the kbuild tree I
guess?

Thanks,

Ingo

2012-06-15 15:10:43

by Michal Marek

[permalink] [raw]
Subject: Re: [PATCH 1/4] [-next] Makefile: Do not call cc-option before including the arch's Makefile

On 6.6.2012 11:49, Ingo Molnar wrote:
>
> * Sam Ravnborg <[email protected]> wrote:
>
>> On Fri, May 25, 2012 at 02:29:40PM +0200, Michal Marek wrote:
>>> Dne 20.5.2012 11:27, Sam Ravnborg napsal(a):
>>>> On Sat, May 12, 2012 at 10:39:05PM +0200, Geert Uytterhoeven wrote:
>>>>> On architectures that setup CROSS_COMPILE in their arch/*/Makefile
>>>>> (blackfin, h8300, m68k, mips, parisc, score, sh, tile, unicore32, xtensa),
>>>>> cc-option may check against the wrong compiler, causing errors like
>>>>>
>>>>> cc1: error: unrecognized command line option "-fno-ipa-cp-clone"
>>>>>
>>>>> if the host gcc supports -fno-ipa-cp-clone, while the cross compiler
>>>>> doesn't support that option.
>>>>>
>>>>> Move the CONFIG_READABLE_ASM section below the inclusion of the arch's
>>>>> Makefile to fix this.
>>>>>
>>>>> Signed-off-by: Geert Uytterhoeven <[email protected]>
>>>>> Cc: Andi Kleen <[email protected]>
>>>>> Cc: H. Peter Anvin <[email protected]>
>>>>> Cc: Michal Marek <[email protected]>
>>>>> Cc: [email protected]
>>>>
>>>> Michal - was this serie ever applied to kbuild?
>>>
>>> The first patch has to go to the tip tree, where the CONFIG_READABLE_ASM
>>> option is introduced.
>> OK - I had not seen this.
>>
>> So tip-folks - please apply this.
>
> it's now all upstream so you can route it via the kbuild tree I
> guess?

I applied it to kbuild.git#rc-fixes now.

Michal