diff mbox

[RFC] target/m68k: multilib issues

Message ID alpine.OSX.2.00.1011180049460.1202@localhost
State New
Headers show

Commit Message

Finn Thain Nov. 17, 2010, 10:50 p.m. UTC
The FL_MMU logic in gcc/config/m68k/m68k-devices.def is bogus. FL_MMU is 
applied to processors for which it doesn't make sense:

- Fido1100 offers no virtual memory and no MMU (it has a Memory Protection 
Unit). The m68k-linux target builds multilibs for fidoa due to the FL_MMU 
flag, although there is no mainline Linux port for this device (neither in 
m68k nor m68knommu, AFAICT).

- CPU32 is supported by uClinux, yet it is flagged FL_MMU but not 
FL_UCLINUX.

- MC6830x devices are also supported by uClinux. They are flagged FL_MMU 
despite having no support for virtual memory (AFAICT).

The m68k-uclinux target gets m68000 multilibs for m68302 (it has an EC000 
core) apparently by accident, i.e. only because the 68000 and 68010 
processors are not flagged FL_MMU. Oddly enough, the m68k-linux target 
does not get m68000 multilibs even though the 68302 is flagged FL_MMU!

So, FL_MMU cannot consistently be taken to mean any of "has Memory 
Management Unit", "only for linux" or "not for uclinux". FL_UCLINUX seems 
to be a partial workaround.

Far better IMHO to expliticly specify multilibs instead. The following 
patch does so.

It also drops the m68k-linux multilibs for fidoa (reason being that a 
device designed for hard real-time and with hardware context switching is 
not a likely candidate for a future Linux port).

This patch does not change any other multilibs even though cpu32 is 
missing from the m68k-uclinux target. (The m68knommu Linux port is the 
only one that supports a CPU32 device, i.e. MC68360.)

Presently m68k-linux libgfortran fails to build, because of the cpu32 
multilib:

../../../../gcc-4.5-20101021/libgfortran/generated/set_exponent_r4.c: In function 'set_exponent_r4':
/home/fthain/btc-0.12/gcc-4.5/m68k-linux-gnu/sysroot/usr/include/bits/mathinline.h:275:749: error: impossible constraint in 'asm'

This is the mathinline.h from glibc. A workaround for this issue that 
fixes the build for cpu32 (but not fidoa) is this addition to 
gcc/config/m68k/t-linux:

ifeq ($(M68K_ARCH),m68k)
MULTILIB_EXTRA_OPTS=mhard-float
endif

But since uClibc has the same mathinline.h header, perhaps the best fix is 
to add the flag in libgfortran itself?

BTW, on the topic of multilib issues, has anyone managed to build 
--with-arch=cf --enable-multilib? It doesn't build for me. Is this 
configuration supported?

Regards,
Finn


2010-11-17  Finn Thain  <fthain@telegraphics.com.au>

	* config/m68k/m68k-devices.def (FL_MMU, FL_UCLINUX): Remove.
	* gcc/config/m68k/m68k.h (FL_MMU, FL_UCLINUX): Remove.
	* config/m68k/t-linux (FL_MMU): Remove.
	(M68K_MLIB_CPU): Specify multilibs explicitly. Drop fidoa.
	* config/m68k/t-uclinux (FL_MMU, FL_UCLINUX): Remove.
	(M68K_MLIB_CPU): Specify multilibs explicitly.

Comments

Thorsten Glaser Nov. 17, 2010, 11 p.m. UTC | #1
Finn Thain dixit:

>Presently m68k-linux libgfortran fails to build, because of the cpu32 

Since cpu32 is for uClinux mostly, from what I heard, I dropped its
multilib in Debian. We have only standard, 68040 and 68060 there at
the moment.

Does it make sense to have it at all, even though someone apparently
ported glibc to it?

bye,
//mirabilos
Finn Thain Nov. 17, 2010, 11:45 p.m. UTC | #2
On Wed, 17 Nov 2010, Thorsten Glaser wrote:

> Finn Thain dixit:
> 
> >Presently m68k-linux libgfortran fails to build, because of the cpu32
> 
> Since cpu32 is for uClinux

I believe it is supported by newlib.

> mostly, from what I heard, I dropped its multilib in Debian. We have 
> only standard, 68040 and 68060 there at the moment.

Most likely debian will always need to adjust mulitlibs. Which is probably 
why they are happy with your patch. I'm not really doing this for debian.

> 
> Does it make sense to have it at all, even though someone apparently
> ported glibc to it?

Dropping cpu32 from m68k-linux doesn't solve the gfortran problem for 
uclinux.

Finn

> 
> bye,
> //mirabilos
>
Thorsten Glaser Nov. 18, 2010, 8:41 a.m. UTC | #3
Finn Thain dixit:

>I believe it is supported by newlib.
[…]
>Dropping cpu32 from m68k-linux doesn't solve the gfortran problem for 
>uclinux.

True. Yes, this should be fixed on the gcc level, although it won’t
reflect in Debian because I only need to build multiarch/lib for
things that are actually usable there. So, no input from me on the
gcc-level problem, sorry. (Does newlib use m68k-unknown-linux-gnu
as well? I thought that was for (e)glibc only.)

bye,
//mirabilos
Finn Thain Nov. 19, 2010, 3:05 a.m. UTC | #4
On Thu, 18 Nov 2010, Thorsten Glaser wrote:

> Finn Thain dixit:
> 
> >I believe it is supported by newlib.
> [?]
> >Dropping cpu32 from m68k-linux doesn't solve the gfortran problem for 
> >uclinux.
> 
> True. Yes, this should be fixed on the gcc level, although it won?t 
> reflect in Debian because I only need to build multiarch/lib for things 
> that are actually usable there.

Right, glibc uses CAS instructions which are not implemented on CPU32. But 
the larger question of m68k-uclinux and m68k-linux ABI compatibility is 
one I can't answer, though I had the impression that m68k-uclinux had 
adopted the m68k-linux ABI.

> So, no input from me on the gcc-level problem, sorry. (Does newlib use 
> m68k-unknown-linux-gnu as well? I thought that was for (e)glibc only.)

I don't know. In my tests I only built uclinux and linux cross-compilers. 
Hence, the patch I sent only disables fidoa mulitlibs, and doesn't affect 
cpu32 or any other multlibs.

Finn

> 
> bye,
> //mirabilos
>
Maxim Kuvyrkov Nov. 19, 2010, 11:02 a.m. UTC | #5
On Nov 18, 2010, at 1:50 AM, Finn Thain wrote:

> BTW, on the topic of multilib issues, has anyone managed to build 
> --with-arch=cf --enable-multilib? It doesn't build for me. Is this 
> configuration supported?

Yes, it is supported.  This is how all CodeSourcery's ColdFire toolchains are built.

> 2010-11-17  Finn Thain  <fthain@telegraphics.com.au>
> 
> 	* config/m68k/m68k-devices.def (FL_MMU, FL_UCLINUX): Remove.
> 	* gcc/config/m68k/m68k.h (FL_MMU, FL_UCLINUX): Remove.
> 	* config/m68k/t-linux (FL_MMU): Remove.
> 	(M68K_MLIB_CPU): Specify multilibs explicitly. Drop fidoa.
> 	* config/m68k/t-uclinux (FL_MMU, FL_UCLINUX): Remove.
> 	(M68K_MLIB_CPU): Specify multilibs explicitly.

I don't think specifying multilibs explicitly is a good approach for M68K port.  It seems cleaner to annotate the device descriptions with flags specifying which target triplet a particular device supports.

Now, I do agree that the flag names are not very descriptive of their effect, that is due to historic reasons.  "FL_MMU" is equivalent to "supports GNU/Linux", and "!FL_MMU || FL_UCLINUX" is equivalent to "supports uClinux", and bare-metal target is naturally supported for any device.  I think it would be a nice cleanup to transform these into self-descriptive FL_LINUX and FL_UCLINUX flags.

Regards,

--
Maxim Kuvyrkov
CodeSourcery
+1-650-331-3385 x724
diff mbox

Patch

Index: gcc-4.5-20101021/gcc/config/m68k/m68k-devices.def
===================================================================
--- gcc-4.5-20101021.orig/gcc/config/m68k/m68k-devices.def	2009-11-17 21:23:10.000000000 +1100
+++ gcc-4.5-20101021/gcc/config/m68k/m68k-devices.def	2010-11-17 23:52:47.720286251 +1100
@@ -72,13 +72,13 @@ 
 /* 680x0 series processors.  */
 M68K_DEVICE ("68000", m68000,   "68000", "68000", 68000,    isa_00,    0)
 M68K_DEVICE ("68010", m68010,   "68010", "68000", 68010,    isa_10,    0)
-M68K_DEVICE ("68020", m68020,   "68020", "68020", 68020,    isa_20,    FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("68030", m68030,   "68030", "68020", 68030,    isa_20,    FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("68040", m68040,   "68040", "68040", 68040,    isa_40,    FL_MMU)
-M68K_DEVICE ("68060", m68060,   "68060", "68060", 68060,    isa_40,    FL_MMU)
-M68K_DEVICE ("68302", m68302,   "68302", "68000", 68000,    isa_00,    FL_MMU)
-M68K_DEVICE ("68332", m68332,   "68332", "cpu32", cpu32,    isa_cpu32, FL_MMU)
-M68K_DEVICE ("cpu32", cpu32,    "cpu32", "cpu32", cpu32,    isa_cpu32, FL_MMU)
+M68K_DEVICE ("68020", m68020,   "68020", "68020", 68020,    isa_20,    0)
+M68K_DEVICE ("68030", m68030,   "68030", "68020", 68030,    isa_20,    0)
+M68K_DEVICE ("68040", m68040,   "68040", "68040", 68040,    isa_40,    0)
+M68K_DEVICE ("68060", m68060,   "68060", "68060", 68060,    isa_40,    0)
+M68K_DEVICE ("68302", m68302,   "68302", "68000", 68000,    isa_00,    0)
+M68K_DEVICE ("68332", m68332,   "68332", "cpu32", cpu32,    isa_cpu32, 0)
+M68K_DEVICE ("cpu32", cpu32,    "cpu32", "cpu32", cpu32,    isa_cpu32, 0)
 
 /* ColdFire CFV1 processor.  */
 /* For historical reasons, the 51 multilib is named 51qe.  */
@@ -159,31 +159,31 @@  M68K_DEVICE ("537x",  mcf537x,  "5373", 
 
 /* CFV4/CFV4e processors.  */
 M68K_DEVICE ("5407",  mcf5407,  "5407",  "5407",  cfv4,     isa_b,     FL_CF_MAC)
-M68K_DEVICE ("54410", mcf54410, "54418", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC | FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("54415", mcf54415, "54418", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC | FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("54416", mcf54416, "54418", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC | FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("54417", mcf54417, "54418", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC | FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("54418", mcf54418, "54418", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC | FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("54450", mcf54450, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC | FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("54451", mcf54451, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC | FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("54452", mcf54452, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC | FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("54453", mcf54453, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC | FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("54454", mcf54454, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC | FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("54455", mcf54455, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC | FL_MMU | FL_UCLINUX)
-M68K_DEVICE ("5470",  mcf5470,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("5471",  mcf5471,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("5472",  mcf5472,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("5473",  mcf5473,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("5474",  mcf5474,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("5475",  mcf5475,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("547x",  mcf547x,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("5480",  mcf5480,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("5481",  mcf5481,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("5482",  mcf5482,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("5483",  mcf5483,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("5484",  mcf5484,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("5485",  mcf5485,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
-M68K_DEVICE ("548x",  mcf548x,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU | FL_MMU)
+M68K_DEVICE ("54410", mcf54410, "54418", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC)
+M68K_DEVICE ("54415", mcf54415, "54418", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC)
+M68K_DEVICE ("54416", mcf54416, "54418", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC)
+M68K_DEVICE ("54417", mcf54417, "54418", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC)
+M68K_DEVICE ("54418", mcf54418, "54418", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC)
+M68K_DEVICE ("54450", mcf54450, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC)
+M68K_DEVICE ("54451", mcf54451, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC)
+M68K_DEVICE ("54452", mcf54452, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC)
+M68K_DEVICE ("54453", mcf54453, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC)
+M68K_DEVICE ("54454", mcf54454, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC)
+M68K_DEVICE ("54455", mcf54455, "54455", "54455", cfv4,     isa_c,     FL_CF_HWDIV | FL_CF_USP | FL_CF_EMAC)
+M68K_DEVICE ("5470",  mcf5470,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("5471",  mcf5471,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("5472",  mcf5472,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("5473",  mcf5473,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("5474",  mcf5474,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("5475",  mcf5475,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("547x",  mcf547x,  "5475",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("5480",  mcf5480,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("5481",  mcf5481,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("5482",  mcf5482,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("5483",  mcf5483,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("5484",  mcf5484,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("5485",  mcf5485,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
+M68K_DEVICE ("548x",  mcf548x,  "5485",  "5475",  cfv4e,    isa_b,     FL_CF_USP | FL_CF_EMAC | FL_CF_FPU)
 
 /* Fido processor.  */
-M68K_DEVICE ("fidoa", fidoa,    "cpu32", "fidoa", cpu32,    isa_cpu32, FL_FIDOA | FL_MMU)
+M68K_DEVICE ("fidoa", fidoa,    "cpu32", "fidoa", cpu32,    isa_cpu32, FL_FIDOA)
Index: gcc-4.5-20101021/gcc/config/m68k/m68k.h
===================================================================
--- gcc-4.5-20101021.orig/gcc/config/m68k/m68k.h	2009-09-23 01:49:54.000000000 +1000
+++ gcc-4.5-20101021/gcc/config/m68k/m68k.h	2010-11-17 23:52:47.720286251 +1100
@@ -232,8 +232,6 @@  along with GCC; see the file COPYING3.  
 #define FL_ISA_B     (1 << 15)
 #define FL_ISA_C     (1 << 16)
 #define FL_FIDOA     (1 << 17)
-#define FL_MMU 	     0   /* Used by multilib machinery.  */
-#define FL_UCLINUX   0   /* Used by multilib machinery.  */
 
 #define TARGET_68010		((m68k_cpu_flags & FL_ISA_68010) != 0)
 #define TARGET_68020		((m68k_cpu_flags & FL_ISA_68020) != 0)
Index: gcc-4.5-20101021/gcc/config/m68k/t-linux
===================================================================
--- gcc-4.5-20101021.orig/gcc/config/m68k/t-linux	2009-04-22 05:03:23.000000000 +1000
+++ gcc-4.5-20101021/gcc/config/m68k/t-linux	2010-11-17 23:52:47.720286251 +1100
@@ -18,8 +18,12 @@ 
 
 EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o
 
-# Only include multilibs for CPUs with an MMU.
-M68K_MLIB_CPU += && match(FLAGS, "FL_MMU")
+M68K_MLIB_CPU += && ( MLIB == "68020" || \
+                      MLIB == "68040" || \
+                      MLIB == "68060" || \
+                      MLIB == "cpu32" || \
+                      MLIB == "54455" || \
+                      MLIB == "5475"  )
 
 # This rule uses MULTILIB_MATCHES to generate a definition of
 # SYSROOT_SUFFIX_SPEC.
Index: gcc-4.5-20101021/gcc/config/m68k/t-uclinux
===================================================================
--- gcc-4.5-20101021.orig/gcc/config/m68k/t-uclinux	2009-05-14 01:10:55.000000000 +1000
+++ gcc-4.5-20101021/gcc/config/m68k/t-uclinux	2010-11-17 23:52:47.720286251 +1100
@@ -19,8 +19,17 @@ 
 # crti and crtn are provided by uClibc.
 EXTRA_MULTILIB_PARTS=crtbegin.o crtend.o
 
-# Include multilibs for CPUs without an MMU or with FL_UCLINUX
-M68K_MLIB_CPU += && (!match(FLAGS, "FL_MMU") || match(FLAGS, "FL_UCLINUX"))
+M68K_MLIB_CPU += && ( MLIB == "68000" || \
+                      MLIB == "68020" || \
+                      MLIB == "51qe"  || \
+                      MLIB == "5206"  || \
+                      MLIB == "5206e" || \
+                      MLIB == "5208"  || \
+                      MLIB == "5206e" || \
+                      MLIB == "5329"  || \
+                      MLIB == "5307"  || \
+                      MLIB == "5407"  || \
+                      MLIB == "54455" )
 
 # Add multilibs for execute-in-place and shared-library code.
 M68K_MLIB_OPTIONS += msep-data/mid-shared-library