Skip to contentSkip to conversation

Coldire: mcf52x2: Improve gcc version detection

PATCH New Richard Retanubun 2 participants 4 messages Mar 19, 2009 – Mar 20, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Coldire: mcf52x2: Improve gcc version detection

From 2cfa4b5789a6c01f6120663cc36ca751e2e5d172 Mon Sep 17 00:00:00 2001
From: Richard Retanubun <[email protected]>
Date: Wed, 18 Mar 2009 17:12:47 -0400
Subject: [PATCH] Improved gcc version detection for more optimized code.

This patch makes the gcc version detection more flexible. gcc 4.2+ supports -mcpu option, which allows more optimized code. Without this patch, building on gcc 4.3.3 breaks on:

start.S:144: Error: operands mismatch -- statement `movec %d0,%RAMBAR1' ignored

Author: Len Sorensen <[email protected]>
---

Hi TC,

Incidentally, I am also trying to move to gcc 4.3.x (4.3.3), and just saw your patch. Len Sorensen from my team suggested this detection scheme, similar to how linux does it, I think. (this way you will still be ok if someone still uses gcc-4.0)

I don't have enough coldfire variants to test, so I can't testify to all of them, but the MCF5270/1 compiles ok.

- Richard

  cpu/mcf52x2/config.mk |    6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)
cpu/mcf52x2/config.mk +4 -2
index 8292736..c4726af 100644
@@ -33,9 +33,11 @@ is5272:=$(shell grep CONFIG_M5272 $(TOPDIR)/include/$(cfg))
  is5275:=$(shell grep CONFIG_M5275 $(TOPDIR)/include/$(cfg))
  is5282:=$(shell grep CONFIG_M5282 $(TOPDIR)/include/$(cfg))
 
+# If gcc 4.2 or greater use -mcpu= otherwise use -m5307 on gcc 4.1 and older
+GCC_SUPPORTS_MCPU = $(shell if [ `echo __GNUC__ __GNUC_MINOR__ | $(CC) -E -xc - \
+	| tail -n 1 | sed -e 's/ /0/'` -gt 401 ];then echo yes; else echo no; fi)
 
-ifneq ($(findstring 4.1,$(shell $(CC) --version)),4.1)
-
+ifeq ($(GCC_SUPPORTS_MCPU),yes)
  ifneq (,$(findstring CONFIG_M5249,$(is5249)))
  PLATFORM_CPPFLAGS += -mcpu=5249
  endif
Signature · 1 line
1.5.6.5
#1 lore raw

PATCH 1/1 Coldire: mcf52x2: Improve gcc version detection

Dear Richard Retanubun,

Quoted 7 lines · In message <[email protected]> you wrote:
cpu/mcf52x2/config.mk +0 -0
@@ -33,9 +33,11 @@ is5272:=$(shell grep CONFIG_M5272 $(TOPDIR)/include/$(cfg))
  is5275:=$(shell grep CONFIG_M5275 $(TOPDIR)/include/$(cfg))
  is5282:=$(shell grep CONFIG_M5282 $(TOPDIR)/include/$(cfg))
 

cpu/mcf52x2/config.mk is5272:=$(shell grep CONFIG_M5272 $(TOPDIR)/include/$(cfg)) · line 43

Quoted 10 lines
cpu/mcf52x2/config.mk +4 -2
+# If gcc 4.2 or greater use -mcpu= otherwise use -m5307 on gcc 4.1 and older
+GCC_SUPPORTS_MCPU = $(shell if [ `echo __GNUC__ __GNUC_MINOR__ | $(CC) -E -xc - \
+	| tail -n 1 | sed -e 's/ /0/'` -gt 401 ];then echo yes; else echo no; fi)
 
-ifneq ($(findstring 4.1,$(shell $(CC) --version)),4.1)
-
+ifeq ($(GCC_SUPPORTS_MCPU),yes)
  ifneq (,$(findstring CONFIG_M5249,$(is5249)))
  PLATFORM_CPPFLAGS += -mcpu=5249
  endif

What makes you think that

	echo __GNUC__ __GNUC_MINOR__ | $(CC) -E -xc - \
	| tail -n 1 | sed -e 's/ /0/'

would be any better than parsing the output of "$(CC) --version"?

The fact that it takes 4 processes instead of one (or say two if we add the filtering) is not a recommendation.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Most people would like to be delivered  from  temptation  but  would
like it to keep in touch."                             - Robert Orben
#2 lore raw

PATCH 1/1 Coldire: mcf52x2: Improve gcc version detection

Hi Wolfgang,

Quoted 10 lines

What makes you think that

	echo __GNUC__ __GNUC_MINOR__ | $(CC) -E -xc - \
	| tail -n 1 | sed -e 's/ /0/'

would be any better than parsing the output of "$(CC) --version"?

The fact that it takes 4 processes instead of one (or say two if we add the filtering) is not a recommendation.

Thanks for the comments,

sorry if I'm (re)stating the obvious, but just to be clear:

ifneq ($(findstring 4.1,$(shell $(CC) --version)),4.1)

while simple, will cause gcc-4.0.x or gcc-3.x.x to try to use the -mcpu option which is not supported yet until gcc-4.2.+ (if I am not mistaken).

I realize the world is always moving forward and this is an increasingly moot argument, but the embedded world is often very attached to our toolchains :P

I am sure there are many better ways of extracting the version string, my attempt is to highlight one way that converts the version to a number and use the '-gt' to compare on it.

Feel free to educate me in 'the better way', my user-space kung-fu is not that strong yet :)

Regards,

- Richard Retanubun

#3 lore raw

PATCH 1/1 Coldire: mcf52x2: Improve gcc version detection

Dear Richard Retanubun,

Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 8 lines
	echo __GNUC__ __GNUC_MINOR__ | $(CC) -E -xc - \
	| tail -n 1 | sed -e 's/ /0/'

would be any better than parsing the output of "$(CC) --version"?

The fact that it takes 4 processes instead of one (or say two if we add the filtering) is not a recommendation.

Quoted 6 lines

sorry if I'm (re)stating the obvious, but just to be clear:

ifneq ($(findstring 4.1,$(shell $(CC) --version)),4.1)

while simple, will cause gcc-4.0.x or gcc-3.x.x to try to use the -mcpu option which is not supported yet until gcc-4.2.+ (if I am not mistaken).

Well, when I say "parsing the output" I had a little more intelligent testing in ming than a fixed string compare and decision between 4.1 or anything else.

Quoted 2 lines

I am sure there are many better ways of extracting the version string, my attempt is to highlight one way that converts the version to a number and use the '-gt' to compare on it.

You get the number for free from "gcc -v".

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"You can have my Unix system when you  pry  it  from  my  cold,  dead
fingers."                                                - Cal Keegan