Re: Regression of GCC >= 4.8.5 for 32-bit powerpc

Rin Okuyama <[email protected]> Wed, 14 Dec 2016 13:06:35 +0900
Newsgroups gmane.os.netbsd.devel.toolchain,gmane.os.netbsd.ports.powerpc
Message-ID <[email protected]>
On 2016/12/14 4:07, Matt Thomas wrote:
> I think the right fix is to make that last
>
> 	else
> 	  fputs ("ppc\n", asm_out_file);
>
> into
>
> 	else if (!global_options_set.x_rs6000_cpu_index)
> 	  fputs ("ppc\n", asm_out_file);
>
> I think that's that is needed.

Thank you for your correction. I slightly modified your version
in order to avoid dangling ".machine". With this patch, I obtained
working kernel and userland for IBM 405 (evbppc). Also, build.sh
successfully completes for evbppc-powerpc64. Is this OK with you?

Rin
--- src/external/gpl3/gcc/dist/gcc/config/rs6000/rs6000.c.orig	2016-12-14 09:33:08.692802297 +0900
+++ src/external/gpl3/gcc/dist/gcc/config/rs6000/rs6000.c	2016-12-14 09:43:15.721045362 +0900
@@ -5188,21 +5188,23 @@
    if (rs6000_default_cpu == 0 || rs6000_default_cpu[0] == '\0'
        || !global_options_set.x_rs6000_cpu_index)
      {
-      fputs ("\t.machine ", asm_out_file);
+      const char *p = NULL;
        if ((rs6000_isa_flags & OPTION_MASK_DIRECT_MOVE) != 0)
-	fputs ("power8\n", asm_out_file);
+	p = "power8";
        else if ((rs6000_isa_flags & OPTION_MASK_POPCNTD) != 0)
-	fputs ("power7\n", asm_out_file);
+	p = "power7";
        else if ((rs6000_isa_flags & OPTION_MASK_CMPB) != 0)
-	fputs ("power6\n", asm_out_file);
+	p = "power6";
        else if ((rs6000_isa_flags & OPTION_MASK_POPCNTB) != 0)
-	fputs ("power5\n", asm_out_file);
+	p = "power5";
        else if ((rs6000_isa_flags & OPTION_MASK_MFCRF) != 0)
-	fputs ("power4\n", asm_out_file);
+	p = "power4";
        else if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) != 0)
-	fputs ("ppc64\n", asm_out_file);
-      else
-	fputs ("ppc\n", asm_out_file);
+	p = "ppc64";
+      else if (!global_options_set.x_rs6000_cpu_index)
+	p = "ppc";
+      if (p != NULL)
+	fprintf (asm_out_file, "\t.machine %s\n", p);
      }
  #endif