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

            Bug ID: 91702
           Summary: ICE with mips16
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: g...@hauke-m.de
  Target Milestone: ---

I am getting the following internal compiler error when building json-c-0.13.1
with GCC 9.2 for MIPS big endian with mip16 support.

--------
$ make V=s
make  all-recursive
make[1]: Entering directory '/home/hauke/openwrt/dl/tmp/json-c-0.13.1'
Making all in .
make[2]: Entering directory '/home/hauke/openwrt/dl/tmp/json-c-0.13.1'
/bin/sh ./libtool  --tag=CC   --mode=compile mips-openwrt-linux-gcc
-DHAVE_CONFIG_H -I.     -mips16  -Wall -Werror -Wcast-qual
-Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -D_GNU_SOURCE
-D_REENTRANT -MT json_object.lo -MD -MP -MF .deps/json_object.Tpo -c -o
json_object.lo json_object.c
libtool: compile:  mips-openwrt-linux-gcc -DHAVE_CONFIG_H -I. -mips16 -Wall
-Werror -Wcast-qual -Wno-error=deprecated-declarations -Wextra
-Wno-unused-parameter -D_GNU_SOURCE -D_REENTRANT -MT json_object.lo -MD -MP -MF
.deps/json_object.Tpo -c json_object.c  -fPIC -DPIC -o .libs/json_object.o
during RTL pass: mach
json_object.c: In function 'json_object_int_inc':
json_object.c:735:1: internal compiler error: Segmentation fault
  735 | }
      | ^
0xa1397f crash_signal
       
/home/hauke/openwrt/openwrt/build_dir/toolchain-mips_24kc_gcc-9.2.0_musl/gcc-9.2.0/gcc/toplev.c:326
0xcd428e mips_split_move(rtx_def*, rtx_def*, mips_split_type, rtx_def*)
       
/home/hauke/openwrt/openwrt/build_dir/toolchain-mips_24kc_gcc-9.2.0_musl/gcc-9.2.0/gcc/config/mips/mips.c:4871
0xe9cc20 gen_split_59(rtx_insn*, rtx_def**)
       
/home/hauke/openwrt/openwrt/build_dir/toolchain-mips_24kc_gcc-9.2.0_musl/gcc-9.2.0/gcc/config/mips/mips.md:5248
0xeec295 split_3
       
/home/hauke/openwrt/openwrt/build_dir/toolchain-mips_24kc_gcc-9.2.0_musl/gcc-9.2.0/gcc/config/mips/mips.md:5246
0xeec295 split_insns(rtx_def*, rtx_insn*)
       
/home/hauke/openwrt/openwrt/build_dir/toolchain-mips_24kc_gcc-9.2.0_musl/gcc-9.2.0/gcc/config/mips/mips.md:7019
0x72b189 try_split(rtx_def*, rtx_insn*, int)
       
/home/hauke/openwrt/openwrt/build_dir/toolchain-mips_24kc_gcc-9.2.0_musl/gcc-9.2.0/gcc/emit-rtl.c:3851
0x9843d1 split_insn
       
/home/hauke/openwrt/openwrt/build_dir/toolchain-mips_24kc_gcc-9.2.0_musl/gcc-9.2.0/gcc/recog.c:2901
0x988f67 split_all_insns_noflow()
       
/home/hauke/openwrt/openwrt/build_dir/toolchain-mips_24kc_gcc-9.2.0_musl/gcc-9.2.0/gcc/recog.c:3063
0xccb594 mips16_lay_out_constants
       
/home/hauke/openwrt/openwrt/build_dir/toolchain-mips_24kc_gcc-9.2.0_musl/gcc-9.2.0/gcc/config/mips/mips.c:17505
0xcd1765 mips_reorg
       
/home/hauke/openwrt/openwrt/build_dir/toolchain-mips_24kc_gcc-9.2.0_musl/gcc-9.2.0/gcc/config/mips/mips.c:19380
0x9b1789 execute
       
/home/hauke/openwrt/openwrt/build_dir/toolchain-mips_24kc_gcc-9.2.0_musl/gcc-9.2.0/gcc/reorg.c:3992
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://bugs.openwrt.org/> for instructions.
make[2]: *** [Makefile:587: json_object.lo] Error 1
make[2]: Leaving directory '/home/hauke/openwrt/dl/tmp/json-c-0.13.1'
make[1]: *** [Makefile:651: all-recursive] Error 1
make[1]: Leaving directory '/home/hauke/openwrt/dl/tmp/json-c-0.13.1'
make: *** [Makefile:448: all] Error 2
---------

The problem is happening in this code part:
https://github.com/json-c/json-c/blob/json-c-0.13.1-20180305/json_object.c#L735

I can reproduce it by using configure with these commands:
CFLAGS="-mips16 " ./configure --target=mips-openwrt-linux
--host=mips-openwrt-linux --build=x86_64-pc-linux-gnu

and then run make

When I remove the -mips16 option from CFLAGS it compiles without an ICE.

I am using GCC 9.2.0 from OpenWrt master as of today with the following patches
applied:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=tree;f=toolchain/gcc/patches/9.2.0;h=81caffc170b7604a685785db350fa5b5e72baf63;hb=HEAD

This was freshly compiled on a Arch Linux system which also uses GCC 9.2.0 as
system compiler.
OpenWrt uses binutils 2.32

I haven't seen this problem with GCC 7.4.0 and GCC 8.3.0, I am also not aware
of any such bug report in OpenWrt.

This is the OpenWrt configuration to reproduce this problem:
------------------
[hauke@hauke-arch openwrt]$ ./scripts/diffconfig.sh 
CONFIG_TARGET_lantiq=y
CONFIG_TARGET_lantiq_xrx200=y
CONFIG_TARGET_lantiq_xrx200_Default=y
CONFIG_DEVEL=y
CONFIG_TOOLCHAINOPTS=y
# CONFIG_BINUTILS_USE_VERSION_2_31_1 is not set
CONFIG_BINUTILS_USE_VERSION_2_32=y
CONFIG_BINUTILS_VERSION="2.32"
CONFIG_BINUTILS_VERSION_2_32=y
CONFIG_GCC_USE_EMBEDDED_PATH_REMAP=y
# CONFIG_GCC_USE_VERSION_7 is not set
CONFIG_GCC_USE_VERSION_9=y
CONFIG_GCC_VERSION="9.2.0"
CONFIG_GCC_VERSION_9=y
--------------------------

This was initially reported here:
https://bugs.openwrt.org/index.php?do=details&task_id=2455

Reply via email to