[PATCH] Re: fix multilib generation for sparc64-linux

Jakub Jelinek jakub@redhat.com
Mon Dec 13 07:09:00 GMT 1999


On Sun, Dec 12, 1999 at 11:18:20AM -0500, Ben Collins wrote:
> When generating the multilib options for sparc64-linux I noticed a few
> problems. The current options allow for an "alt" that uses the
> "-mcmodel=medany -mno-app-regs" options. Under a normal compile we end up
> with a 'alt/' and '64/alt' multilib directory that are identical.

Have you seen it actually? It should not be ever generated twice. 64/alt is
not generated because MULTILIB_DEFAULTS contain m64 and thus the same
options are assumed already for alt/.
I always get 32/ and alt/ subdirs when configuring a compiler defaulting to
-m64.

> Also
> when compiling using --with-cpu=v7 (default m32) we attempt to compile the
> 'alt/' directory using the above options. This fails given that -mcmodel
> is invalid when we use -m32.

Yep, this is a problem, plus that currently using -m32 -mno-app-regs does
not work.

> This patche fixes both of these (actually
> the same problem, just two different symptoms) and also one small
> gramatical error in genmultilib that I saw :)
> 
> With these we get a multilib.h that looks like:
> 
> static char *multilib_raw[] = {
> ". !m64 !m32 !mno-app-regs !mcmodel=medany;",
> "64 m64 !m32 !mno-app-regs !mcmodel=medany;",
> "32 !m64 m32 !mno-app-regs !mcmodel=medany;",
> "64/alt m64 !m32 mno-app-regs mcmodel=medany;",
> "64/alt m64 !m32 mno-app-regs !mcmodel=medany;",
> "64/alt m64 !m32 !mno-app-regs mcmodel=medany;",
> NULL
> };

This is wrong. Have you looked at what ./xgcc -print-multi-lib prints with
this? It does not mention the 64/alt directory at all if the default is
-m64.
I was trying to convince genmultilib to generate multilib.h which would do
what I'd like it to, ie. build only 3 different directories, 32, 64 and alt,
but let e.g. -m32 -mno-app-regs go into the 32/ directory, but it turns out
that genmultilib is not able to generate it unless it would be hacked up
further. So, rather than fighting genmultilib, I took the approach of
providing a hand edited linux64 multilib.h, which should work well for both
cases (compiler defaulting to 32 or 64bits), create only 3 different
multilibes and work right with all the options passed to it.

1999-12-13  Jakub Jelinek  <jakub@redhat.com>

	* Makefile.in: If target fragment defines MULTILIB_H, use that
	multilib.h instead of generating one.
	* config/sparc/t-linux64 (MULTILIB_H): Set it, comment out all
	MULTILIB other variables.
	* config/sparc/ml-linux64.h: New file.

--- gcc/config/sparc/t-linux64.jj	Fri Dec 10 21:56:35 1999
+++ gcc/config/sparc/t-linux64	Mon Dec 13 15:16:53 1999
@@ -1,7 +1,8 @@
-MULTILIB_OPTIONS = m64/m32 mno-app-regs|mcmodel=medany
-MULTILIB_DIRNAMES = 64 32 alt 
-MULTILIB_MATCHES = mcmodel?medany=mcmodel?medmid
-MULTILIB_EXCEPTIONS = *m32/*medany *m32/*mno-app-regs
+# MULTILIB_OPTIONS = m64/m32 mno-app-regs|mcmodel=medany
+# MULTILIB_DIRNAMES = 64 32 alt 
+# MULTILIB_MATCHES = mcmodel?medany=mcmodel?medmid
+# MULTILIB_EXCEPTIONS = *m32/*medany
+MULTILIB_H = sparc/ml-linux64.h
 
 LIBGCC = stmp-multilib
 INSTALL_LIBGCC = install-multilib
--- gcc/config/sparc/ml-linux64.h.jj	Mon Dec 13 14:48:47 1999
+++ gcc/config/sparc/ml-linux64.h	Mon Dec 13 15:42:16 1999
@@ -0,0 +1,40 @@
+/* This is hand edited genmultilib output from:
+
+   MULTILIB_OPTIONS = m64/m32 mno-app-regs|mcmodel=medany
+   MULTILIB_DIRNAMES = 64 32 alt
+   MULTILIB_MATCHES = mcmodel?medany=mcmodel?medmid
+   MULTILIB_EXCEPTIONS = *m32/_*medany
+
+   with the following tweaks:
+   1) for -m32 -mno-app-regs go into the 32/ directory
+      instead of 32/alt
+   2) use alt/ for m64 alternative libs, no matter if the
+      default is -m32 or -m64.  */
+
+static char *multilib_raw[] = {
+#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 || TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc
+". !m32 !mno-app-regs !mcmodel=medany;",
+"32 m32;",
+"alt !m32 mno-app-regs mcmodel=medany;",
+"alt !m32 mno-app-regs !mcmodel=medany;",
+"alt !m32 !mno-app-regs mcmodel=medany;",
+#else
+". !m64;",
+"64 m64 !mno-app-regs !mcmodel=medany;",
+"alt m64 mno-app-regs mcmodel=medany;",
+"alt m64 mno-app-regs !mcmodel=medany;",
+"alt m64 !mno-app-regs mcmodel=medany;",
+#endif
+NULL
+};
+
+static char *multilib_matches_raw[] = {
+"mcmodel=medmid mcmodel=medany;",
+"m64 m64;",
+"m32 m32;",
+"mno-app-regs mno-app-regs;",
+"mcmodel=medany mcmodel=medany;",
+NULL
+};
+
+static char *multilib_extra = "";
--- gcc/Makefile.in.jj	Fri Dec 10 21:55:20 1999
+++ gcc/Makefile.in	Mon Dec 13 14:58:19 1999
@@ -1165,12 +1165,16 @@ libgcc.a: $(LIBGCC1) $(LIBGCC2)
 # switches.
 multilib.h: s-mlib; @true
 s-mlib: $(srcdir)/genmultilib Makefile
-	$(SHELL) $(srcdir)/genmultilib \
-	  "$(MULTILIB_OPTIONS)" \
-	  "$(MULTILIB_DIRNAMES)" \
-	  "$(MULTILIB_MATCHES)" \
-	  "$(MULTILIB_EXCEPTIONS)" \
-	  "$(MULTILIB_EXTRA_OPTS)" > tmp-mlib.h
+	-if [ x$(MULTILIB_H) != x ]; then \
+	  cp $(srcdir)/config/$(MULTILIB_H) tmp-mlib.h; \
+	else \
+	  $(SHELL) $(srcdir)/genmultilib \
+	    "$(MULTILIB_OPTIONS)" \
+	    "$(MULTILIB_DIRNAMES)" \
+	    "$(MULTILIB_MATCHES)" \
+	    "$(MULTILIB_EXCEPTIONS)" \
+	    "$(MULTILIB_EXTRA_OPTS)" > tmp-mlib.h; \
+	fi
 	$(SHELL) $(srcdir)/move-if-change tmp-mlib.h multilib.h
 	touch s-mlib
 


Cheers,
    Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.26 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________


More information about the Gcc-patches mailing list