Re: Make MicroBlaze support DWARF EH (old Xilinx patch, needed for glibc build)

2017-01-06 Thread Michael Eager

On 01/06/2017 01:34 AM, Edgar E. Iglesias wrote:

On Thu, Jan 05, 2017 at 05:58:01PM +, Joseph Myers wrote:

On Thu, 5 Jan 2017, Michael Eager wrote:


 On multiple occasions, I have asked Xilinx to submit patches such
 as this one directly to the GCC/Binutils projects (assuming that
 they have a current FSF Copyright Assignment), or to give me
 explicit permission to do so on their behalf, as was the case when
 I originally submitted the MicroBlaze port to these projects.  For
 whatever reason, neither has occurred.


copyright.list shows assignments from Xilinx for GCC, binutils, GDB and
glibc, with no indication that they are not current, or of any restriction
on who at Xilinx can contribute changes.

Thus, I presume we simply need someone at Xilinx to approve the
contribution of this patch to GCC.  The last patch sent to gcc-patches by
someone @xilinx.com appears to have been
; author and
other @xilinx.com people from that discussion CC:ed on this message.


Hi Joseph,

There's no problem from our side.
In fact, a version of this patch has already been posted to gcc-patches:
https://gcc.gnu.org/ml/gcc-patches/2013-03/msg00657.html

I don't do any work on the toolchain anymore and don't have the setup to
run the testsuite. Ajit or Nagaraju are might be able to help resolve
any issues.

Cheers,
Edgar




--
Joseph S. Myers
jos...@codesourcery.com




OK to apply.

--
Michael Eagerea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


Re: Make MicroBlaze support DWARF EH (old Xilinx patch, needed for glibc build)

2017-01-06 Thread Edgar E. Iglesias
On Thu, Jan 05, 2017 at 05:58:01PM +, Joseph Myers wrote:
> On Thu, 5 Jan 2017, Michael Eager wrote:
> 
> > On multiple occasions, I have asked Xilinx to submit patches such
> > as this one directly to the GCC/Binutils projects (assuming that
> > they have a current FSF Copyright Assignment), or to give me
> > explicit permission to do so on their behalf, as was the case when
> > I originally submitted the MicroBlaze port to these projects.  For
> > whatever reason, neither has occurred.
> 
> copyright.list shows assignments from Xilinx for GCC, binutils, GDB and 
> glibc, with no indication that they are not current, or of any restriction 
> on who at Xilinx can contribute changes.
> 
> Thus, I presume we simply need someone at Xilinx to approve the 
> contribution of this patch to GCC.  The last patch sent to gcc-patches by 
> someone @xilinx.com appears to have been 
> ; author and 
> other @xilinx.com people from that discussion CC:ed on this message.

Hi Joseph,

There's no problem from our side.
In fact, a version of this patch has already been posted to gcc-patches:
https://gcc.gnu.org/ml/gcc-patches/2013-03/msg00657.html

I don't do any work on the toolchain anymore and don't have the setup to
run the testsuite. Ajit or Nagaraju are might be able to help resolve
any issues.

Cheers,
Edgar


> 
> -- 
> Joseph S. Myers
> jos...@codesourcery.com


Re: Make MicroBlaze support DWARF EH (old Xilinx patch, needed for glibc build)

2017-01-05 Thread Joseph Myers
On Thu, 5 Jan 2017, Michael Eager wrote:

> On multiple occasions, I have asked Xilinx to submit patches such
> as this one directly to the GCC/Binutils projects (assuming that
> they have a current FSF Copyright Assignment), or to give me
> explicit permission to do so on their behalf, as was the case when
> I originally submitted the MicroBlaze port to these projects.  For
> whatever reason, neither has occurred.

copyright.list shows assignments from Xilinx for GCC, binutils, GDB and 
glibc, with no indication that they are not current, or of any restriction 
on who at Xilinx can contribute changes.

Thus, I presume we simply need someone at Xilinx to approve the 
contribution of this patch to GCC.  The last patch sent to gcc-patches by 
someone @xilinx.com appears to have been 
; author and 
other @xilinx.com people from that discussion CC:ed on this message.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: Make MicroBlaze support DWARF EH (old Xilinx patch, needed for glibc build)

2017-01-05 Thread Michael Eager

On 01/02/2017 03:45 PM, Joseph Myers wrote:

This patch, taken from

and with a few formatting cleanups and an update for the removal of
gen_rtx_raw_REG, enables DWARF EH support for MicroBlaze.

This is needed for building glibc with a compiler that includes shared
libgcc; right now all glibc builds for MicroBlaze are failing with my
bot for lack of this support.  (It's dubious if we should have glibc
ports at all where required support is missing in FSF GCC.)

Tested building glibc with build-many-glibcs.py.  I have *not* done
any other testing or any execution testing for MicroBlaze.  OK to
commit?


I have two concerns;

1.  Lack of testing on MicroBlaze.  Although the patch presumably works
in the Buildroot environment, that's not the same source base.

I may be able to build and test this patch, but it will be a couple
weeks before I can get to it.

2.  Ownership and copyright.  This is clearly not your authorship.
Submission of a patch explicitly indicates that you are assigning
your copyright interest in the patch to the FSF.  I don't believe
that you have copyright to this patch and can't assign it to FSF.

On multiple occasions, I have asked Xilinx to submit patches such
as this one directly to the GCC/Binutils projects (assuming that
they have a current FSF Copyright Assignment), or to give me
explicit permission to do so on their behalf, as was the case when
I originally submitted the MicroBlaze port to these projects.  For
whatever reason, neither has occurred.

The first issue is procedural/technical and easily resolved.  The
second issue involves Copyright Law.  IANAL, but my understanding is
that a third party cannot take a patch from a non-FSF/GNU repository
and apply it to an FSF/GNU repository without the authors' agreement
and assignment of copyright. (If Buildroot were an FSF/GNU project,
then copyright would have already been assigned to FSF, presumably,
and accepting the patch into GCC would not involve any transfer of
ownership.)

Does anyone have any authority on this copyright issue?


--
Michael Eagerea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


Make MicroBlaze support DWARF EH (old Xilinx patch, needed for glibc build)

2017-01-02 Thread Joseph Myers
This patch, taken from

and with a few formatting cleanups and an update for the removal of
gen_rtx_raw_REG, enables DWARF EH support for MicroBlaze.

This is needed for building glibc with a compiler that includes shared
libgcc; right now all glibc builds for MicroBlaze are failing with my
bot for lack of this support.  (It's dubious if we should have glibc
ports at all where required support is missing in FSF GCC.)

Tested building glibc with build-many-glibcs.py.  I have *not* done
any other testing or any execution testing for MicroBlaze.  OK to
commit?

2017-01-02  Edgar E. Iglesias 
David Holsgrove 

* common/config/microblaze/microblaze-common.c
(TARGET_EXCEPT_UNWIND_INFO): Remove.
* config/microblaze/microblaze-protos.h (microblaze_eh_return):
New prototype.
* config/microblaze/microblaze.c (microblaze_must_save_register)
(microblaze_expand_epilogue, microblaze_return_addr): Handle
calls_eh_return.
(microblaze_eh_return): New function.
* config/microblaze/microblaze.h (RETURN_ADDR_OFFSET)
(EH_RETURN_DATA_REGNO, MB_EH_STACKADJ_REGNUM)
(EH_RETURN_STACKADJ_RTX, ASM_PREFERRED_EH_DATA_FORMAT): New macros.
* config/microblaze/microblaze.md (eh_return): New pattern.

Index: gcc/common/config/microblaze/microblaze-common.c
===
--- gcc/common/config/microblaze/microblaze-common.c(revision 244001)
+++ gcc/common/config/microblaze/microblaze-common.c(working copy)
@@ -37,7 +37,4 @@ static const struct default_options microblaze_opt
 #undef  TARGET_OPTION_OPTIMIZATION_TABLE
 #define TARGET_OPTION_OPTIMIZATION_TABLE microblaze_option_optimization_table
 
-#undef TARGET_EXCEPT_UNWIND_INFO
-#define TARGET_EXCEPT_UNWIND_INFO  sjlj_except_unwind_info
-
 struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
Index: gcc/config/microblaze/microblaze-protos.h
===
--- gcc/config/microblaze/microblaze-protos.h   (revision 244001)
+++ gcc/config/microblaze/microblaze-protos.h   (working copy)
@@ -57,6 +57,7 @@ extern bool microblaze_tls_referenced_p (rtx);
 extern int symbol_mentioned_p (rtx);
 extern int label_mentioned_p (rtx);
 extern bool microblaze_cannot_force_const_mem (machine_mode, rtx);
+extern void microblaze_eh_return (rtx op0);
 #endif  /* RTX_CODE */
 
 /* Declare functions in microblaze-c.c.  */
Index: gcc/config/microblaze/microblaze.c
===
--- gcc/config/microblaze/microblaze.c  (revision 244001)
+++ gcc/config/microblaze/microblaze.c  (working copy)
@@ -1926,6 +1926,10 @@ microblaze_must_save_register (int regno)
   if (frame_pointer_needed && (regno == HARD_FRAME_POINTER_REGNUM))
 return 1;
 
+  if (crtl->calls_eh_return
+  && regno == MB_ABI_SUB_RETURN_ADDR_REGNUM)
+return 1;
+
   if (!crtl->is_leaf)
 {
   if (regno == MB_ABI_SUB_RETURN_ADDR_REGNUM)
@@ -1953,6 +1957,11 @@ microblaze_must_save_register (int regno)
return 1;
 }
 
+  if (crtl->calls_eh_return
+  && (regno == EH_RETURN_DATA_REGNO (0)
+  || regno == EH_RETURN_DATA_REGNO (1)))
+return 1;
+
   return 0;
 }
 
@@ -3029,6 +3038,12 @@ microblaze_expand_epilogue (void)
   emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, fsiz_rtx));
 }
 
+  if (crtl->calls_eh_return)
+emit_insn (gen_addsi3 (stack_pointer_rtx,
+   stack_pointer_rtx,
+   gen_raw_REG (SImode,
+   MB_EH_STACKADJ_REGNUM)));
+
   emit_jump_insn (gen_return_internal (gen_rtx_REG (Pmode, GP_REG_FIRST +

MB_ABI_SUB_RETURN_ADDR_REGNUM)));
 }
@@ -3326,12 +3341,16 @@ microblaze_return_addr (int count, rtx frame ATTRI
   if (count != 0)
 return NULL_RTX;
 
-  return gen_rtx_PLUS (Pmode,
-  get_hard_reg_initial_val (Pmode,
-MB_ABI_SUB_RETURN_ADDR_REGNUM),
-  GEN_INT (8));
+  return get_hard_reg_initial_val (Pmode,
+   MB_ABI_SUB_RETURN_ADDR_REGNUM);
 }
 
+void
+microblaze_eh_return (rtx op0)
+{
+  emit_insn (gen_movsi (gen_rtx_MEM (Pmode, stack_pointer_rtx), op0));
+}
+
 /* Queue an .ident string in the queue of top-level asm statements.
If the string size is below the threshold, put it into .sdata2.
If the front-end is done, we must be being called from toplev.c.
Index: gcc/config/microblaze/microblaze.h
===
--- gcc/config/microblaze/microblaze.h  (revision 244001)
+++ gcc/config/microblaze/microblaze.h  (working copy)
@@