Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-13 Thread Eric Botcazou
> I poked at this a little and noticed a difference between the x86_64
> support and the RISC-V support.  The RISC-V C language port has char
> as unsigned by default.  The x86_64 port has char signed by default.
> If I add a -fsigned-char option, then the testcase works as expected
> for RISC-V.  Curiously, the Ada compiler accepts -fsigned-char but not
> -funsigned-char.

But it accepts -fno-signed-char, which is equivalent. :-)  In any case, I 
agree that it should also accept -funsigned-char, now done.

> I tried hacking in a -funsigned-char flag, but when
> I use it with the x86_64 port the result is still correct.  Maybe my
> quick hack wasn't quite right.  Anyways, the default signedness of
> char has something to do with the problem.

I don't seem to be able to reproduce the failure with a cross-compiler though 
so that's really weird.


* gcc-interface/lang.opt (funsigned-char): New option.
* gcc-interface/misc.c (gnat_handle_option): Accept it.
* gcc-interface/utils.c (finish_character_type): Tweak comment.


-- 
Eric BotcazouIndex: gcc-interface/lang.opt
===
--- gcc-interface/lang.opt	(revision 262551)
+++ gcc-interface/lang.opt	(working copy)
@@ -80,6 +80,10 @@ fsigned-char
 Ada AdaWhy AdaSCIL
 Make \"char\" signed by default.
 
+funsigned-char
+Ada AdaWhy AdaSCIL
+Make \"char\" unsigned by default.
+
 gant
 Ada AdaWhy AdaSCIL Driver Joined Undocumented RejectNegative
 Catch typos.
Index: gcc-interface/misc.c
===
--- gcc-interface/misc.c	(revision 262551)
+++ gcc-interface/misc.c	(working copy)
@@ -170,6 +170,7 @@ gnat_handle_option (size_t scode, const
 
 case OPT_fshort_enums:
 case OPT_fsigned_char:
+case OPT_funsigned_char:
   /* These are handled by the middle-end.  */
   break;
 
Index: gcc-interface/utils.c
===
--- gcc-interface/utils.c	(revision 262551)
+++ gcc-interface/utils.c	(working copy)
@@ -1684,7 +1684,7 @@ record_builtin_type (const char *name, t
   integral types are unsigned.
 
   Unfortunately the signedness of 'char' in C is implementation-defined
-  and GCC even has the option -fsigned-char to toggle it at run time.
+  and GCC even has the option -f{un}signed-char to toggle it at run time.
   Since GNAT's philosophy is to be compatible with C by default, to wit
   Interfaces.C.char is defined as a mere copy of Character, we may need
   to declare character types as signed types in GENERIC and generate the


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-12 Thread Pierre-Marie de Rodat

On 07/13/2018 01:57 AM, Jim Wilson wrote:

I poked at this a little and noticed a difference between the x86_64
support and the RISC-V support.  The RISC-V C language port has char
as unsigned by default.  The x86_64 port has char signed by default.
If I add a -fsigned-char option, then the testcase works as expected
for RISC-V.  Curiously, the Ada compiler accepts -fsigned-char but not
-funsigned-char.  I tried hacking in a -funsigned-char flag, but when
I use it with the x86_64 port the result is still correct.  Maybe my
quick hack wasn't quite right.  Anyways, the default signedness of
char has something to do with the problem.


Ah, interesting! Last year, we installed specific code in the Ada front 
end and the DWARF back end to handle discrepancies between the 
INTEGER_TYPE signedness and the signedness to appear in debug info 
(https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/dwarf2out.c;h=c2422e29658b6a101034318deed224271e6f1ca7;hb=HEAD#l24561), 
but ironically here, it seems that we don’t handle properly when 
everything is unsigned.


I think the current testcase should work on RISC-V even without 
-fsigned-char: Character’s debug type should be unsigned in all cases. 
Maybe for some reason we don’t create the correct debug type in the Ada 
front end… Do you think I can reproduce this with a x86_64-linux 
compiler targetting something like riscv-elf? I don’t have access to a 
RISC-V board on which to build GCC.


--
Pierre-Marie de Rodat


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-12 Thread Jim Wilson
On Thu, Jul 12, 2018 at 8:56 AM, Pierre-Marie de Rodat
 wrote:
> I don’t have much more to say than debug11.adb’s comment ;-)
>
>> This testcase checks that in the DWARF description of the variant type
>> below, the C discriminant is properly described as unsigned, hence the
>> 0x5a
>> ('Z') and 0x80 (128) values in the DW_AT_discr_list attribute. If it was
>> described as signed, we would have instead 90 and -128.
>
> I don’t have an Ada RISC-V compiler (nor binutils) to check right now: would
> it be possible to send the corresponding debug11.s and debug11.o? Hopefully
> we just have to enhance the regexps.

I poked at this a little and noticed a difference between the x86_64
support and the RISC-V support.  The RISC-V C language port has char
as unsigned by default.  The x86_64 port has char signed by default.
If I add a -fsigned-char option, then the testcase works as expected
for RISC-V.  Curiously, the Ada compiler accepts -fsigned-char but not
-funsigned-char.  I tried hacking in a -funsigned-char flag, but when
I use it with the x86_64 port the result is still correct.  Maybe my
quick hack wasn't quite right.  Anyways, the default signedness of
char has something to do with the problem.

Jim


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-12 Thread Pierre-Marie de Rodat

On 07/08/2018 12:35 AM, Eric Botcazou wrote:

I haven't tried looking at the failures yet, and might not spend much
more time on this.  Two of them are debug related, and debug support
is a work in progress.  I need to finish the native riscv64-linux
support before we can do anything useful there, and I'd like to get
back to working on that as soon as possible.


No clue about debug11.adb, maybe Pierre-Marie could shed some light on it.


I don’t have much more to say than debug11.adb’s comment ;-)


This testcase checks that in the DWARF description of the variant type
below, the C discriminant is properly described as unsigned, hence the 0x5a
('Z') and 0x80 (128) values in the DW_AT_discr_list attribute. If it was
described as signed, we would have instead 90 and -128.


I don’t have an Ada RISC-V compiler (nor binutils) to check right now: 
would it be possible to send the corresponding debug11.s and debug11.o? 
Hopefully we just have to enhance the regexps.


--
Pierre-Marie de Rodat


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-07 Thread Eric Botcazou
> I haven't tried looking at the failures yet, and might not spend much
> more time on this.  Two of them are debug related, and debug support
> is a work in progress.  I need to finish the native riscv64-linux
> support before we can do anything useful there, and I'd like to get
> back to working on that as soon as possible.

No clue about debug11.adb, maybe Pierre-Marie could shed some light on it.

> The GNU-stack error looks a little worrisome.  I'd expect a linux port to
> get GNU-stack stuff right without much trouble.

The test checks that -ftrampolines forces the use of trampolines instead of 
descriptors.  If trampolines are generated on the stack for RISC-V, then the 
stack should be made executable when there are built.  Otherwise you can add 
the appropriate triplet to the dg-skip-if line.

In any case, that's benign since trampolines are not generated by default now.

> The last one is warn5.adb:29:30: warning: source alignment (4) < alignment
> of "Element_Type" (8) Maybe something I copied from the mips linux port is
> wrong for riscv64 linux.

No, this looks as expected, you just need to add the appropriate triplet to 
the list on line 29 when you have 15 seconds to kill.  Patchlet preapproved.

-- 
Eric Botcazou


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-07 Thread Jim Wilson
On Sat, Jul 7, 2018 at 9:41 AM, Eric Botcazou  wrote:
> You're welcome.  Are the 4 remaining failures related to stack checking?

FAIL: gnat.dg/debug11.adb scan-assembler-times 0x5a.*DW_AT_discr_list 1
FAIL: gnat.dg/debug11.adb scan-assembler-times 0x80.*DW_AT_discr_list 1
FAIL: gnat.dg/trampoline4.adb scan-assembler GNU-stack.*x
FAIL: gnat.dg/warn5.adb (test for excess errors)

I haven't tried looking at the failures yet, and might not spend much
more time on this.  Two of them are debug related, and debug support
is a work in progress.  I need to finish the native riscv64-linux
support before we can do anything useful there, and I'd like to get
back to working on that as soon as possible.  The GNU-stack error
looks a little worrisome.  I'd expect a linux port to get GNU-stack
stuff right without much trouble.  The last one is
warn5.adb:29:30: warning: source alignment (4) < alignment of "Element_Type" (8)
Maybe something I copied from the mips linux port is wrong for riscv64 linux.

Jim


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-07 Thread Eric Botcazou
> I tried adding the missing definition.  I now get
> 
> === acats Summary ===
> # of expected passes2320
> # of unexpected failures0
> 
> === gnat Summary ===
> 
> # of expected passes2779
> # of unexpected failures4
> # of expected failures  24
> # of unsupported tests  25
> 
> So yes, that solved my problem, and we have a working RISC-V Ada port
> now.  Thanks for the help.

You're welcome.  Are the 4 remaining failures related to stack checking?

-- 
Eric Botcazou


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-07 Thread Arnaud Charlet
> I tried adding the missing definition.  I now get
> 
> === acats Summary ===
> # of expected passes2320
> # of unexpected failures0
> 
> === gnat Summary ===
> 
> # of expected passes2779
> # of unexpected failures4
> # of expected failures  24
> # of unsupported tests  25
> 
> So yes, that solved my problem, and we have a working RISC-V Ada port
> now.  Thanks for the help.

Great!


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-07 Thread Jim Wilson
On Fri, Jul 6, 2018 at 12:55 AM, Eric Botcazou  wrote:
>> Ada doesn't use trampolines if you define...
>>
>> > +   Always_Compatible_Rep : constant Boolean := False;
>>
>> ...this to False.
>
> And also define TARGET_CUSTOM_FUNCTION_DESCRIPTORS for the architecture.

I tried adding the missing definition.  I now get

=== acats Summary ===
# of expected passes2320
# of unexpected failures0

=== gnat Summary ===

# of expected passes2779
# of unexpected failures4
# of expected failures  24
# of unsupported tests  25

So yes, that solved my problem, and we have a working RISC-V Ada port
now.  Thanks for the help.

Jim


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-06 Thread Jim Wilson
On Fri, Jul 6, 2018 at 12:16 AM, Arnaud Charlet  wrote:
>> Ada is a low priority side project for me, so if you want non-trivial changes
>> it may be a while before I can get to them.  There is a lot of other stuff
>> higher on my priority list at the moment, such as getting native gdb support
>> working.  If this isn't OK as is, then I'm willing to put work-in-progress
>> patches in a bug report or on a branch or something.
>>
>> OK?
>
> This is OK, thanks.
>
>> Jim
>>
>>   gcc/ada/
>>   * Makefile.rtl: Add riscv*-linux* support.
>>   * libgnarl/s-linux__riscv.ads: New.
>>   * libgnat/system-linux-riscv.ads: New.

Committed.

Jim


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-06 Thread Eric Botcazou
> Ada doesn't use trampolines if you define...
> 
> > +   Always_Compatible_Rep : constant Boolean := False;
> 
> ...this to False.

And also define TARGET_CUSTOM_FUNCTION_DESCRIPTORS for the architecture.

-- 
Eric Botcazou


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-06 Thread Eric Botcazou
> The result is good enough to bootstrap natively and seems to give reasonable
> native testsuite results for a first attempt.  The machine I'm running on
> has broken icache flushing, so trampolines won't work, and I suspect that
> is causing a lot of the testsuite failures.

Ada doesn't use trampolines if you define...

> +   Always_Compatible_Rep : constant Boolean := False;

...this to False.

-- 
Eric Botcazou


Re: [PATCH, Ada] RISC-V: Initial riscv linux Ada port.

2018-07-06 Thread Arnaud Charlet
> Ada is a low priority side project for me, so if you want non-trivial changes
> it may be a while before I can get to them.  There is a lot of other stuff
> higher on my priority list at the moment, such as getting native gdb support
> working.  If this isn't OK as is, then I'm willing to put work-in-progress
> patches in a bug report or on a branch or something.
> 
> OK?

This is OK, thanks.

> Jim
> 
>   gcc/ada/
>   * Makefile.rtl: Add riscv*-linux* support.
>   * libgnarl/s-linux__riscv.ads: New.
>   * libgnat/system-linux-riscv.ads: New.