This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] GCC multilib vs. OS multilib naming followup


Hi!

The following patch should fix 3 different problems with the patch I
commited yesterday. First the problem found by Alex,
should fix --disable-multilib on MULTILIB_OSDIRNAMES arches and
should fix sparc64-sun-solaris2.8 --enable-multilib build.
sparc64-sun-solaris2.8 build problem was that I have added a check in
genmultilib which printed "sparcv9 someoptions;" instead of
"sparcv9:sparcv9 someoptions;" when MULTILIB_DEFAULTS is m64
on sparc*-sun-solaris*.
The --disable-multilib fix is a little bit more complicated, since
MULTILIB_DEFAULTS is not known until xgcc is run, so instead of precomputing
what OS multilib dir should be when --disable-multilib, like:
static const char *const multilib_raw[] = {
".:../lib64 ;",
NULL
};
in
multilib.h which would require duplicating knowledge about
MULTILIB_DEFAULTS, I chose to generate multilib.h like:
static const char *const multilib_raw[] = {
". !m64 !m32;",
".:../lib64 m64 !m32;",
".:../lib32 !m64 m32;",
NULL
};
...
in --disable-multilib case if MULTILIB_OSDIRNAMES is specified
and added code to skip dirs starting with .: from being printed in
-print-multi-lib output. This means -print-multi-lib in --disable-multilib
case stays the same, ie.
.;
and also --print-multi-directory with any options will still print
.
like it used to, on the other side --print-multi-os-directory will print
the right OS multilib directory, like
../lib64 in x86-64 --disable-multilib case.

Robert, could you please test this on sparc64-sun-solaris2.8?

Andreas kindly tested this on x86-64 both with --disable-multilib and without
it, thanks.

Ok to commit?

2002-10-03  Jakub Jelinek  <jakub@redhat.com>

	* gcc.c (set_multilib_dir): Don't access *end.
	Use memcpy instead of strncpy.  Don't write beyond malloced buffer.
	(print_multilib_info): Don't show paths starting with ".:".
	* genmultilib: Add new option, "yes" if multilibs are enabled.
	Update comments.  If multilibs not enabled, print .:${osdirout}
	for each directory.  If multilibs are enabled, always print
	${dirout}:${osdirout}, even if the two are the same.
	* Makefile.in (s-mlib): Pass @enable_multilib@ to genmultilib.
	Pass all MULTILIB_* variables to genmultilib even if
	--disable-multilib but MULTILIB_OSDIRNAMES is not empty.

--- gcc/gcc.c.jj	2002-10-03 21:21:03.000000000 +0200
+++ gcc/gcc.c	2002-10-04 13:58:46.000000000 +0200
@@ -6926,11 +6926,11 @@ set_multilib_dir ()
 
 	  while (q < end && *q != ':')
 	    q++;
-	  if (*q == ':')
+	  if (q < end)
 	    {
 	      char *new_multilib_os_dir = xmalloc (end - q);
-	      strncpy (new_multilib_os_dir, q + 1, end - q - 1);
-	      new_multilib_os_dir[end - q] = '\0';
+	      memcpy (new_multilib_os_dir, q + 1, end - q - 1);
+	      new_multilib_os_dir[end - q - 1] = '\0';
 	      multilib_os_dir = new_multilib_os_dir;
 	      break;
 	    }
@@ -6986,6 +6986,12 @@ print_multilib_info ()
 	  ++p;
 	}
 
+      /* When --disable-multilib was used but target defines
+	 MULTILIB_OSDIRNAMES, entries starting with .: are there just
+	 to find multilib_os_dir, so skip them from output.  */
+      if (this_path[0] == '.' && this_path[1] == ':')
+	skip = 1;
+
       /* Check for matches with the multilib_exclusions. We don't bother
          with the '!' in either list. If any of the exclusion rules match
          all of its options with the select rule, we skip it.  */
--- gcc/genmultilib.jj	2002-10-03 21:21:03.000000000 +0200
+++ gcc/genmultilib	2002-10-04 15:03:21.000000000 +0200
@@ -68,6 +68,9 @@
 # The difference is that second argument describes multilib directories
 # in GCC conventions, while this one the OS multilib convention.
 
+# The last option should be "yes" if multilibs are enabled.  If it is not
+# "yes", all GCC multilib dir names will be ".".
+
 # The output looks like
 #   #define MULTILIB_MATCHES "\
 #   SUBDIRECTORY OPTIONS;\
@@ -85,7 +88,7 @@
 #   genmultilib 'm64/m32 mno-app-regs|mcmodel=medany' '64 32 alt'
 #		'mcmodel?medany=mcmodel?medmid' 'm32/mno-app-regs* m32/mcmodel=*'
 #		'' 'm32/!m64/mno-app-regs m32/!m64/mcmodel=medany'
-#		'../lib64 ../lib32 alt'
+#		'../lib64 ../lib32 alt' yes
 # This produces:
 #   ". !m64 !m32 !mno-app-regs !mcmodel=medany;",
 #   "64:../lib64 m64 !m32 !mno-app-regs !mcmodel=medany;",
@@ -113,6 +116,7 @@ exceptions=$4
 extra=$5
 exclusions=$6
 osdirnames=$7
+enable_multilib=$8
 
 echo "static const char *const multilib_raw[] = {"
 
@@ -292,9 +296,18 @@ for combo in ${combinations}; do
     osdirout=`echo ${combo} | sed ${toosdirnames}`
     # Remove the leading and trailing slashes.
     osdirout=`echo ${osdirout} | sed -e 's|^/||' -e 's|/$||g'`
-    if [ "x${dirout}" != "x${osdirout}" ]; then
+    if [ "x${enable_multilib}" != xyes ]; then
+      dirout=".:${osdirout}"
+    else
       dirout="${dirout}:${osdirout}"
     fi
+  else
+    if [ "x${enable_multilib}" != xyes ]; then
+      # genmultilib with --disable-multilib should be
+      # called with '' '' '' '' '' '' '' no
+      # if MULTILIB_OSDIRNAMES is empty.
+      exit 1
+    fi
   fi
 
   # Look through the options.  We must output each option that is
--- gcc/Makefile.in.jj	2002-10-03 21:21:03.000000000 +0200
+++ gcc/Makefile.in	2002-10-04 14:10:31.000000000 +0200
@@ -1061,7 +1061,8 @@ libgcc.a: $(LIBGCC_DEPS)
 # switches.
 multilib.h: s-mlib; @true
 s-mlib: $(srcdir)/genmultilib Makefile
-	if test @enable_multilib@ = yes; then \
+	if test @enable_multilib@ = yes \
+	   || test -n "$(MULTILIB_OSDIRNAMES)"; then \
 	  $(SHELL) $(srcdir)/genmultilib \
 	    "$(MULTILIB_OPTIONS)" \
 	    "$(MULTILIB_DIRNAMES)" \
@@ -1070,9 +1071,11 @@ s-mlib: $(srcdir)/genmultilib Makefile
 	    "$(MULTILIB_EXTRA_OPTS)" \
 	    "$(MULTILIB_EXCLUSIONS)" \
 	    "$(MULTILIB_OSDIRNAMES)" \
+	    "@enable_multilib@" \
 	    > tmp-mlib.h; \
 	else \
-	  $(SHELL) $(srcdir)/genmultilib '' '' '' '' '' '' '' > tmp-mlib.h; \
+	  $(SHELL) $(srcdir)/genmultilib '' '' '' '' '' '' '' no \
+	    > tmp-mlib.h; \
 	fi
 	$(SHELL) $(srcdir)/move-if-change tmp-mlib.h multilib.h
 	$(STAMP) s-mlib

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]