public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/115591] New: ICE in riscv64-elf cross compiler, handling imported addresses
@ 2024-06-22 13:23 simon at pushface dot org
  2024-06-23 10:38 ` [Bug target/115591] internal error on global variable-length array ebotcazou at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: simon at pushface dot org @ 2024-06-22 13:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115591

            Bug ID: 115591
           Summary: ICE in riscv64-elf cross compiler, handling imported
                    addresses
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: simon at pushface dot org
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

Created attachment 58487
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58487&action=edit
Reproducer

Compiler in use: gnat-riscv64-elf-darwin-14.1.0-3 from
https://github.com/alire-project/GNAT-FSF-builds/releases

Compiling the attached reproducer with riscv64-elf-gcc -c --RTS=. bug.adb
results
in

during RTL pass: expand
+===========================GNAT BUG DETECTED==============================+
| 14.1.0 (riscv64-elf) in tree_to_uhwi, at tree.h:4951                     |
| Error detected around bug.adb:29:24                                      |
| Compiling bug.adb                                                        |
| Please submit a bug report; see https://gcc.gnu.org/bugs/ .              |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact command that you entered.                              |
| Also include sources listed below.                                       |
+==========================================================================+

Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.
Consider also -gnatd.n switch (see debug.adb).

system.ads
bug.adb
bug.ads
s-stoele.ads
s-stoele.adb
ada.ads
a-unccon.ads


raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:412

Note that
* this error doesn’t happen with an arm-eabi cross compiler
* it was present from GCC 12.2.0

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

* [Bug target/115591] internal error on global variable-length array
  2024-06-22 13:23 [Bug ada/115591] New: ICE in riscv64-elf cross compiler, handling imported addresses simon at pushface dot org
@ 2024-06-23 10:38 ` ebotcazou at gcc dot gnu.org
  2024-06-23 10:47 ` ebotcazou at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-06-23 10:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115591

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org
            Summary|ICE in riscv64-elf cross    |internal error on global
                   |compiler, handling imported |variable-length array
                   |addresses                   |
              Build|x86_64-apple-darwin21.6.0   |
             Status|UNCONFIRMED                 |NEW
          Component|ada                         |target
   Last reconfirmed|                            |2024-06-23
     Ever confirmed|0                           |1

--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
It's a buglet in the RISC-V back-end:

(gdb) bt
#0  internal_error (gmsgid=0x584aa67 "in %s, at %s:%d")
    at /home/eric/cvs/gcc/gcc/diagnostic.cc:2255
#1  0x0000000004ad30a2 in fancy_abort (
    file=0x4ea1be0 "/home/eric/cvs/gcc/gcc/tree.cc", line=6488, 
    function=0x4ea3cc1 "tree_to_uhwi")
    at /home/eric/cvs/gcc/gcc/diagnostic.cc:2380
#2  0x0000000002469386 in tree_to_uhwi (t=0x7ffff705aca8)
    at /home/eric/cvs/gcc/gcc/tree.cc:6488
#3  0x0000000002555b2e in riscv_valid_lo_sum_p (sym_type=SYMBOL_ABSOLUTE, 
    mode=E_BLKmode, x=0x7ffff717bb58)
    at /home/eric/cvs/gcc/gcc/config/riscv/riscv.cc:1706

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

* [Bug target/115591] internal error on global variable-length array
  2024-06-22 13:23 [Bug ada/115591] New: ICE in riscv64-elf cross compiler, handling imported addresses simon at pushface dot org
  2024-06-23 10:38 ` [Bug target/115591] internal error on global variable-length array ebotcazou at gcc dot gnu.org
@ 2024-06-23 10:47 ` ebotcazou at gcc dot gnu.org
  2024-06-23 14:42 ` simon at pushface dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-06-23 10:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115591

--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
The immediate fix is:

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index c17141d909a..5e34dc92210 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -1702,7 +1702,9 @@ riscv_valid_lo_sum_p (enum riscv_symbol_type sym_type,
machine_mode mode,
       align = (SYMBOL_REF_DECL (x)
               ? DECL_ALIGN (SYMBOL_REF_DECL (x))
               : 1);
-      size = (SYMBOL_REF_DECL (x) && DECL_SIZE (SYMBOL_REF_DECL (x))
+      size = (SYMBOL_REF_DECL (x)
+             && DECL_SIZE (SYMBOL_REF_DECL (x))
+             && tree_fits_uhwi_p (DECL_SIZE (SYMBOL_REF_DECL (x)))
              ? tree_to_uhwi (DECL_SIZE (SYMBOL_REF_DECL (x)))
              : 2*BITS_PER_WORD);
     }

but I cannot really test it.

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

* [Bug target/115591] internal error on global variable-length array
  2024-06-22 13:23 [Bug ada/115591] New: ICE in riscv64-elf cross compiler, handling imported addresses simon at pushface dot org
  2024-06-23 10:38 ` [Bug target/115591] internal error on global variable-length array ebotcazou at gcc dot gnu.org
  2024-06-23 10:47 ` ebotcazou at gcc dot gnu.org
@ 2024-06-23 14:42 ` simon at pushface dot org
  2024-06-24 10:54 ` simon at pushface dot org
  2024-06-25  9:06 ` ebotcazou at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: simon at pushface dot org @ 2024-06-23 14:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115591

--- Comment #3 from simon at pushface dot org ---
On 23 Jun 2024, at 11:47, ebotcazou at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115591
> 
> --- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
> The immediate fix is:
> 
> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> index c17141d909a..5e34dc92210 100644
> --- a/gcc/config/riscv/riscv.cc
> +++ b/gcc/config/riscv/riscv.cc
> @@ -1702,7 +1702,9 @@ riscv_valid_lo_sum_p (enum riscv_symbol_type sym_type,
> machine_mode mode,
>       align = (SYMBOL_REF_DECL (x)
>               ? DECL_ALIGN (SYMBOL_REF_DECL (x))
>               : 1);
> -      size = (SYMBOL_REF_DECL (x) && DECL_SIZE (SYMBOL_REF_DECL (x))
> +      size = (SYMBOL_REF_DECL (x)
> +             && DECL_SIZE (SYMBOL_REF_DECL (x))
> +             && tree_fits_uhwi_p (DECL_SIZE (SYMBOL_REF_DECL (x)))
>              ? tree_to_uhwi (DECL_SIZE (SYMBOL_REF_DECL (x)))
>              : 2*BITS_PER_WORD);
>     }
> 
> but I cannot really test it.

Can I help with testing? (beyond applying the patch and checking that the error
is fixed)

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

* [Bug target/115591] internal error on global variable-length array
  2024-06-22 13:23 [Bug ada/115591] New: ICE in riscv64-elf cross compiler, handling imported addresses simon at pushface dot org
                   ` (2 preceding siblings ...)
  2024-06-23 14:42 ` simon at pushface dot org
@ 2024-06-24 10:54 ` simon at pushface dot org
  2024-06-25  9:06 ` ebotcazou at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: simon at pushface dot org @ 2024-06-24 10:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115591

--- Comment #4 from simon at pushface dot org ---
bug.adb compiles without error after applying the patch.

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

* [Bug target/115591] internal error on global variable-length array
  2024-06-22 13:23 [Bug ada/115591] New: ICE in riscv64-elf cross compiler, handling imported addresses simon at pushface dot org
                   ` (3 preceding siblings ...)
  2024-06-24 10:54 ` simon at pushface dot org
@ 2024-06-25  9:06 ` ebotcazou at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2024-06-25  9:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115591

--- Comment #5 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Jeff, this looks like an obvious fix given the comment just above the modified
code, but only a maintainer can probably assess that.

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

end of thread, other threads:[~2024-06-25  9:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-22 13:23 [Bug ada/115591] New: ICE in riscv64-elf cross compiler, handling imported addresses simon at pushface dot org
2024-06-23 10:38 ` [Bug target/115591] internal error on global variable-length array ebotcazou at gcc dot gnu.org
2024-06-23 10:47 ` ebotcazou at gcc dot gnu.org
2024-06-23 14:42 ` simon at pushface dot org
2024-06-24 10:54 ` simon at pushface dot org
2024-06-25  9:06 ` ebotcazou at gcc dot gnu.org

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).