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]

[rfa] Small multilib patch to deal with removed options


One motivation for DRIVER_SELF_SPECS was to provide a way of canonicalising
the driver's command line before it goes through the usual multilib machinery.
Usually the specs will add new options, but they can also take options away.

The problem is that the current multilib code doesn't expect options to
be taken away, and treats the removed options in the same way as others.
This can be fixed by checking switches[].live_cond against SWITCH_IGNORE,
as per the patch below.

[ One example of when this is useful is the combination of MIPS' -mabi*
  and -mgp* options.  With -mabi={32,o64,n32,64}, there's only one
  acceptable -mgp option: -mgp32 for -mabi=32 and -mgp64 for the others.
  However, with -mabi=eabi, both -mgp options make sense.

  The mips64vr*-elf configuration includes multilibs for these three ABIs:

      -mabi=32
      -mabi=eabi (implicitly -mgp64)
      -mabi=eabi -mgp32

  Given the current multilib machinery, the most natural way of doing this
  is to add the following MULTILIB_OPTIONS:

      mabi=32/mabi=eabi mgp32

  But this will build multilibs for both "-mabi=32" and "-mabi=32 -mgp32",
  which specify the same thing.  We can avoid this redundancy using the
  following entry in MULTILIB_EXCEPTIONS:

      mabi=32/mgp32

  but the multilib machinery will then treat "-mabi=32 -mgp32" as an
  unsupported combination.  In order to keep it working correctly,
  DRIVER_SELF_SPECS can be used to remove redundant -mgp32s from the
  command line.

  Note that agreeing on a canonical form isn't just useful for multilibs.
  It can sometimes simplify later spec strings as well. ]

Patch tested on mips64vrel-elf.  It makes "-mabi=32 -mgp32" work as
expected.  OK to install?

Richard


	* gcc.c (used_arg): Check whether an option has been removed.

-b version:

Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.411
diff -b -c -p -d -r1.411 gcc.c
*** gcc.c	5 Mar 2004 13:54:11 -0000	1.411
--- gcc.c	24 Mar 2004 14:27:40 -0000
*************** used_arg (const char *p, int len)
*** 6790,6795 ****
--- 6790,6796 ----
  	= xmalloc (sizeof (struct mswitchstr)
  		   * (n_mdswitches + (n_switches ? n_switches : 1)));
        for (i = 0; i < n_switches; i++)
+ 	if (switches[i].live_cond != SWITCH_IGNORE)
  	  {
  	    int xlen = strlen (switches[i].part1);
  	    for (j = 0; j < cnt; j++)

Version to commit:

Index: gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.411
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.411 gcc.c
*** gcc.c	5 Mar 2004 13:54:11 -0000	1.411
--- gcc.c	23 Mar 2004 12:54:48 -0000
*************** used_arg (const char *p, int len)
*** 6790,6809 ****
  	= xmalloc (sizeof (struct mswitchstr)
  		   * (n_mdswitches + (n_switches ? n_switches : 1)));
        for (i = 0; i < n_switches; i++)
! 	{
! 	  int xlen = strlen (switches[i].part1);
! 	  for (j = 0; j < cnt; j++)
! 	    if (xlen == matches[j].len
! 		&& ! strncmp (switches[i].part1, matches[j].str, xlen))
! 	      {
! 		mswitches[n_mswitches].str = matches[j].replace;
! 		mswitches[n_mswitches].len = matches[j].rep_len;
! 		mswitches[n_mswitches].replace = (char *) 0;
! 		mswitches[n_mswitches].rep_len = 0;
! 		n_mswitches++;
! 		break;
! 	      }
! 	}
  
        /* Add MULTILIB_DEFAULTS switches too, as long as they were not present
  	 on the command line nor any options mutually incompatible with
--- 6790,6810 ----
  	= xmalloc (sizeof (struct mswitchstr)
  		   * (n_mdswitches + (n_switches ? n_switches : 1)));
        for (i = 0; i < n_switches; i++)
! 	if (switches[i].live_cond != SWITCH_IGNORE)
! 	  {
! 	    int xlen = strlen (switches[i].part1);
! 	    for (j = 0; j < cnt; j++)
! 	      if (xlen == matches[j].len
! 		  && ! strncmp (switches[i].part1, matches[j].str, xlen))
! 		{
! 		  mswitches[n_mswitches].str = matches[j].replace;
! 		  mswitches[n_mswitches].len = matches[j].rep_len;
! 		  mswitches[n_mswitches].replace = (char *) 0;
! 		  mswitches[n_mswitches].rep_len = 0;
! 		  n_mswitches++;
! 		  break;
! 		}
! 	  }
  
        /* Add MULTILIB_DEFAULTS switches too, as long as they were not present
  	 on the command line nor any options mutually incompatible with


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