public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix print_multilib_info when default arguments appear in the option list with '!'
@ 2020-11-26  9:04 Kito Cheng
  2020-11-27 23:44 ` Jim Wilson
  0 siblings, 1 reply; 3+ messages in thread
From: Kito Cheng @ 2020-11-26  9:04 UTC (permalink / raw)
  To: gcc-patches, jimw, kito.cheng; +Cc: Kito Cheng

This issue is found when we try to always define MULTILIB_DEFAULTS for -march
and -mabi for RISC-V back-end, however `-print-multi-lib` will skip
multi-lib setting if match any one of flag in MULTILIB_DEFAULTS, even
some options are specified in the option list with '!'.

e.g.

We have default march=rv32i and mabi=ilp32.

And we have following multi-lib set:

". !march=rv32i !march=rv32im !march=rv32imafc !mabi=ilp32 !mabi=ilp32f;"
"rv32i/ilp32 march=rv32i !march=rv32im !march=rv32imafc mabi=ilp32 !mabi=ilp32f;"
"rv32im/ilp32 !march=rv32i march=rv32im !march=rv32imafc mabi=ilp32 !mabi=ilp32f;"
"rv32imafc/ilp32f !march=rv32i !march=rv32ic !march=rv32im march=rv32imafc !mabi=ilp32 mabi=ilp32f;"

`-print-multi-lib` willl show `.` and `rv32imafc/ilp32f` only, because
the mabi=ilp32 is matched, however there is `!march=rv32i` in `rv32im/ilp32`, so
`rv32im/ilp32` should keep, because it reject march=rv32i.

Note: This can be reproduced via following configure options with patch [1]:
gcc/configure --target=riscv64-elf --with-arch=rv32i --with-abi=ilp32 \
  --with-multilib-generator="rv32i-ilp32--;rv32im-ilp32--;rv32imafc-ilp32f--"

[1] https://gcc.gnu.org/pipermail/gcc-patches/2020-November/559707.html

gcc/ChangeLog:

	* gcc.c (print_multilib_info): Check default arguments not
	appeared in multi-lib option list with '!'
---
 gcc/gcc.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/gcc/gcc.c b/gcc/gcc.c
index 26bc5065eeb..b2a26b5af81 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -9730,6 +9730,7 @@ print_multilib_info (void)
   const char *p = multilib_select;
   const char *last_path = 0, *this_path;
   int skip;
+  int not_arg;
   unsigned int last_path_len = 0;
 
   while (*p != '\0')
@@ -9884,9 +9885,13 @@ print_multilib_info (void)
 		goto invalid_select;
 
 	      if (*q == '!')
-		arg = NULL;
+		{
+		  not_arg = 1;
+		  q++;
+		}
 	      else
-		arg = q;
+		not_arg = 0;
+	      arg = q;
 
 	      while (*q != ' ' && *q != ';')
 		{
@@ -9895,11 +9900,17 @@ print_multilib_info (void)
 		  ++q;
 		}
 
-	      if (arg != NULL
-		  && default_arg (arg, q - arg))
+	      if (default_arg (arg, q - arg))
 		{
-		  skip = 1;
-		  break;
+		  /* Stop checking if any default arguments appeared in not
+		     list.  */
+		  if (not_arg)
+		    {
+		      skip = 0;
+		      break;
+		    }
+		  else
+		    skip = 1;
 		}
 
 	      if (*q == ' ')
-- 
2.29.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix print_multilib_info when default arguments appear in the option list with '!'
  2020-11-26  9:04 [PATCH] Fix print_multilib_info when default arguments appear in the option list with '!' Kito Cheng
@ 2020-11-27 23:44 ` Jim Wilson
  2020-11-30  3:52   ` Kito Cheng
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Wilson @ 2020-11-27 23:44 UTC (permalink / raw)
  To: Kito Cheng; +Cc: GCC Patches, Kito Cheng

On Thu, Nov 26, 2020 at 1:04 AM Kito Cheng <kito.cheng@sifive.com> wrote:

>         * gcc.c (print_multilib_info): Check default arguments not
>         appeared in multi-lib option list with '!'
>

OK.

Jim

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix print_multilib_info when default arguments appear in the option list with '!'
  2020-11-27 23:44 ` Jim Wilson
@ 2020-11-30  3:52   ` Kito Cheng
  0 siblings, 0 replies; 3+ messages in thread
From: Kito Cheng @ 2020-11-30  3:52 UTC (permalink / raw)
  To: Jim Wilson; +Cc: Kito Cheng, GCC Patches

Committed :)

On Sat, Nov 28, 2020 at 7:45 AM Jim Wilson <jimw@sifive.com> wrote:
>
> On Thu, Nov 26, 2020 at 1:04 AM Kito Cheng <kito.cheng@sifive.com> wrote:
>
> >         * gcc.c (print_multilib_info): Check default arguments not
> >         appeared in multi-lib option list with '!'
> >
>
> OK.
>
> Jim

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-30  3:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-26  9:04 [PATCH] Fix print_multilib_info when default arguments appear in the option list with '!' Kito Cheng
2020-11-27 23:44 ` Jim Wilson
2020-11-30  3:52   ` Kito Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).