Patchwork [Ada,Darwin] Restore PowerPC Darwin Ada bootstrap (after a looong time, it seems).

login
register
mail settings
Submitter IainS
Date Sept. 5, 2011, 6:50 p.m.
Message ID <253924DB-D841-4443-A571-02918471D1F5@sandoe-acoustics.co.uk>
Download mbox | patch
Permalink /patch/113427/
State New
Headers show

Comments

IainS - Sept. 5, 2011, 6:50 p.m.
Well, this was two needles in a haystack ...

... AFAICT from googling, powerpc-darwin9 has never bootstrapped ADA  
(I see questions but no resolution).
Perhaps Adacore has a version ... but I was unable to find any  
starting point - so this was somewhat tough to debug.

----

Anyway, there are two issues for 4.6 and three for trunk:

1.  rs6000.c (WORLD_SAVE_P) decides on the use of the out-of-line  
prologue saves on the basis of cfun->calls_setjmp && flag_exceptions.
    of course, flag_exceptions is NOT set by Ada for SjLj - which is  
what's used for the compiler build.

    - it doesn't seem reasonable to force -fexceptions - until we can  
build ada with ZCE.

    - so, given that SjLj exceptions are in use w/out the flag - it  
seems that the check should be adjusted.

2. (TRUNK-only)

   ** Eric, you removed the setting of cfun->calls_setjmp from gcc/ 
builtins.c (in June).   This (re)breaks trunk c.f. 4.6 - given the fix  
to (1).
   Was there some reason to remove this?

  ... would there be some more appropriate test for rs6000.c to use?

  ... if not, my proposed solution is to re-insert the check in  
builtins.c to remove the regression w.r.t. to 4.6.

3. There is no multi-lib target set for powerpc64-darwin, thus  
bootstrap fails with a Bad Alignment error in building the target libs.

Since this is a long-standing regression (last bootstrap for powerpc- 
darwin was likely in the 4.2 era).

OK for 4.6 (1, 3) and trunk (1,2 & 3) ?

FTR, the rs6000 change is local to the Darwin port.

Iain

gcc:

	* builtins.c (expand_builtin_setjmp_setup):  Note that the function  
calls builtin setjmp.
	* config/rs6000/rs6000.c (compute_save_world_info): Do not require  
flag_exceptions
	to be set when using SjLj.

ada:

	* gcc-interface/Makefile.in (darwin): Adjust LIBGNAT_TARGET_PAIRS for  
powerpc
	darwin on the basis of the arch.
	* system-darwin-ppc64.ads: New file.

+   --  The values defined here are copied from the ppc version.
+
+   Max_Interrupt_Priority : constant Positive := 63;
+   Max_Priority           : constant Positive :=  
Max_Interrupt_Priority - 1;
+
+   subtype Any_Priority is Integer range 0 .. Max_Interrupt_Priority;
+   subtype Priority is Any_Priority range 0 .. Max_Priority;
+   subtype Interrupt_Priority is Any_Priority
+     range Priority'Last + 1 .. Max_Interrupt_Priority;
+
+   Default_Priority : constant Priority :=
+     (Priority'Last - Priority'First) / 2;
+
+private
+
+   type Address is mod Memory_Size;
+   Null_Address : constant Address := 0;
+
+   --------------------------------------
+   -- System Implementation Parameters --
+   --------------------------------------
+
+   --  These parameters provide information about the target that is  
used
+   --  by the compiler. They are in the private part of System, where  
they
+   --  can be accessed using the special circuitry in the Targparm unit
+   --  whose source should be consulted for more detailed descriptions
+   --  of the individual switch values.
+
+   Backend_Divide_Checks     : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := True;
+   Command_Line_Args         : constant Boolean := True;
+   Configurable_Run_Time     : constant Boolean := False;
+   Denorm                    : constant Boolean := True;
+   Duration_32_Bits          : constant Boolean := False;
+   Exit_Status_Supported     : constant Boolean := True;
+   Fractional_Fixed_Ops      : constant Boolean := False;
+   Frontend_Layout           : constant Boolean := False;
+   Machine_Overflows         : constant Boolean := False;
+   Machine_Rounds            : constant Boolean := True;
+   Preallocated_Stacks       : constant Boolean := False;
+   Signed_Zeros              : constant Boolean := True;
+   Stack_Check_Default       : constant Boolean := False;
+   Stack_Check_Probes        : constant Boolean := False;
+   Stack_Check_Limits        : constant Boolean := False;
+   Support_64_Bit_Divides    : constant Boolean := True;
+   Support_Aggregates        : constant Boolean := True;
+   Support_Composite_Assign  : constant Boolean := True;
+   Support_Composite_Compare : constant Boolean := True;
+   Support_Long_Shifts       : constant Boolean := True;
+   Always_Compatible_Rep     : constant Boolean := False;
+   Suppress_Standard_Library : constant Boolean := False;
+   Use_Ada_Main_Program_Name : constant Boolean := False;
+   ZCX_By_Default            : constant Boolean := True;
+
+end System;
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 178554)
+++ gcc/builtins.c	(working copy)
@@ -815,6 +815,10 @@ expand_builtin_setjmp_setup (rtx buf_addr, rtx rec
     emit_insn (gen_builtin_setjmp_setup (buf_addr));
 #endif
 
+  /* This can be tested by a target to determine that the prologue may not use
+     register-saving functions.   */
+  cfun->calls_setjmp = 1;
+
   /* We have a nonlocal label.   */
   cfun->has_nonlocal_label = 1;
 }
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 178554)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -17945,7 +17945,7 @@ compute_save_world_info (rs6000_stack_t *info_ptr)
   info_ptr->world_save_p
     = (WORLD_SAVE_P (info_ptr)
        && DEFAULT_ABI == ABI_DARWIN
-       && ! (cfun->calls_setjmp && flag_exceptions)
+       && !cfun->calls_setjmp
        && info_ptr->first_fp_reg_save == FIRST_SAVED_FP_REGNO
        && info_ptr->first_gp_reg_save == FIRST_SAVED_GP_REGNO
        && info_ptr->first_altivec_reg_save == FIRST_SAVED_ALTIVEC_REGNO
Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in	(revision 178554)
+++ gcc/ada/gcc-interface/Makefile.in	(working copy)
@@ -2240,8 +2240,15 @@ ifeq ($(strip $(filter-out darwin%,$(osys))),)
     a-numaux.ads<a-numaux-darwin.ads \
     a-numaux.adb<a-numaux-darwin.adb \
     g-trasym.ads<g-trasym-unimplemented.ads \
-    g-trasym.adb<g-trasym-unimplemented.adb \
-    system.ads<system-darwin-ppc.ads
+    g-trasym.adb<g-trasym-unimplemented.adb
+    
+    ifeq ($(strip $(MULTISUBDIR)),/ppc64)
+      LIBGNAT_TARGET_PAIRS += \
+        system.ads<system-darwin-ppc64.ads
+    else
+      LIBGNAT_TARGET_PAIRS += \
+      system.ads<system-darwin-ppc.ads
+    endif
   endif
 
   TOOLS_TARGET_PAIRS =  \
Index: gcc/ada/system-darwin-ppc64.ads
===================================================================
--- gcc/ada/system-darwin-ppc64.ads	(revision 0)
+++ gcc/ada/system-darwin-ppc64.ads	(revision 0)
@@ -0,0 +1,296 @@
+------------------------------------------------------------------------------
+--                                                                          --
+--                        GNAT RUN-TIME COMPONENTS                          --
+--                                                                          --
+--                               S Y S T E M                                --
+--                                                                          --
+--                                 S p e c                                  --
+--                         (Darwin/PPC64 Version)                           --
+--                                                                          --
+--             Copyright (C) 2011, Free Software Foundation, Inc.           --
+--                                                                          --
+-- This specification is derived from the Ada Reference Manual for use with --
+-- GNAT. The copyright notice above, and the license provisions that follow --
+-- apply solely to the  contents of the part following the private keyword. --
+--                                                                          --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
+--                                                                          --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.               --
+--                                                                          --
+-- You should have received a copy of the GNU General Public License and    --
+-- a copy of the GCC Runtime Library Exception along with this program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
+-- <http://www.gnu.org/licenses/>.                                          --
+--                                                                          --
+-- GNAT was originally developed  by the GNAT team at  New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
+--                                                                          --
+------------------------------------------------------------------------------
+
+package System is
+   pragma Pure;
+   --  Note that we take advantage of the implementation permission to make
+   --  this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
+   --  2005, this is Pure in any case (AI-362).
+
+   type Name is (SYSTEM_NAME_GNAT);
+   System_Name : constant Name := SYSTEM_NAME_GNAT;
+
+   --  System-Dependent Named Numbers
+
+   Min_Int               : constant := Long_Long_Integer'First;
+   Max_Int               : constant := Long_Long_Integer'Last;
+
+   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
+   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
+
+   Max_Base_Digits       : constant := Long_Long_Float'Digits;
+   Max_Digits            : constant := Long_Long_Float'Digits;
+
+   Max_Mantissa          : constant := 63;
+   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
+
+   Tick                  : constant := 0.01;
+
+   --  Storage-related Declarations
+
+   type Address is private;
+   pragma Preelaborable_Initialization (Address);
+   Null_Address : constant Address;
+
+   Storage_Unit : constant := 8;
+   Word_Size    : constant := 64;
+   Memory_Size  : constant := 2 ** 64;
+
+   --  Address comparison
+
+   function "<"  (Left, Right : Address) return Boolean;
+   function "<=" (Left, Right : Address) return Boolean;
+   function ">"  (Left, Right : Address) return Boolean;
+   function ">=" (Left, Right : Address) return Boolean;
+   function "="  (Left, Right : Address) return Boolean;
+
+   pragma Import (Intrinsic, "<");
+   pragma Import (Intrinsic, "<=");
+   pragma Import (Intrinsic, ">");
+   pragma Import (Intrinsic, ">=");
+   pragma Import (Intrinsic, "=");
+
+   --  Other System-Dependent Declarations
+
+   type Bit_Order is (High_Order_First, Low_Order_First);
+   Default_Bit_Order : constant Bit_Order := High_Order_First;
+   pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
+
+   --  Priority-related Declarations (RM D.1)
+
+   --  The values defined here are copied from the ppc version.
+
+   Max_Interrupt_Priority : constant Positive := 63;
+   Max_Priority           : constant Positive := Max_Interrupt_Priority - 1;
+
+   subtype Any_Priority is Integer range 0 .. Max_Interrupt_Priority;
+   subtype Priority is Any_Priority range 0 .. Max_Priority;
+   subtype Interrupt_Priority is Any_Priority
+     range Priority'Last + 1 .. Max_Interrupt_Priority;
+
+   Default_Priority : constant Priority :=
+     (Priority'Last - Priority'First) / 2;
+
+private
+
+   type Address is mod Memory_Size;
+   Null_Address : constant Address := 0;
+
+   --------------------------------------
+   -- System Implementation Parameters --
+   --------------------------------------
+
+   --  These parameters provide information about the target that is used
+   --  by the compiler. They are in the private part of System, where they
+   --  can be accessed using the special circuitry in the Targparm unit
+   --  whose source should be consulted for more detailed descriptions
+   --  of the individual switch values.
+
+   Backend_Divide_Checks     : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := True;
+   Command_Line_Args         : constant Boolean := True;
+   Configurable_Run_Time     : constant Boolean := False;
+   Denorm                    : constant Boolean := True;
+   Duration_32_Bits          : constant Boolean := False;
+   Exit_Status_Supported     : constant Boolean := True;
+   Fractional_Fixed_Ops      : constant Boolean := False;
+   Frontend_Layout           : constant Boolean := False;
+   Machine_Overflows         : constant Boolean := False;
+   Machine_Rounds            : constant Boolean := True;
+   Preallocated_Stacks       : constant Boolean := False;
+   Signed_Zeros              : constant Boolean := True;
+   Stack_Check_Default       : constant Boolean := False;
+   Stack_Check_Probes        : constant Boolean := False;
+   Stack_Check_Limits        : constant Boolean := False;
+   Support_64_Bit_Divides    : constant Boolean := True;
+   Support_Aggregates        : constant Boolean := True;
+   Support_Composite_Assign  : constant Boolean := True;
+   Support_Composite_Compare : constant Boolean := True;
+   Support_Long_Shifts       : constant Boolean := True;
+   Always_Compatible_Rep     : constant Boolean := False;
+   Suppress_Standard_Library : constant Boolean := False;
+   Use_Ada_Main_Program_Name : constant Boolean := False;
+   ZCX_By_Default            : constant Boolean := True;
+
+end System;
+------------------------------------------------------------------------------
+--                                                                          --
+--                        GNAT RUN-TIME COMPONENTS                          --
+--                                                                          --
+--                               S Y S T E M                                --
+--                                                                          --
+--                                 S p e c                                  --
+--                         (Darwin/PPC64 Version)                           --
+--                                                                          --
+--             Copyright (C) 2011, Free Software Foundation, Inc.           --
+--                                                                          --
+-- This specification is derived from the Ada Reference Manual for use with --
+-- GNAT. The copyright notice above, and the license provisions that follow --
+-- apply solely to the  contents of the part following the private keyword. --
+--                                                                          --
+-- GNAT is free software;  you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
+--                                                                          --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.               --
+--                                                                          --
+-- You should have received a copy of the GNU General Public License and    --
+-- a copy of the GCC Runtime Library Exception along with this program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
+-- <http://www.gnu.org/licenses/>.                                          --
+--                                                                          --
+-- GNAT was originally developed  by the GNAT team at  New York University. --
+-- Extensive contributions were provided by Ada Core Technologies Inc.      --
+--                                                                          --
+------------------------------------------------------------------------------
+
+package System is
+   pragma Pure;
+   --  Note that we take advantage of the implementation permission to make
+   --  this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
+   --  2005, this is Pure in any case (AI-362).
+
+   type Name is (SYSTEM_NAME_GNAT);
+   System_Name : constant Name := SYSTEM_NAME_GNAT;
+
+   --  System-Dependent Named Numbers
+
+   Min_Int               : constant := Long_Long_Integer'First;
+   Max_Int               : constant := Long_Long_Integer'Last;
+
+   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
+   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
+
+   Max_Base_Digits       : constant := Long_Long_Float'Digits;
+   Max_Digits            : constant := Long_Long_Float'Digits;
+
+   Max_Mantissa          : constant := 63;
+   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
+
+   Tick                  : constant := 0.01;
+
+   --  Storage-related Declarations
+
+   type Address is private;
+   pragma Preelaborable_Initialization (Address);
+   Null_Address : constant Address;
+
+   Storage_Unit : constant := 8;
+   Word_Size    : constant := 64;
+   Memory_Size  : constant := 2 ** 64;
+
+   --  Address comparison
+
+   function "<"  (Left, Right : Address) return Boolean;
+   function "<=" (Left, Right : Address) return Boolean;
+   function ">"  (Left, Right : Address) return Boolean;
+   function ">=" (Left, Right : Address) return Boolean;
+   function "="  (Left, Right : Address) return Boolean;
+
+   pragma Import (Intrinsic, "<");
+   pragma Import (Intrinsic, "<=");
+   pragma Import (Intrinsic, ">");
+   pragma Import (Intrinsic, ">=");
+   pragma Import (Intrinsic, "=");
+
+   --  Other System-Dependent Declarations
+
+   type Bit_Order is (High_Order_First, Low_Order_First);
+   Default_Bit_Order : constant Bit_Order := High_Order_First;
+   pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
+
+   --  Priority-related Declarations (RM D.1)
+
+   --  The values defined here are copied from the ppc version.
+
+   Max_Interrupt_Priority : constant Positive := 63;
+   Max_Priority           : constant Positive := Max_Interrupt_Priority - 1;
+
+   subtype Any_Priority is Integer range 0 .. Max_Interrupt_Priority;
+   subtype Priority is Any_Priority range 0 .. Max_Priority;
+   subtype Interrupt_Priority is Any_Priority
+     range Priority'Last + 1 .. Max_Interrupt_Priority;
+
+   Default_Priority : constant Priority :=
+     (Priority'Last - Priority'First) / 2;
+
+private
+
+   type Address is mod Memory_Size;
+   Null_Address : constant Address := 0;
+
+   --------------------------------------
+   -- System Implementation Parameters --
+   --------------------------------------
+
+   --  These parameters provide information about the target that is used
+   --  by the compiler. They are in the private part of System, where they
+   --  can be accessed using the special circuitry in the Targparm unit
+   --  whose source should be consulted for more detailed descriptions
+   --  of the individual switch values.
+
+   Backend_Divide_Checks     : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := True;
+   Command_Line_Args         : constant Boolean := True;
+   Configurable_Run_Time     : constant Boolean := False;
+   Denorm                    : constant Boolean := True;
+   Duration_32_Bits          : constant Boolean := False;
+   Exit_Status_Supported     : constant Boolean := True;
+   Fractional_Fixed_Ops      : constant Boolean := False;
+   Frontend_Layout           : constant Boolean := False;
+   Machine_Overflows         : constant Boolean := False;
+   Machine_Rounds            : constant Boolean := True;
+   Preallocated_Stacks       : constant Boolean := False;
+   Signed_Zeros              : constant Boolean := True;
+   Stack_Check_Default       : constant Boolean := False;
+   Stack_Check_Probes        : constant Boolean := False;
+   Stack_Check_Limits        : constant Boolean := False;
+   Support_64_Bit_Divides    : constant Boolean := True;
+   Support_Aggregates        : constant Boolean := True;
+   Support_Composite_Assign  : constant Boolean := True;
+   Support_Composite_Compare : constant Boolean := True;
+   Support_Long_Shifts       : constant Boolean := True;
+   Always_Compatible_Rep     : constant Boolean := False;
+   Suppress_Standard_Library : constant Boolean := False;
+   Use_Ada_Main_Program_Name : constant Boolean := False;
+   ZCX_By_Default            : constant Boolean := True;
+
+end System;
Mike Stump - Sept. 6, 2011, 12:05 a.m.
On Sep 5, 2011, at 11:50 AM, Iain Sandoe <developer@sandoe-acoustics.co.uk> wrote:
> 1.  rs6000.c (WORLD_SAVE_P) decides on the use of the out-of-line prologue saves on the basis of cfun->calls_setjmp && flag_exceptions.
>   of course, flag_exceptions is NOT set by Ada for SjLj - which is what's used for the compiler build.

Ick...  It seems wrong to me....   15 years later and it still feels like there is too much chewing gum involved.  Unless someone has a better idea on how to press forward, I'll ok the Darwin only change to rs6000.  I think that the change to turn of fexceptions when doing exceptions is a better way forward, but that is like to be a way more destabilizing change and likely the Ada folks have their reasons why that won't work.
>
Geert Bosch - Sept. 6, 2011, 2:52 a.m.
On Sep 5, 2011, at 14:50, Iain Sandoe wrote:
> ... AFAICT from googling, powerpc-darwin9 has never bootstrapped ADA (I see questions but no resolution).
> Perhaps Adacore has a version ... but I was unable to find any starting point - so this was somewhat tough to debug.

Nope, if we had supported any PPC-darwin versions, the required changes would have been checked in. Of course, it is hardly surprising that the platform isn't commercially viable anymore. So, Ada(*) support depends on volunteers like you... :-)

  -Geert

--
* Note capitalization
Eric Botcazou - Sept. 6, 2011, 7:41 a.m.
> 1.  rs6000.c (WORLD_SAVE_P) decides on the use of the out-of-line
> prologue saves on the basis of cfun->calls_setjmp && flag_exceptions.
>     of course, flag_exceptions is NOT set by Ada for SjLj - which is
> what's used for the compiler build.

It isn't set because GNAT implements a different SJLJ scheme, entirely based 
on __builtin_setjmp/__builtin_longjmp.  It is incompatible with the regular 
EH scheme so flag_exceptions cannot be set.

>     - it doesn't seem reasonable to force -fexceptions - until we can
> build ada with ZCE.

Or change the SJLJ scheme.

>     - so, given that SjLj exceptions are in use w/out the flag - it
> seems that the check should be adjusted.
>
> 2. (TRUNK-only)
>
>    ** Eric, you removed the setting of cfun->calls_setjmp from gcc/
> builtins.c (in June).   This (re)breaks trunk c.f. 4.6 - given the fix
> to (1).
>    Was there some reason to remove this?

Yes, the comment just above was obsolete after the SPARC change.  Moreover, 
__builtin_setjmp is not like setjmp, it is lowered into internal constructs 
that represent all of its effects so using the cfun->calls_setjmp big hammer 
looks overkill to me.

>   ... would there be some more appropriate test for rs6000.c to use?

Possibly, what's the exact reason why the special routines cannot be used?

> 3. There is no multi-lib target set for powerpc64-darwin, thus
> bootstrap fails with a Bad Alignment error in building the target libs.
>
> Since this is a long-standing regression (last bootstrap for powerpc-
> darwin was likely in the 4.2 era).
>
> OK for 4.6 (1, 3) and trunk (1,2 & 3) ?

Be careful about system-darwin-ppc64.ads: I don't think you can backport an 
instance from the trunk to the 4.6 branch, as there is at least one entry 
missing at the end.

Thanks for working on this!
IainS - Sept. 6, 2011, 7:59 a.m.
Hello Eric,

On 6 Sep 2011, at 08:41, Eric Botcazou wrote:

>>    - it doesn't seem reasonable to force -fexceptions - until we can
>> build ada with ZCE.
>
> Or change the SJLJ scheme.

Hm. I'm probably being a bit dumb here - but not clear about which  
scheme/where in the code-base you have in mind.

(I get the point about the SjLj scheme used by Ada being different).

>>  ... would there be some more appropriate test for rs6000.c to use?
>
> Possibly, what's the exact reason why the special routines cannot be  
> used?

That's a good question, and one that I haven't got to the bottom of -  
but the exclusion was there in the original code-base [still in the  
vendor's tree too].
(also, the rs6000 pro/epilogue code is not the easiest to navigate).

>> 3. There is no multi-lib target set for powerpc64-darwin, thus
>> bootstrap fails with a Bad Alignment error in building the target  
>> libs.
>>
>> Since this is a long-standing regression (last bootstrap for powerpc-
>> darwin was likely in the 4.2 era).
>>
>> OK for 4.6 (1, 3) and trunk (1,2 & 3) ?
>
> Be careful about system-darwin-ppc64.ads: I don't think you can  
> backport an
> instance from the trunk to the 4.6 branch, as there is at least one  
> entry
> missing at the end.

Yes, I have a different version for 4.6 with the recently deleted  
entries still intact (and, of course, it has been tested).

cheers
Iain
Eric Botcazou - Sept. 6, 2011, 8:12 a.m.
> That's a good question, and one that I haven't got to the bottom of -
> but the exclusion was there in the original code-base [still in the
> vendor's tree too].
> (also, the rs6000 pro/epilogue code is not the easiest to navigate).

Assuming that this is because the non-local goto handler needs to find a 
register saved at a canonical place, you can try !cfun->has_nonlocal_label.

This will subsume the original check !(cfun->calls_setjmp && flag_exceptions)
as both the regular SJLJ scheme and the GNAT SJLJ scheme use it.

> Yes, I have a different version for 4.6 with the recently deleted
> entries still intact (and, of course, it has been tested).

OK.
Mike Stump - Sept. 6, 2011, 4:17 p.m.
On Sep 6, 2011, at 1:12 AM, Eric Botcazou wrote:
>> That's a good question, and one that I haven't got to the bottom of -
>> but the exclusion was there in the original code-base [still in the
>> vendor's tree too].
>> (also, the rs6000 pro/epilogue code is not the easiest to navigate).
> 
> Assuming that this is because the non-local goto handler needs to find a 
> register saved at a canonical place, you can try !cfun->has_nonlocal_label.

> This will subsume the original check !(cfun->calls_setjmp && flag_exceptions)
> as both the regular SJLJ scheme and the GNAT SJLJ scheme use it.

I can't confirm the assumption, but, if it holds, sounds nicer to me, thanks.

Patch

Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 178554)
+++ gcc/builtins.c	(working copy)
@@ -815,6 +815,10 @@  expand_builtin_setjmp_setup (rtx buf_addr, rtx rec
      emit_insn (gen_builtin_setjmp_setup (buf_addr));
  #endif

+  /* This can be tested by a target to determine that the prologue  
may not use
+     register-saving functions.   */
+  cfun->calls_setjmp = 1;
+
    /* We have a nonlocal label.   */
    cfun->has_nonlocal_label = 1;
  }
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 178554)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -17945,7 +17945,7 @@  compute_save_world_info (rs6000_stack_t  
*info_ptr)
    info_ptr->world_save_p
      = (WORLD_SAVE_P (info_ptr)
         && DEFAULT_ABI == ABI_DARWIN
-       && ! (cfun->calls_setjmp && flag_exceptions)
+       && !cfun->calls_setjmp
         && info_ptr->first_fp_reg_save == FIRST_SAVED_FP_REGNO
         && info_ptr->first_gp_reg_save == FIRST_SAVED_GP_REGNO
         && info_ptr->first_altivec_reg_save ==  
FIRST_SAVED_ALTIVEC_REGNO
Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in	(revision 178554)
+++ gcc/ada/gcc-interface/Makefile.in	(working copy)
@@ -2240,8 +2240,15 @@  ifeq ($(strip $(filter-out darwin%,$(osys))),)
      a-numaux.ads<a-numaux-darwin.ads \
      a-numaux.adb<a-numaux-darwin.adb \
      g-trasym.ads<g-trasym-unimplemented.ads \
-    g-trasym.adb<g-trasym-unimplemented.adb \
-    system.ads<system-darwin-ppc.ads
+    g-trasym.adb<g-trasym-unimplemented.adb
+
+    ifeq ($(strip $(MULTISUBDIR)),/ppc64)
+      LIBGNAT_TARGET_PAIRS += \
+        system.ads<system-darwin-ppc64.ads
+    else
+      LIBGNAT_TARGET_PAIRS += \
+      system.ads<system-darwin-ppc.ads
+    endif
    endif

    TOOLS_TARGET_PAIRS =  \
Index: gcc/ada/system-darwin-ppc64.ads
===================================================================
--- gcc/ada/system-darwin-ppc64.ads	(revision 0)
+++ gcc/ada/system-darwin-ppc64.ads	(revision 0)
@@ -0,0 +1,296 @@ 
+ 
------------------------------------------------------------------------------
+ 
--                                                                          --
+--                        GNAT RUN-TIME  
COMPONENTS                          --
+ 
--                                                                          --
+--                               S Y S T E  
M                                --
+ 
--                                                                          --
+--                                 S p e  
c                                  --
+--                         (Darwin/PPC64  
Version)                           --
+ 
--                                                                          --
+--             Copyright (C) 2011, Free Software Foundation,  
Inc.           --
+ 
--                                                                          --
+-- This specification is derived from the Ada Reference Manual for  
use with --
+-- GNAT. The copyright notice above, and the license provisions that  
follow --
+-- apply solely to the  contents of the part following the private  
keyword. --
+ 
--                                                                          --
+-- GNAT is free software;  you can  redistribute it  and/or modify it  
under --
+-- terms of the  GNU General Public License as published  by the Free  
Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any  
later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but  
WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of  
MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR  
PURPOSE.                                     --
+ 
--                                                                          --
+-- As a special exception under Section 7 of GPL version 3, you are  
granted --
+-- additional permissions described in the GCC Runtime Library  
Exception,   --
+-- version 3.1, as published by the Free Software  
Foundation.               --
+ 
--                                                                          --
+-- You should have received a copy of the GNU General Public License  
and    --
+-- a copy of the GCC Runtime Library Exception along with this  
program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not,  
see    --
+-- <http://www.gnu.org/licenses/ 
 >.                                          --
+ 
--                                                                          --
+-- GNAT was originally developed  by the GNAT team at  New York  
University. --
+-- Extensive contributions were provided by Ada Core Technologies  
Inc.      --
+ 
--                                                                          --
+ 
------------------------------------------------------------------------------
+
+package System is
+   pragma Pure;
+   --  Note that we take advantage of the implementation permission  
to make
+   --  this unit Pure instead of Preelaborable; see RM 13.7.1(15). In  
Ada
+   --  2005, this is Pure in any case (AI-362).
+
+   type Name is (SYSTEM_NAME_GNAT);
+   System_Name : constant Name := SYSTEM_NAME_GNAT;
+
+   --  System-Dependent Named Numbers
+
+   Min_Int               : constant := Long_Long_Integer'First;
+   Max_Int               : constant := Long_Long_Integer'Last;
+
+   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
+   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
+
+   Max_Base_Digits       : constant := Long_Long_Float'Digits;
+   Max_Digits            : constant := Long_Long_Float'Digits;
+
+   Max_Mantissa          : constant := 63;
+   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
+
+   Tick                  : constant := 0.01;
+
+   --  Storage-related Declarations
+
+   type Address is private;
+   pragma Preelaborable_Initialization (Address);
+   Null_Address : constant Address;
+
+   Storage_Unit : constant := 8;
+   Word_Size    : constant := 64;
+   Memory_Size  : constant := 2 ** 64;
+
+   --  Address comparison
+
+   function "<"  (Left, Right : Address) return Boolean;
+   function "<=" (Left, Right : Address) return Boolean;
+   function ">"  (Left, Right : Address) return Boolean;
+   function ">=" (Left, Right : Address) return Boolean;
+   function "="  (Left, Right : Address) return Boolean;
+
+   pragma Import (Intrinsic, "<");
+   pragma Import (Intrinsic, "<=");
+   pragma Import (Intrinsic, ">");
+   pragma Import (Intrinsic, ">=");
+   pragma Import (Intrinsic, "=");
+
+   --  Other System-Dependent Declarations
+
+   type Bit_Order is (High_Order_First, Low_Order_First);
+   Default_Bit_Order : constant Bit_Order := High_Order_First;
+   pragma Warnings (Off, Default_Bit_Order); -- kill constant  
condition warning
+
+   --  Priority-related Declarations (RM D.1)
+
+   --  The values defined here are copied from the ppc version.
+
+   Max_Interrupt_Priority : constant Positive := 63;
+   Max_Priority           : constant Positive :=  
Max_Interrupt_Priority - 1;
+
+   subtype Any_Priority is Integer range 0 .. Max_Interrupt_Priority;
+   subtype Priority is Any_Priority range 0 .. Max_Priority;
+   subtype Interrupt_Priority is Any_Priority
+     range Priority'Last + 1 .. Max_Interrupt_Priority;
+
+   Default_Priority : constant Priority :=
+     (Priority'Last - Priority'First) / 2;
+
+private
+
+   type Address is mod Memory_Size;
+   Null_Address : constant Address := 0;
+
+   --------------------------------------
+   -- System Implementation Parameters --
+   --------------------------------------
+
+   --  These parameters provide information about the target that is  
used
+   --  by the compiler. They are in the private part of System, where  
they
+   --  can be accessed using the special circuitry in the Targparm unit
+   --  whose source should be consulted for more detailed descriptions
+   --  of the individual switch values.
+
+   Backend_Divide_Checks     : constant Boolean := False;
+   Backend_Overflow_Checks   : constant Boolean := True;
+   Command_Line_Args         : constant Boolean := True;
+   Configurable_Run_Time     : constant Boolean := False;
+   Denorm                    : constant Boolean := True;
+   Duration_32_Bits          : constant Boolean := False;
+   Exit_Status_Supported     : constant Boolean := True;
+   Fractional_Fixed_Ops      : constant Boolean := False;
+   Frontend_Layout           : constant Boolean := False;
+   Machine_Overflows         : constant Boolean := False;
+   Machine_Rounds            : constant Boolean := True;
+   Preallocated_Stacks       : constant Boolean := False;
+   Signed_Zeros              : constant Boolean := True;
+   Stack_Check_Default       : constant Boolean := False;
+   Stack_Check_Probes        : constant Boolean := False;
+   Stack_Check_Limits        : constant Boolean := False;
+   Support_64_Bit_Divides    : constant Boolean := True;
+   Support_Aggregates        : constant Boolean := True;
+   Support_Composite_Assign  : constant Boolean := True;
+   Support_Composite_Compare : constant Boolean := True;
+   Support_Long_Shifts       : constant Boolean := True;
+   Always_Compatible_Rep     : constant Boolean := False;
+   Suppress_Standard_Library : constant Boolean := False;
+   Use_Ada_Main_Program_Name : constant Boolean := False;
+   ZCX_By_Default            : constant Boolean := True;
+
+end System;
+ 
------------------------------------------------------------------------------
+ 
--                                                                          --
+--                        GNAT RUN-TIME  
COMPONENTS                          --
+ 
--                                                                          --
+--                               S Y S T E  
M                                --
+ 
--                                                                          --
+--                                 S p e  
c                                  --
+--                         (Darwin/PPC64  
Version)                           --
+ 
--                                                                          --
+--             Copyright (C) 2011, Free Software Foundation,  
Inc.           --
+ 
--                                                                          --
+-- This specification is derived from the Ada Reference Manual for  
use with --
+-- GNAT. The copyright notice above, and the license provisions that  
follow --
+-- apply solely to the  contents of the part following the private  
keyword. --
+ 
--                                                                          --
+-- GNAT is free software;  you can  redistribute it  and/or modify it  
under --
+-- terms of the  GNU General Public License as published  by the Free  
Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any  
later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but  
WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of  
MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR  
PURPOSE.                                     --
+ 
--                                                                          --
+-- As a special exception under Section 7 of GPL version 3, you are  
granted --
+-- additional permissions described in the GCC Runtime Library  
Exception,   --
+-- version 3.1, as published by the Free Software  
Foundation.               --
+ 
--                                                                          --
+-- You should have received a copy of the GNU General Public License  
and    --
+-- a copy of the GCC Runtime Library Exception along with this  
program;     --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not,  
see    --
+-- <http://www.gnu.org/licenses/ 
 >.                                          --
+ 
--                                                                          --
+-- GNAT was originally developed  by the GNAT team at  New York  
University. --
+-- Extensive contributions were provided by Ada Core Technologies  
Inc.      --
+ 
--                                                                          --
+ 
------------------------------------------------------------------------------
+
+package System is
+   pragma Pure;
+   --  Note that we take advantage of the implementation permission  
to make
+   --  this unit Pure instead of Preelaborable; see RM 13.7.1(15). In  
Ada
+   --  2005, this is Pure in any case (AI-362).
+
+   type Name is (SYSTEM_NAME_GNAT);
+   System_Name : constant Name := SYSTEM_NAME_GNAT;
+
+   --  System-Dependent Named Numbers
+
+   Min_Int               : constant := Long_Long_Integer'First;
+   Max_Int               : constant := Long_Long_Integer'Last;
+
+   Max_Binary_Modulus    : constant := 2 ** Long_Long_Integer'Size;
+   Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
+
+   Max_Base_Digits       : constant := Long_Long_Float'Digits;
+   Max_Digits            : constant := Long_Long_Float'Digits;
+
+   Max_Mantissa          : constant := 63;
+   Fine_Delta            : constant := 2.0 ** (-Max_Mantissa);
+
+   Tick                  : constant := 0.01;
+
+   --  Storage-related Declarations
+
+   type Address is private;
+   pragma Preelaborable_Initialization (Address);
+   Null_Address : constant Address;
+
+   Storage_Unit : constant := 8;
+   Word_Size    : constant := 64;
+   Memory_Size  : constant := 2 ** 64;
+
+   --  Address comparison
+
+   function "<"  (Left, Right : Address) return Boolean;
+   function "<=" (Left, Right : Address) return Boolean;
+   function ">"  (Left, Right : Address) return Boolean;
+   function ">=" (Left, Right : Address) return Boolean;
+   function "="  (Left, Right : Address) return Boolean;
+
+   pragma Import (Intrinsic, "<");
+   pragma Import (Intrinsic, "<=");
+   pragma Import (Intrinsic, ">");
+   pragma Import (Intrinsic, ">=");
+   pragma Import (Intrinsic, "=");
+
+   --  Other System-Dependent Declarations
+
+   type Bit_Order is (High_Order_First, Low_Order_First);
+   Default_Bit_Order : constant Bit_Order := High_Order_First;
+   pragma Warnings (Off, Default_Bit_Order); -- kill constant  
condition warning
+
+   --  Priority-related Declarations (RM D.1)
+