Bug 60111 - [SH] ICE compiling Newlib
Summary: [SH] ICE compiling Newlib
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-07 21:25 UTC by Lawrence Sebald
Modified: 2014-11-22 04:54 UTC (History)
0 users

See Also:
Host: armv6l-unknown-linux-gnueabihf
Target: sh-elf
Build:
Known to work: 4.7.3
Known to fail: 4.8.2
Last reconfirmed:


Attachments
Preprocessed source file exhibiting the ICE. (4.42 KB, text/plain)
2014-02-07 21:25 UTC, Lawrence Sebald
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lawrence Sebald 2014-02-07 21:25:33 UTC
Created attachment 32081 [details]
Preprocessed source file exhibiting the ICE.

When building a cross-compiler from armv6l-unknown-linux-gnueabihf (A Raspberry Pi running Raspbian) to sh-elf, I'm running into an internal compiler error when compiling part of Newlib. Here is the backtrace that is generated:

sh-elf-gcc -B/mnt/usbhdd1/toolchain/kos/utils/dc-chain/build-newlib-sh-elf-2.0.0/sh-elf/m4-nofpu/newlib/ -isystem /mnt/usbhdd1/toolchain/kos/utils/dc-chain/build-newlib-sh-elf-2.0.0/sh-elf/m4-nofpu/newlib/targ-include -isystem /mnt/usbhdd1/toolchain/kos/utils/dc-chain/newlib-2.0.0/newlib/libc/include -B/mnt/usbhdd1/toolchain/kos/utils/dc-chain/build-newlib-sh-elf-2.0.0/sh-elf/m4-nofpu/libgloss/sh -L/mnt/usbhdd1/toolchain/kos/utils/dc-chain/build-newlib-sh-elf-2.0.0/sh-elf/m4-nofpu/libgloss/libnosys -L/mnt/usbhdd1/toolchain/kos/utils/dc-chain/newlib-2.0.0/libgloss/sh  -m4-nofpu -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"2.0.0\" -DPACKAGE_STRING=\"newlib\ 2.0.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I. -I../../../../../../newlib-2.0.0/newlib/libc/stdlib -DREENTRANT_SYSCALLS_PROVIDED -DMALLOC_PROVIDED -DABORT_PROVIDED -DHAVE_FCNTL -ffunction-sections -fdata-sections -fno-builtin      -g -O2  -m4-nofpu -c -o lib_a-lrand48.o `test -f 'lrand48.c' || echo '../../../../../../newlib-2.0.0/newlib/libc/stdlib/'`lrand48.c
../../../../../../newlib-2.0.0/newlib/libc/stdlib/lrand48.c: In function ‘_lrand48_r’:
../../../../../../newlib-2.0.0/newlib/libc/stdlib/lrand48.c:24:1: internal compiler error: in gen_ashift, at config/sh/sh.c:3746
 }
 ^
0x5a33db gen_ashift
	../../gcc-4.8.2/gcc/config/sh/sh.c:3746
0x5a358f gen_shifty_hi_op(int, rtx_def**)
	../../gcc-4.8.2/gcc/config/sh/sh.c:3874
0x5a87ff gen_shl_and(rtx_def*, rtx_def*, rtx_def*, rtx_def*)
	../../gcc-4.8.2/gcc/config/sh/sh.c:4185
0x5f105f gen_split_912(rtx_def*, rtx_def**)
	../../gcc-4.8.2/gcc/config/sh/sh.md:5173
0x222a6f try_split(rtx_def*, rtx_def*, int)
	../../gcc-4.8.2/gcc/emit-rtl.c:3562
0x382b47 split_insn
	../../gcc-4.8.2/gcc/recog.c:2836
0x38709f split_all_insns()
	../../gcc-4.8.2/gcc/recog.c:2926
0x38715b rest_of_handle_split_after_reload
	../../gcc-4.8.2/gcc/recog.c:3832
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

I have tried with both GCC versions available on the host OS' package manager (Debian 4.6.3-14+rpi1, and Debian 4.7.2-5+rpi1) and have the same ICE with both of them. This may actually be a host-related bug, rather than a target-related bug, as the ICE does not occur when building a cross-compiler on Darwin on x86-64.

Preprocessed source code of the file exhibiting the ICE is attached.
Comment 1 Oleg Endo 2014-02-08 20:07:27 UTC
Interesting.  Maybe PR 59375 is related somehow.
Comment 2 Oleg Endo 2014-03-01 14:56:44 UTC
In gen_ashift the assert
    gcc_assert (satisfies_constraint_P27 (n_rtx));

fires, which means that the requested shift amount is not 1, 2, 8 or 16.

In gen_shifty_hi_op the function gen_ashift is invoked with the shift amount values taken from the ext_ashl_lshr_seq table, which contains the allowed shift amounts only.
I don't see a problem in sh.c.  Maybe it's a indeed a problem of the host compiler.
Comment 3 Segher Boessenkool 2014-11-20 16:03:48 UTC
Author: segher
Date: Thu Nov 20 16:03:16 2014
New Revision: 217883

URL: https://gcc.gnu.org/viewcvs?rev=217883&root=gcc&view=rev
Log:
2014-11-20  Segher Boessenkool  <segher@kernel.crashing.org>

	PR target/60111
	* config/sh/sh.c: Use signed char for signed field.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/sh/sh.c
Comment 4 Oleg Endo 2014-11-22 04:46:18 UTC
Author: olegendo
Date: Sat Nov 22 04:45:46 2014
New Revision: 217958

URL: https://gcc.gnu.org/viewcvs?rev=217958&root=gcc&view=rev
Log:
gcc/
	Backport from mainline
	2014-11-20  Segher Boessenkool  <segher@kernel.crashing.org>

	PR target/60111
	* config/sh/sh.c: Use signed char for signed field.

Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/config/sh/sh.c
Comment 5 Oleg Endo 2014-11-22 04:53:18 UTC
Author: olegendo
Date: Sat Nov 22 04:52:46 2014
New Revision: 217959

URL: https://gcc.gnu.org/viewcvs?rev=217959&root=gcc&view=rev
Log:
gcc/
	Backport from mainline
	2014-11-20  Segher Boessenkool  <segher@kernel.crashing.org>

	PR target/60111
	* config/sh/sh.c: Use signed char for signed field.

Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/config/sh/sh.c
Comment 6 Oleg Endo 2014-11-22 04:54:57 UTC
Fixed on trunk, 4.9 and 4.8.