Bug 60643 - ICE with -O1 and -g on mips (internal compiler error: in dwarf2out_var_location, at dwarf2out.c:20810)
Summary: ICE with -O1 and -g on mips (internal compiler error: in dwarf2out_var_locati...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-25 03:26 UTC by hongxu jia
Modified: 2014-12-02 09:24 UTC (History)
2 users (show)

See Also:
Host: x86_64-linux
Target: mips-wrs-linux
Build: x86_64-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments
the config.log of mips-poky-linux-gcc (7.71 KB, text/x-log)
2014-03-25 03:26 UTC, hongxu jia
Details
the open-embedded patches (49.35 KB, application/x-tar)
2014-03-25 05:32 UTC, hongxu jia
Details

Note You need to log in before you can comment on or make changes to this bug.
Description hongxu jia 2014-03-25 03:26:48 UTC
Created attachment 32440 [details]
the config.log of mips-poky-linux-gcc

I have hit a ICE and could reduce it to the following minimal example:

1. Only the size of array assigned with 2 caused the issue:
$ cat > mipgcc-test.c << END

#include <stdio.h>

#define ARRAY_SIZE_MAX  2

int main (int argc, char **argv)
{
        char *pStrArry[ARRAY_SIZE_MAX] = {"hello"};
        int i = 0;

        while(pStrArry[i] && i<ARRAY_SIZE_MAX)
        {
                printf("%s\n", pStrArry[i]);
                i++;
        }

        return 0;
}

END

2. Only -O1 and -g on mips caused the issue:
$ mips-poky-linux-gcc -O1 -g -o mipgcc-test mipgcc-test.c
mipgcc-test.c: In function 'main':
mipgcc-test.c:18:1: internal compiler error: in dwarf2out_var_location, at dwarf2out.c:20810
 }
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions
Comment 1 hongxu jia 2014-03-25 03:30:02 UTC
Build Configuration:
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Ubuntu-12.04"
TARGET_SYS        = "mips-wrs-linux"
Comment 2 Andrew Pinski 2014-03-25 04:34:46 UTC
Is this with or without the open-embedded patches?
Comment 3 Andrew Pinski 2014-03-25 04:39:14 UTC
It works for me in modified version of GCC 4.9.
Comment 4 hongxu jia 2014-03-25 05:32:43 UTC
Created attachment 32441 [details]
the open-embedded patches
Comment 5 Andrew Pinski 2014-03-25 05:51:26 UTC
Can you try without the OE patches first?
Comment 6 Andrew Pinski 2014-03-25 05:57:53 UTC
It works with an unmodified:
xgcc (GCC) 4.9.0 20140317 (experimental) [trunk revision 208625]

Compiled for mips64-linux-gnu and using -mabi=32.
Comment 7 Andrew Pinski 2014-03-25 05:58:25 UTC
Here is my configure line:
Configured with: /home/apinski/src/gcc-fsf/local//gcc/configure --prefix=/home/apinski/local-gcc-mips --target=mips64-linux-gnu --with-mips-plt --with-arch=octeon+ --with-float=soft --with-sysroot=/home/apinski/local-gcc-mips/mips64-linux/sys-root/
Comment 8 Andrew Pinski 2014-03-25 06:08:25 UTC
Works for me with an unmodified GCC 4.8.2.

So please try removing all of the Open-embedded patches since one of them is causing this bug.
Comment 9 Andrew Pinski 2014-03-25 06:09:04 UTC
Just for record:
apinski@apinskidesktop:~/src/gcc-fsf/gcc-4.8.2/objdir-mips/gcc$ ./xgcc -B.  t.c -I. -S -O -g -v
Using built-in specs.
COLLECT_GCC=./xgcc
Target: mips-wrs-linux
Configured with: ../configure --target=mips-wrs-linux --enable-threads=posix --disable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --enable-threads=posix --disable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --disable-silent-rules --disable-dependency-tracking --without-local-prefix --enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=sysv --enable-linker-build-id --with-ppl=no --with-cloog=no --without-local-prefix --enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=sysv --enable-linker-build-id --with-ppl=no --with-cloog=no --without-local-prefix --enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=sysv --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global
Thread model: posix
gcc version 4.8.2 (GCC) 
COLLECT_GCC_OPTIONS='-B' '.' '-I' '.' '-S' '-O' '-g' '-v' '-mllsc'
 ./cc1 -quiet -v -I . -iprefix /data1/src/gcc-fsf/gcc-4.8.2/objdir-mips/gcc/../lib/gcc/mips-wrs-linux/4.8.2/ t.c -quiet -dumpbase t.c -mllsc -auxbase t -g -O -version -o t.s
GNU C (GCC) version 4.8.2 (mips-wrs-linux)
	compiled by GNU C version 4.4.5, GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/data1/src/gcc-fsf/gcc-4.8.2/objdir-mips/gcc/../lib/gcc/mips-wrs-linux/4.8.2/include"
ignoring nonexistent directory "/data1/src/gcc-fsf/gcc-4.8.2/objdir-mips/gcc/../lib/gcc/mips-wrs-linux/4.8.2/include-fixed"
ignoring nonexistent directory "/data1/src/gcc-fsf/gcc-4.8.2/objdir-mips/gcc/../lib/gcc/mips-wrs-linux/4.8.2/../../../../mips-wrs-linux/sys-include"
ignoring nonexistent directory "/data1/src/gcc-fsf/gcc-4.8.2/objdir-mips/gcc/../lib/gcc/mips-wrs-linux/4.8.2/../../../../mips-wrs-linux/include"
ignoring nonexistent directory "/data1/src/gcc-fsf/gcc-4.8.2/objdir-mips/gcc/../lib/gcc/../../lib/gcc/mips-wrs-linux/4.8.2/include"
ignoring nonexistent directory "/data1/src/gcc-fsf/gcc-4.8.2/objdir-mips/gcc/../lib/gcc/../../lib/gcc/mips-wrs-linux/4.8.2/include-fixed"
ignoring nonexistent directory "/data1/src/gcc-fsf/gcc-4.8.2/objdir-mips/gcc/../lib/gcc/../../lib/gcc/mips-wrs-linux/4.8.2/../../../../mips-wrs-linux/sys-include"
ignoring nonexistent directory "/data1/src/gcc-fsf/gcc-4.8.2/objdir-mips/gcc/../lib/gcc/../../lib/gcc/mips-wrs-linux/4.8.2/../../../../mips-wrs-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 .
End of search list.
GNU C (GCC) version 4.8.2 (mips-wrs-linux)
	compiled by GNU C version 4.4.5, GMP version 4.3.2, MPFR version 3.0.0-p3, MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: c57da6ac9636c2e235f9cfdd31b2aa13
COMPILER_PATH=./
LIBRARY_PATH=./
COLLECT_GCC_OPTIONS='-B' '.' '-I' '.' '-S' '-O' '-g' '-v' '-mllsc'
Comment 10 hongxu jia 2014-03-25 08:00:06 UTC
(In reply to Andrew Pinski from comment #8)
> Works for me with an unmodified GCC 4.8.2.
> 
> So please try removing all of the Open-embedded patches since one of them is
> causing this bug.

I have removed all of the Open-embedded patches, and cross-compiling
mip-gcc on x86-64 host. But the problem still existed.

//Hongxu
Comment 11 hongxu jia 2014-03-25 08:00:57 UTC
For Record:

mips-poky-linux/gcc$ ./xgcc -B.  mipgcc-test.c -I. -S -O -g -v
Reading specs from ./specs
COLLECT_GCC=./xgcc
Target: mips-poky-linux
Configured with: /buildarea/hjia/build-20140321-qemumips-yocto/tmp/work-shared/gcc-4.8.2-r0/gcc-4.8.2/configure --build=x86_64-linux --host=x86_64-linux --target=mips-poky-linux --prefix=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr --exec_prefix=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr --bindir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr/bin/mips32-poky-linux --sbindir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr/bin/mips32-poky-linux --libexecdir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr/libexec/mips32-poky-linux --datadir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr/share --sysconfdir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/etc --sharedstatedir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/com --localstatedir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/var --libdir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr/lib/mips32-poky-linux --includedir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr/include --oldincludedir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr/include --infodir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr/share/info --mandir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux --enable-clocale=generic --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --disable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=mips-poky-linux- --without-local-prefix --enable-target-optspace --enable-lto --enable-libssp --disable-bootstrap --disable-libmudflap --with-system-zlib --with-linker-hash-style=sysv --enable-linker-build-id --with-ppl=no --with-cloog=no --enable-checking=release --enable-cheaders=c_global --with-gxx-include-dir=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/qemumips/usr/include/c++ --with-sysroot=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/qemumips --with-build-sysroot=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/qemumips --enable-targets=all --enable-poison-system-directories --disable-libunwind-exceptions --with-mpfr=/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/x86_64-linux/usr --with-system-zlib --disable-nls --enable-__cxa_atexit
Thread model: posix
gcc version 4.8.2 (GCC) 
COLLECT_GCC_OPTIONS='-B' '.' '-I' '.' '-S' '-O' '-g' '-v' '-mllsc' '-mno-shared' '-EB' '-mabi=32'
 ./cc1 -quiet -v -I . -iprefix /buildarea/hjia/build-20140321-qemumips-yocto/tmp/work/mips32-poky-linux/gcc-cross/4.8.2-r0/gcc-4.8.2/build.x86_64-linux.mips-poky-linux/gcc/../../lib/mips32-poky-linux/gcc/mips-poky-linux/4.8.2/ -isystem ./include -isystem ./include-fixed mipgcc-test.c -meb -quiet -dumpbase mipgcc-test.c -mllsc -mno-shared -mabi=32 -auxbase mipgcc-test -g -O -version -o mipgcc-test.s
GNU C (GCC) version 4.8.2 (mips-poky-linux)
	compiled by GNU C version 4.6.3, GMP version 5.1.1, MPFR version 3.1.2, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/buildarea/hjia/build-20140321-qemumips-yocto/tmp/work/mips32-poky-linux/gcc-cross/4.8.2-r0/gcc-4.8.2/build.x86_64-linux.mips-poky-linux/gcc/../../lib/mips32-poky-linux/gcc/mips-poky-linux/4.8.2/include"
ignoring nonexistent directory "/buildarea/hjia/build-20140321-qemumips-yocto/tmp/work/mips32-poky-linux/gcc-cross/4.8.2-r0/gcc-4.8.2/build.x86_64-linux.mips-poky-linux/gcc/../../lib/mips32-poky-linux/gcc/mips-poky-linux/4.8.2/include-fixed"
ignoring nonexistent directory "/buildarea/hjia/build-20140321-qemumips-yocto/tmp/work/mips32-poky-linux/gcc-cross/4.8.2-r0/gcc-4.8.2/build.x86_64-linux.mips-poky-linux/gcc/../../lib/mips32-poky-linux/gcc/mips-poky-linux/4.8.2/../../../../../mips-poky-linux/include"
ignoring nonexistent directory "/buildarea/hjia/build-20140321-qemumips-yocto/tmp/work/mips32-poky-linux/gcc-cross/4.8.2-r0/gcc-4.8.2/build.x86_64-linux.mips-poky-linux/gcc/../../lib/mips32-poky-linux/gcc/../../../lib/mips32-poky-linux/gcc/mips-poky-linux/4.8.2/include"
ignoring nonexistent directory "/buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/qemumips/usr/local/include"
ignoring nonexistent directory "/buildarea/hjia/build-20140321-qemumips-yocto/tmp/work/mips32-poky-linux/gcc-cross/4.8.2-r0/gcc-4.8.2/build.x86_64-linux.mips-poky-linux/gcc/../../lib/mips32-poky-linux/gcc/../../../lib/mips32-poky-linux/gcc/mips-poky-linux/4.8.2/include-fixed"
ignoring nonexistent directory "/buildarea/hjia/build-20140321-qemumips-yocto/tmp/work/mips32-poky-linux/gcc-cross/4.8.2-r0/gcc-4.8.2/build.x86_64-linux.mips-poky-linux/gcc/../../lib/mips32-poky-linux/gcc/../../../lib/mips32-poky-linux/gcc/mips-poky-linux/4.8.2/../../../../../mips-poky-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 .
 ./include
 ./include-fixed
 /buildarea/hjia/build-20140321-qemumips-yocto/tmp/sysroots/qemumips/usr/include
End of search list.
GNU C (GCC) version 4.8.2 (mips-poky-linux)
	compiled by GNU C version 4.6.3, GMP version 5.1.1, MPFR version 3.1.2, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 64005b8c8a5d8be3a34f740be1b8b914
mipgcc-test.c: In function 'main':
mipgcc-test.c:18:1: internal compiler error: in dwarf2out_var_location, at dwarf2out.c:20810
 }
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

//Hongxu
Comment 12 Khem Raj 2014-10-05 07:56:47 UTC
I would like to reopen this bug. As there is more information to explain this issue. This issue will happen if you first build cross binutils and add the installation path to PATH variable and then configure gcc to cross build for mips. All you need is cross assembler available in PATH when configuring gcc.

If gcc configure script does not find assembler then many probes fail and it gets configured differently. 

I could see that when cross assembler is not in path then the resulting gcc is able to compile the sample program however when assembler is in PATH then the issue starts to show up.

I am not sure how Andrew built his toolchain but it seems he is not adding binutils to the path before configuring cross gcc.

Steps.

configure and install cross binutils ( especially assembler )
Add the install path to PATH variable
configure and compile cross gcc
Try out the example ( it will cause the ICE as explained)

btw it happens with gcc 4.8 as well as 4.9 in same fashion and I have verified that OE patches don't make any difference here. I could see it happen on latest FSF 4.9 branch


see below is the diff between gcc/config.log between two cases explained above

-gcc_cv_as=''
+gcc_cv_as='/home/ubuntu/work/dizzy/build-pacexi3v2/tmp/sysroots/x86_64-linux/usr/bin/mipsel-rdk-linux/mipsel-rdk-linux-as'
 gcc_cv_ld=''
 gcc_cv_nm=''
 gcc_cv_objdump=''
@@ -6067,7 +6205,7 @@
 target='mipsel-rdk-linux-gnu'
 target_alias='mipsel-rdk-linux'
 target_cpu='mipsel'
-target_cpu_default='MASK_SPLIT_ADDRESSES'
+target_cpu_default='(MASK_SPLIT_ADDRESSES)|MASK_EXPLICIT_RELOCS'
 target_noncanonical='mipsel-rdk-linux'
 target_os='linux-gnu'
 target_subdir='mipsel-rdk-linux'
@@ -6278,13 +6416,31 @@
 #define HAVE_DLFCN_H 1
 #define LT_OBJDIR ".libs/"
 #define PLUGIN_LD_SUFFIX ""
+#define HAVE_GAS_BALIGN_AND_P2ALIGN 1
+#define HAVE_GAS_MAX_SKIP_P2ALIGN 1
+#define HAVE_GAS_WEAK 1
+#define HAVE_GAS_WEAKREF 1
 #define HAVE_GNU_INDIRECT_FUNCTION 0
+#define HAVE_AS_LEB128 1
 #define HAVE_GAS_CFI_DIRECTIVE 0
-#define HAVE_GAS_CFI_PERSONALITY_DIRECTIVE 0
-#define HAVE_GAS_CFI_SECTIONS_DIRECTIVE 0
-#define HAVE_GAS_SHF_MERGE 0
+#define HAVE_GAS_CFI_PERSONALITY_DIRECTIVE 1
+#define HAVE_GAS_CFI_SECTIONS_DIRECTIVE 1
+#define USE_AS_TRADITIONAL_FORMAT 1
+#define HAVE_GAS_SHF_MERGE 1
 #define HAVE_COMDAT_GROUP 0
+#define HAVE_GAS_DISCRIMINATOR 1
+#define HAVE_AS_TLS 1
 #define HAVE_LTO_PLUGIN 0
+#define HAVE_AS_NO_SHARED 1
+#define HAVE_AS_GNU_ATTRIBUTE 1
+#define HAVE_GAS_MICROMIPS 1
+#define HAVE_AS_DTPRELWORD 1
+#define HAVE_AS_DSPR1_MULT 1
+#define HAVE_AS_NAN 1
+#define HAVE_AS_GDWARF2_DEBUG_FLAG 1
+#define HAVE_AS_GSTABS_DEBUG_FLAG 1
+#define HAVE_AS_DEBUG_PREFIX_MAP 1
+#define HAVE_AS_LINE_ZERO 1
 #define HAVE_LD_EH_FRAME_CIEV3 0
 #define ENABLE_LTO 1
Comment 13 hongxu jia 2014-12-02 02:25:27 UTC
Khem Raj gave more details, so I reopen it (but without that option, choose unconfirmed to instead)
Comment 15 hongxu jia 2014-12-02 09:24:31 UTC
I have done the test, the defect has fixed

//Hongxu