Skip to contentSkip to conversation

mips: fix mipsel toolchains support to compile BIG_ENDIAN board

PATCH In review Jean-Christophe PLAGNIOL-VILLARD 3 participants 5 messages Jul 26, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mips: fix mipsel toolchains support to compile BIG_ENDIAN board

---
 arch/mips/Makefile |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)
arch/mips/Makefile +38 -4
index 86b4b80..72434d4 100644
@@ -1,20 +1,54 @@
+#
+# Select the object file format to substitute into the linker script.
+#
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+32bit-tool-archpref	= mipsel
+64bit-tool-archpref	= mips64el
+32bit-bfd		= elf32-tradlittlemips
+64bit-bfd		= elf64-tradlittlemips
+32bit-emul		= elf32ltsmip
+64bit-emul		= elf64ltsmip
+else
+32bit-tool-archpref	= mips
+64bit-tool-archpref	= mips64
+32bit-bfd		= elf32-tradbigmips
+64bit-bfd		= elf64-tradbigmips
+32bit-emul		= elf32btsmip
+64bit-emul		= elf64btsmip
+endif
+
 CPPFLAGS += -D__MIPS__ -fno-strict-aliasing -fno-merge-constants
 
 cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
 cflags-y += -Wall -Wmissing-prototypes -Wstrict-prototypes \
 	-Wno-uninitialized -Wno-format -Wno-main
 
-cflags-$(CONFIG_32BIT) += -mabi=32
-cflags-$(CONFIG_64BIT) += -mabi=64
+ifdef CONFIG_32BIT
+ld-emul		= $(32bit-emul)
+cflags-y	+= -mabi=32
+endif
+
+ifdef CONFIG_64BIT
+ld-emul		= $(64bit-emul)
+cflags-y	+= -mabi=64
+endif
 
 undef-all += -UMIPSEB -U_MIPSEB -U__MIPSEB -U__MIPSEB__
 undef-all += -UMIPSEL -U_MIPSEL -U__MIPSEL -U__MIPSEL__
 predef-be += -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__
 predef-le += -DMIPSEL -D_MIPSEL -D__MIPSEL -D__MIPSEL__
 
-cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB $(undef-all) $(predef-be))
+ifdef CONFIG_CPU_BIG_ENDIAN
+cflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB $(undef-all) $(predef-be))
+ldflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB )
+endif
+
+ifdef CONFIG_CPU_BIG_ENDIAN
+cflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL $(undef-all) $(predef-le))
+ldflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL )
+endif
 
-cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL $(undef-all) $(predef-le))
+LDFLAGS += $(ldflags-y) -m $(ld-emul)
 
 #
 # CPU-dependent compiler/assembler options for optimization.
Signature · 7 lines
1.7.5.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 17 lines · Jean-Christophe PLAGNIOL-VILLARD
 arch/mips/Makefile |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)
arch/mips/Makefile +9 -0
index 86b4b80..72434d4 100644
@@ -1,20 +1,54 @@
+#
+# Select the object file format to substitute into the linker script.
+#
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+32bit-tool-archpref	= mipsel
+64bit-tool-archpref	= mips64el
+32bit-bfd		= elf32-tradlittlemips
+64bit-bfd		= elf64-tradlittlemips
+32bit-emul		= elf32ltsmip

arch/mips/Makefile line 19

Quoted 10 lines
arch/mips/Makefile +10 -0
+64bit-emul		= elf64ltsmip
+else
+32bit-tool-archpref	= mips
+64bit-tool-archpref	= mips64
+32bit-bfd		= elf32-tradbigmips
+64bit-bfd		= elf64-tradbigmips
+32bit-emul		= elf32btsmip
+64bit-emul		= elf64btsmip
+endif
+

This is part of linux mips Makefile.
But *-tool-archpref variables don't used. In linux this variables used to construct CROSS_COMPILE (if not set). I shell send the patches to use them.

Quoted 25 lines
arch/mips/Makefile +9 -3
 CPPFLAGS += -D__MIPS__ -fno-strict-aliasing -fno-merge-constants
 
 cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
 cflags-y += -Wall -Wmissing-prototypes -Wstrict-prototypes \
 	-Wno-uninitialized -Wno-format -Wno-main
 
-cflags-$(CONFIG_32BIT) += -mabi=32
-cflags-$(CONFIG_64BIT) += -mabi=64
+ifdef CONFIG_32BIT
+ld-emul		= $(32bit-emul)
+cflags-y	+= -mabi=32
+endif
+
+ifdef CONFIG_64BIT
+ld-emul		= $(64bit-emul)
+cflags-y	+= -mabi=64
+endif
 
 undef-all += -UMIPSEB -U_MIPSEB -U__MIPSEB -U__MIPSEB__
 undef-all += -UMIPSEL -U_MIPSEL -U__MIPSEL -U__MIPSEL__
 predef-be += -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__
 predef-le += -DMIPSEL -D_MIPSEL -D__MIPSEL -D__MIPSEL__
 
-cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q
 'mips.*el-.*' && echo -EB $(undef-all) $(predef-be))

arch/mips/Makefile

Quoted 10 lines
arch/mips/Makefile +6 -0
 
 
+ifdef CONFIG_CPU_BIG_ENDIAN
+cflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB
 $(undef-all) $(predef-be))
+ldflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB
 )
+endif
+
+ifdef CONFIG_CPU_BIG_ENDIAN

Too many CPU_BIG_ENDIAN here...

Quoted 5 lines
arch/mips/Makefile +1 -0
+cflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL

$(undef-all) $(predef-le))
+ldflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL )
+endif

Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 1/1 MIPS: try to select cross-compiler (if not set)

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/mips/Makefile     |   15 +++++++++++++++
 scripts/Kbuild.include |   11 +++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)
arch/mips/Makefile +15 -0
index 1ec2107..4d635c6 100644
@@ -17,6 +17,21 @@ else
 64bit-emul		= elf64btsmip
 endif
 
+ifdef CONFIG_32BIT
+tool-archpref		= $(32bit-tool-archpref)
+UTS_MACHINE		:= mips
+endif
+ifdef CONFIG_64BIT
+tool-archpref		= $(64bit-tool-archpref)
+UTS_MACHINE		:= mips64
+endif
+
+ifneq ($(SUBARCH),$(ARCH))
+  ifeq ($(CROSS_COMPILE),)
+    CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux-  $(tool-archpref)-linux-gnu-  $(tool-archpref)-unknown-linux-gnu-)
+  endif
+endif
+
 CPPFLAGS += -D__MIPS__ -fno-strict-aliasing -fno-merge-constants
 
 cflags-y += -G 0 -mno-abicalls -fno-pic -pipe
scripts/Kbuild.include +11 -0
index 95e7746..0e6e2c7 100644
@@ -56,6 +56,17 @@ endef
 # gcc support functions
 # See documentation in Documentation/kbuild/makefiles.txt
 
+# cc-cross-prefix
+# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-)
+# Return first prefix where a prefix$(CC) is found in PATH.
+# If no $(CC) found in PATH with listed prefixes return nothing
+cc-cross-prefix =  \
+	$(word 1, $(foreach c,$(1),                                   \
+		$(shell set -e;                                       \
+		if (which $(strip $(c))$(CC)) > /dev/null 2>&1 ; then \
+			echo $(c);                                    \
+		fi)))
+
 # output directory for tests below
 TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/)
 
Signature · 7 lines
1.7.5.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw
In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 18 lines · Jean-Christophe PLAGNIOL-VILLARD
---
 arch/mips/Makefile |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)
arch/mips/Makefile +8 -0
index 86b4b80..72434d4 100644
@@ -1,20 +1,54 @@
+#
+# Select the object file format to substitute into the linker script.
+#
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+32bit-tool-archpref	= mipsel
+64bit-tool-archpref	= mips64el
+32bit-bfd		= elf32-tradlittlemips
+64bit-bfd		= elf64-tradlittlemips

arch/mips/Makefile line 18

Quoted 10 lines
arch/mips/Makefile +10 -0
+32bit-emul		= elf32ltsmip
+64bit-emul		= elf64ltsmip
+else
+32bit-tool-archpref	= mips
+64bit-tool-archpref	= mips64
+32bit-bfd		= elf32-tradbigmips
+64bit-bfd		= elf64-tradbigmips
+32bit-emul		= elf32btsmip
+64bit-emul		= elf64btsmip
+endif

I'm not convinced that introducing magic for finding a cross toolchain is a good idea. The corresponding kernel code goes back to the pre 2.6.12 era and I think it wouldn't find its way mainline nowadays.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH 1/1 MIPS: fix fix mipsel toolchains support to compile BIG_ENDIAN board

In reply to Jean-Christophe PLAGNIOL-VILLARD
---
 arch/mips/Makefile |   10 +---------
 1 files changed, 1 insertions(+), 9 deletions(-)
arch/mips/Makefile +1 -9
index 72434d4..43b8ae6 100644
@@ -2,17 +2,9 @@
 # Select the object file format to substitute into the linker script.
 #
 ifdef CONFIG_CPU_LITTLE_ENDIAN
-32bit-tool-archpref	= mipsel
-64bit-tool-archpref	= mips64el
-32bit-bfd		= elf32-tradlittlemips
-64bit-bfd		= elf64-tradlittlemips
 32bit-emul		= elf32ltsmip
 64bit-emul		= elf64ltsmip
 else
-32bit-tool-archpref	= mips
-64bit-tool-archpref	= mips64
-32bit-bfd		= elf32-tradbigmips
-64bit-bfd		= elf64-tradbigmips
 32bit-emul		= elf32btsmip
 64bit-emul		= elf64btsmip
 endif
@@ -43,7 +35,7 @@ cflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB $(unde
 ldflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB )
 endif
 
-ifdef CONFIG_CPU_BIG_ENDIAN
+ifdef CONFIG_CPU_LITTLE_ENDIAN
 cflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL $(undef-all) $(predef-le))
 ldflags-y += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL )
 endif
Signature · 7 lines
1.7.5.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox