Skip to contentSkip to conversation

ext-toolchain: MIPS: Select correct endianness for the target

PATCH New Markos Chandras 2 participants 6 messages Oct 14, 2013 – Oct 30, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext-toolchain: MIPS: Select correct endianness for the target

Previously, an external-toolchain on a mipsel/mips64el target didn't select the appriopriate endianness but
it asked the user to set the correct CFLAGS on his/her own. We fix this by appending "-EL" to the toolchain wrapper options if the user has selected a mipsel/mips64el target.

---
 toolchain/toolchain-external/Config.in             | 24 ++++++----------------
 .../toolchain-external/ext-toolchain-wrapper.c     |  3 +++
 toolchain/toolchain-external/toolchain-external.mk |  7 ++++++-
 3 files changed, 15 insertions(+), 19 deletions(-)
toolchain/toolchain-external/Config.in +6 -18
index 0d42041..6674b3d 100644
@@ -213,12 +213,10 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201305
 	    - MIPS32 O32 little endian glibc
 	      Select a MIPS generic core
 	      Disable BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS64 little endian glibc
 	      Select a MIPS64 generic core
 	      Select the n64 ABI
 	      Disable BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS32 big endian soft float glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
@@ -229,12 +227,10 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201305
 	    - MIPS32 little endian soft float glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS64 little endian soft float glibc
 	      Select a MIPS64 generic core
 	      Select the n64 ABI
 	      Select BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS32 big endian microMIPS glibc
 	      Select a MIPS generic core
 	      Disable BR2_SOFT_FLOAT
@@ -242,7 +238,7 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201305
 	    - MIPS32 little endian microMIPS glibc
 	      Select a MIPS generic core
 	      Disable BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL -mips16
+	      Set BR2_TARGET_OPTIMIZATION to -mips16
 	    - MIPS32 big endian soft float microMIPS glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
@@ -250,7 +246,7 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201305
 	    - MIPS32 little endian soft float microMIPS glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL -mips16
+	      Set BR2_TARGET_OPTIMIZATION to -mips16
 	    - MIPS32 big endian uclibc
 	      Not usable in Buildroot yet.
 	    - MIPS32 little endian uclibc
@@ -284,12 +280,10 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201209
 	    - MIPS32 O32 little endian glibc
 	      Select a MIPS generic core
 	      Disable BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS64 little endian glibc
 	      Select a MIPS generic core
 	      Select the n64 ABI
 	      Disable BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS32 big endian soft float glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
@@ -300,12 +294,10 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201209
 	    - MIPS32 little endian soft float glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS64 little endian soft float glibc
 	      Select a MIPS generic core
 	      Select the n64 ABI
 	      Select BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS32 big endian microMIPS glibc
 	      Select a MIPS generic core
 	      Disable BR2_SOFT_FLOAT
@@ -313,7 +305,7 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201209
 	    - MIPS32 little endian microMIPS glibc
 	      Select a MIPS generic core
 	      Disable BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL -mips16
+	      Set BR2_TARGET_OPTIMIZATION to -mips16
 	    - MIPS32 big endian soft float microMIPS glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
@@ -321,7 +313,7 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201209
 	    - MIPS32 little endian soft float microMIPS glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL -mips16
+	      Set BR2_TARGET_OPTIMIZATION to -mips16
 	    - MIPS32 big endian uclibc
 	      Not usable in Buildroot yet.
 	    - MIPS32 little endian uclibc
@@ -355,12 +347,10 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201203
 	    - MIPS32 O32 little endian glibc
 	      Select a MIPS generic core
 	      Disable BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS64 little endian glibc
 	      Select a MIPS generic core
 	      Select the n64 ABI
 	      Disable BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS32 big endian soft float glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
@@ -371,12 +361,10 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201203
 	    - MIPS32 little endian soft float glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS64 little endian soft float glibc
 	      Select a MIPS generic core
 	      Select the n64 ABI
 	      Select BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL
 	    - MIPS32 big endian microMIPS glibc
 	      Select a MIPS generic core
 	      Disable BR2_SOFT_FLOAT
@@ -384,7 +372,7 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201203
 	    - MIPS32 little endian microMIPS glibc
 	      Select a MIPS generic core
 	      Disable BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL -mips16
+	      Set BR2_TARGET_OPTIMIZATION to -mips16
 	    - MIPS32 big endian soft float microMIPS glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
@@ -392,7 +380,7 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS201203
 	    - MIPS32 little endian soft float microMIPS glibc
 	      Select a MIPS generic core
 	      Select BR2_SOFT_FLOAT
-	      Set BR2_TARGET_OPTIMIZATION to -EL -mips16
+	      Set BR2_TARGET_OPTIMIZATION to -mips16
 	    - MIPS32 big endian uclibc
 	      Not usable in Buildroot yet.
 	    - MIPS32 little endian uclibc
toolchain/toolchain-external/ext-toolchain-wrapper.c +3 -0
index 727e322..fdfa29c 100644
@@ -63,6 +63,9 @@ static char *predef_args[] = {
 #ifdef BR_BINFMT_FLAT
 	"-Wl,-elf2flt",
 #endif
+#ifdef BR_MIPS_TARGET_LITTLE_ENDIAN
+	"-EL",
+#endif
 #ifdef BR_ADDITIONAL_CFLAGS
 	BR_ADDITIONAL_CFLAGS
 #endif
toolchain/toolchain-external/toolchain-external.mk +6 -1
index b5b1ce7..073e38a 100644
@@ -207,7 +207,12 @@ ifeq ($(BR2_BINFMT_FLAT),y)
 TOOLCHAIN_EXTERNAL_CFLAGS += -Wl,-elf2flt
 TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_BINFMT_FLAT
 endif
-
+ifeq ($(BR2_mipsel)$(BR2_mips64el),y)
+ifeq ($(BR2_ENDIAN),"LITTLE")
+TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_MIPS_TARGET_LITTLE_ENDIAN
+TOOLCHAIN_EXTERNAL_CFLAGS += -EL
+endif
+endif
 ifneq ($(BR2_TARGET_OPTIMIZATION),)
 TOOLCHAIN_EXTERNAL_CFLAGS += $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
 # We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 1/1 ext-toolchain: MIPS: Select correct endianness for the target

Dear Markos Chandras,

toolchain/toolchain-external/toolchain-external.mk ifeq ($(BR2_BINFMT_FLAT),y) · line 211

Quoted 2 lines · Markos Chandras
toolchain/toolchain-external/toolchain-external.mk +2 -0
+ifeq ($(BR2_mipsel)$(BR2_mips64el),y)
+ifeq ($(BR2_ENDIAN),"LITTLE")

If we're on mipsel or mips64el, we're always little endian, right? So maybe the test on BR2_ENDIAN isn't that useful? :-)

toolchain/toolchain-external/toolchain-external.mk ifeq ($(BR2_BINFMT_FLAT),y) · line 215

Quoted 4 lines
toolchain/toolchain-external/toolchain-external.mk +4 -0
+TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_MIPS_TARGET_LITTLE_ENDIAN
+TOOLCHAIN_EXTERNAL_CFLAGS += -EL
+endif
+endif

Should we do it for -EB as well? Or do we consider because the Sourcery toolchain defaults to big endian we don't need to explicit -EB ?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 ext-toolchain: MIPS: Select correct endianness for the target

Hi Thomas,

Quoted 8 lines · Thomas Petazzoni

Dear Markos Chandras,

toolchain/toolchain-external/toolchain-external.mk ifeq ($(BR2_BINFMT_FLAT),y) · line 211

Quoted 2 lines · Markos Chandras
toolchain/toolchain-external/toolchain-external.mk +2 -0
+ifeq ($(BR2_mipsel)$(BR2_mips64el),y)
+ifeq ($(BR2_ENDIAN),"LITTLE")

If we're on mipsel or mips64el, we're always little endian, right? So maybe the test on BR2_ENDIAN isn't that useful? :-)

Oh right that makes sense...

Quoted 8 lines

toolchain/toolchain-external/toolchain-external.mk ifeq ($(BR2_BINFMT_FLAT),y) · line 215

Quoted 5 lines
toolchain/toolchain-external/toolchain-external.mk +4 -0
+TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_MIPS_TARGET_LITTLE_ENDIAN
+TOOLCHAIN_EXTERNAL_CFLAGS += -EL
+endif
+endif

Should we do it for -EB as well? Or do we consider because the Sourcery toolchain defaults to big endian we don't need to explicit -EB ?

It's not necessary because the default is for big endian. But if you prefer to do that for the sake of consinstency I am fine with it :)

Peter can you fix this patch before you commit it or should I send a v2?

Signature · 1 line
markos
#3 lore raw

PATCH 1/1 ext-toolchain: MIPS: Select correct endianness for the target

Dear Markos Chandras,

Quoted 7 lines · Markos Chandras
Quoted 2 lines

Should we do it for -EB as well? Or do we consider because the Sourcery toolchain defaults to big endian we don't need to explicit -EB ?

It's not necessary because the default is for big endian. But if you prefer to do that for the sake of consinstency I am fine with it :)

Peter can you fix this patch before you commit it or should I send a v2?

I have a bunch of other external toolchain / toolchain patches, so I can take your patch as well and send a global patch series to Peter.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH 1/1 ext-toolchain: MIPS: Select correct endianness for the target

Quoted 10 lines · Thomas Petazzoni

Dear Markos Chandras,

Quoted 6 lines · Markos Chandras
Quoted 2 lines

Should we do it for -EB as well? Or do we consider because the Sourcery toolchain defaults to big endian we don't need to explicit -EB ?

It's not necessary because the default is for big endian. But if you prefer to do that for the sake of consinstency I am fine with it :)

Quoted 9 lines
Quoted 1 line

Peter can you fix this patch before you commit it or should I send a v2?

I have a bunch of other external toolchain / toolchain patches, so I can take your patch as well and send a global patch series to Peter.

Thanks!

Thomas

Hi Thomas,

Oh that would be great! Would you be able to remove the redundant "ifeq ($(BR2_ENDIAN),"LITTLE")" or should I send a new patch? :)

Signature · 1 line
markos
#5 lore raw

PATCH 1/1 ext-toolchain: MIPS: Select correct endianness for the target

In reply to Markos Chandras

Dear Markos Chandras,

Quoted 7 lines · Markos Chandras

Previously, an external-toolchain on a mipsel/mips64el target didn't select the appriopriate endianness but
it asked the user to set the correct CFLAGS on his/her own. We fix this by appending "-EL" to the toolchain wrapper options if the user has selected a mipsel/mips64el target.

Applied to for-peter-2013.11, after making a few fixes (remove the BR2_ENDIAN test, addition of the big endian case).

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com