diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 9376e00..82986a8 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1800,10 +1800,11 @@ s-mlib: $(srcdir)/genmultilib Makefile
 	    "$(MULTILIB_EXCLUSIONS)" \
 	    "$(MULTILIB_OSDIRNAMES)" \
 	    "$(MULTILIB_REQUIRED)" \
+	    "$(MULTILIB_REUSE)" \
 	    "@enable_multilib@" \
 	    > tmp-mlib.h; \
 	else \
-	  $(SHELL) $(srcdir)/genmultilib '' '' '' '' '' '' '' '' no\
+	  $(SHELL) $(srcdir)/genmultilib '' '' '' '' '' '' '' '' '' no\
 	    > tmp-mlib.h; \
 	fi
 	$(SHELL) $(srcdir)/../move-if-change tmp-mlib.h multilib.h
diff --git a/gcc/gcc.c b/gcc/gcc.c
index bbca6d8..94f29f1 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1212,6 +1212,7 @@ static struct spec_list static_specs[] =
   INIT_STATIC_SPEC ("multilib_matches",		&multilib_matches),
   INIT_STATIC_SPEC ("multilib_exclusions",	&multilib_exclusions),
   INIT_STATIC_SPEC ("multilib_options",		&multilib_options),
+  INIT_STATIC_SPEC ("multilib_reuse",		&multilib_reuse),
   INIT_STATIC_SPEC ("linker",			&linker_name_spec),
   INIT_STATIC_SPEC ("linker_plugin_file",	&linker_plugin_file_spec),
   INIT_STATIC_SPEC ("lto_wrapper",		&lto_wrapper_spec),
@@ -7471,10 +7472,16 @@ set_multilib_dir (void)
 
   first = 1;
   p = multilib_select;
+
+  /* Append multilib reuse rules if any.  With those rules, we can reuse
+     one multilib for certain different targets.  */
+  if (strlen(multilib_reuse) > 0)
+    p = concat (p, multilib_reuse, NULL);
+
   while (*p != '\0')
     {
-      /* Ignore newlines.  */
-      if (*p == '\n')
+      /* Ignore newlines and spaces.  */
+      if (*p == '\n' || *p == ' ')
 	{
 	  ++p;
 	  continue;
@@ -7487,8 +7494,8 @@ set_multilib_dir (void)
 	  if (*p == '\0')
 	    {
 	    invalid_select:
-	      fatal_error ("multilib select %qs is invalid",
-			   multilib_select);
+	      fatal_error ("multilib select %qs%qs is invalid",
+			   multilib_select, multilib_reuse);
 	    }
 	  ++p;
 	}
diff --git a/gcc/genmultilib b/gcc/genmultilib
index dc4751b..fca24db 100644
--- a/gcc/genmultilib
+++ b/gcc/genmultilib
@@ -84,6 +84,15 @@
 # This argument can be used together with MULTILIB_EXCEPTIONS and will take
 # effect after the MULTILIB_EXCEPTIONS.
 
+# The optional ninth argument is a set of predefined multilib selection rules
+# which will be appended to variable multilib_select defined in gcc.c and can
+# eventually impact how gcc selects multilib.  The rules in this argument will
+# be used only when gcc can't find suitable multilib from multilib_select.
+# This argument enables us to reuse one multilib among certain targets,
+# for example we can reuse multilib built with options "optA optB optC"
+# among options "optA optD optE" and "optA optF optG" with rules:
+# dirA optA optB optC;dirA optA optD optE;dirA optA optF optG;
+
 # The last option should be "yes" if multilibs are enabled.  If it is not
 # "yes", all GCC multilib dir names will be ".".
 
@@ -104,7 +113,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' '' yes
+#		'../lib64 ../lib32 alt' '' '' yes
 # This produces:
 #   ". !m64 !m32 !mno-app-regs !mcmodel=medany;",
 #   "64:../lib64 m64 !m32 !mno-app-regs !mcmodel=medany;",
@@ -133,7 +142,8 @@ extra=$5
 exclusions=$6
 osdirnames=$7
 multilib_required=$8
-enable_multilib=$9
+multilib_reuse=$9
+enable_multilib=${10}
 
 echo "static const char *const multilib_raw[] = {"
 
@@ -443,6 +453,10 @@ moptions=`echo ${options} | sed -e 's,[ 	][ 	]*, ,g'`
 echo ""
 echo "static const char *multilib_options = \"${moptions}\";"
 
+# Output the multilib reuse rules now
+echo ""
+echo "static const char *multilib_reuse = \"${multilib_reuse}\";"
+
 # Finally output the disable flag if specified
 if [ "x${disable_multilib}" = xyes ]; then
   echo ""
