uClibc-0.9.29 compilation failed when trying to build with gcc-4.2.2 with the following error: ---- CUT HERE ---- sh4-linux-uclibc-gcc -c ldso/ldso/ldso.c -o ldso/ldso/ldso.oS -include ./include/libc-symbols.h -Wall -Wstrict-prototypes -fno-strict-aliasing -Os -pipe -funit-at-a-time -fhonour-copts -fno-stack-protector -fno-builtin -nostdinc -I./include -I. -std=gnu99 -Os -funit-at-a-time -fno-tree-loop-optimize -fno-tree-dominator-opts -fno-strength-reduce -fstrict-aliasing -mprefergot -I./libpthread/linuxthreads.old/sysdeps/unix/sysv/linux/sh -I./libpthread/linuxthreads.old/sysdeps/sh -I./libpthread/linuxthreads.old/sysdeps/unix/sysv/linux -I./libpthread/linuxthreads.old/sysdeps/pthread -I./libpthread/linuxthreads.old -I./libpthread -I/store/sh4_3/trunk/build_dir/toolchain-sh4_gcc4.2.2/linux/include/ -isystem /store/sh4_3/trunk/staging_dir/toolchain-sh4_gcc4.2.2/lib/gcc/sh4-linux-uclibc/4.2.2/include -DNDEBUG -fPIC -DSHARED -DNOT_IN_libc -DIS_IN_rtld -fno-stack-protector -fno-omit-frame-pointer -I./ldso/ldso/sh -I./ldso/include -I./ldso/ldso -DUCLIBC_RUNTIME_PREFIX="/" -DUCLIBC_LDSO="ld-uClibc.so.0" -DLDSO_ELFINTERP="sh/elfinterp.c" In file included from ./libpthread/linuxthreads.old/sysdeps/sh/tls.h:23, from ./include/bits/uClibc_errno.h:35, from ./include/errno.h:62, from ./include/bits/syscalls.h:16, from ./include/sys/syscall.h:34, from ./ldso/ldso/sh/dl-syscalls.h:3, from ./ldso/include/dl-syscall.h:12, from ./ldso/include/ldso.h:36, from ldso/ldso/ldso.c:33: ./libpthread/linuxthreads.old/sysdeps/sh/pt-machine.h:36: warning: C99 inline functions are not supported; using GNU89 ./libpthread/linuxthreads.old/sysdeps/sh/pt-machine.h:36: warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute ldso/ldso/dl-elf.c: In function '_dl_dprintf': ldso/ldso/dl-elf.c:803: error: unable to find a register to spill in class 'R0_REGS' ldso/ldso/dl-elf.c:803: error: this is the insn: (insn 884 885 23 3 (set (reg/f:SI 1 r1 [221]) (mem/u/c:SI (plus:SI (reg:SI 12 r12) (reg/f:SI 1 r1 [222])) [0 S4 A32])) 171 {movsi_ie} (nil) (expr_list:REG_DEAD (reg/f:SI 1 r1 [222]) (expr_list:REG_EQUIV (symbol_ref:SI ("_dl_pagesize") <var_decl 0x2aaaab0d40b0 _dl_pagesize>) (nil)))) ldso/ldso/dl-elf.c:803: confused by earlier errors, bailing out ---- CUT HERE ---- uClibc developers pointed me here saying this is a known bug for the gcc-4.x line, I was able to reproduce this bug on gcc-4.1.2 also. GCC compilation options: Configured with: /store/sh4_3/trunk/build_dir/toolchain-sh4_gcc4.2.2/gcc-4.2.2/configure --prefix=/store/sh4_3/trunk/staging_dir/toolchain-sh4_gcc4.2.2 --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=sh4-linux-uclibc --enable-languages=c --disable-shared --with-sysroot=/store/sh4_3/trunk/build_dir/toolchain-sh4_gcc4.2.2/uClibc_dev/ --disable-__cxa_atexit --enable-target-optspace --with-gnu-ld --disable-nls --disable-libmudflap --disable-multilib
I suppose ldso/ldso/dl-elf.c:803 is an asm() statement. How does it look like? Can you attach preprocessed source?
Created attachment 14941 [details] Preprocessed source of ldso.c
(In reply to comment #1) > I suppose ldso/ldso/dl-elf.c:803 is an asm() statement. How does it look like? > Can you attach preprocessed source? > No, dl-elf.c:803 is the closing of _dl_dprintf, preprocessed source as required with -save-temps attached.
*** Bug 34807 has been marked as a duplicate of this bug. ***
Created attachment 14973 [details] reduced testcase I think Richard's comment is the case. Here is a reduced testcase. The PIC memory access on SH4 makes register pressure on R0 high and sometimes can't use with asm register statement using R0. It seems that there is no easy way to fix this issue. Currently, it's a limitation of asm extensions on this target. In the above testcase, the error will go away with adding -fno-schedule-insns option, but the more complex cases like PR 34807 will fail even with that option. You could avoid this problem completely with isolating PIC accesses and asm statements. For example, if the above reduced testcase is changed so to use noinline attribute, that program static __attribute__ ((__noinline__)) void * _dl_mmap (void * start, int length, int prot, int flags, int fd, int offset) { register long __sc3 __asm__ ("r3") = 90; register long __sc4 __asm__ ("r4") = (long) start; register long __sc5 __asm__ ("r5") = (long) length; register long __sc6 __asm__ ("r6") = (long) prot; register long __sc7 __asm__ ("r7") = (long) flags; register long __sc0 __asm__ ("r0") = (long) fd; register long __sc1 __asm__ ("r1") = (long) offset; __asm__ __volatile__ ("trapa %1" : "=z" (__sc0) : "i" (0x10 + 6), "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), "r" (__sc3), "r" (__sc1) : "memory" ); } extern int _dl_pagesize; void _dl_dprintf(int fd, const char *fmt, ...) { static char *buf; buf = _dl_mmap ((void *) 0, _dl_pagesize, 0x1 | 0x2, 0x02 | 0x20, -1, 0); } will never hit this problem.
(In reply to comment #5) > Created attachment 14973 [details] > reduced testcase > I have tried to reproduce the ICE with the reduced testcase on rev 191865 with the following options: -x c -m4 -mb -fschedule-insns -fPIC -mprefergot -x c -m4 -ml -fschedule-insns -fPIC -mprefergot and optimization levels -O0 -O1 -O2 -O3 -Os -Og. It seems the problem does not happen anymore.
Author: olegendo Date: Mon Oct 15 21:59:21 2012 New Revision: 192478 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=192478 Log: PR target/34777 * gcc.target/sh/torture/sh-torture.exp: New. * gcc.target/sh/torture/pr34777.c: New. Added: trunk/gcc/testsuite/gcc.target/sh/torture/ trunk/gcc/testsuite/gcc.target/sh/torture/pr34777.c trunk/gcc/testsuite/gcc.target/sh/torture/sh-torture.exp Modified: trunk/gcc/testsuite/ChangeLog
Since this doesn't seem to be an issue on current trunk (4.8), can we close this PR?
(In reply to comment #8) > Since this doesn't seem to be an issue on current trunk (4.8), can we close > this PR? The test case in PR 34807 which is marked as a duplicate of this PR still ICEs on trunk in the similar way.
(In reply to comment #9) > (In reply to comment #8) > > Since this doesn't seem to be an issue on current trunk (4.8), can we close > > this PR? > > The test case in PR 34807 which is marked as a duplicate of this PR > still ICEs on trunk in the similar way. Oh, I see. I'm not sure, could it be related to the (still existing) problem with some of the atomic patterns (which clobber R0), as described here http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50751#c28 ?
The following... Index: gcc/config/sh/sh.c =================================================================== --- gcc/config/sh/sh.c (revision 192482) +++ gcc/config/sh/sh.c (working copy) @@ -10527,6 +10527,15 @@ } } + if (GET_CODE (*p) == PLUS && REG_P (XEXP (*p, 0)) && REG_P (XEXP (*p, 1)) + && REGNO (XEXP (*p, 0)) != R0_REG) + { + *p = gen_rtx_PLUS (Pmode, XEXP (*p, 0), XEXP (*p, 1)); + push_reload (*p, NULL_RTX, p, NULL, BASE_REG_CLASS, Pmode, VOIDmode, 0, 0, + opnum, type); + return true; + } + /* We must re-recognize what we created before. */ if (GET_CODE (*p) == PLUS && (mode_sz == 4 || mode_sz == 8) seems to fix the test case of PR 34807. However, I've not tested it any further and probably the fix is incomplete and works only for mem loads and not stores. In fact it can be broken again quite easily by inserting another insn that requires R0 (tst #imm,r0 in this case): int glob, glob1; static int _dl_mmap (int xx) { register int __sc0 __asm__ ("r0") = glob1; register int __sc1 __asm__ ("r1") = glob; if (xx & 3) __asm__ ("trapa %1 " : "=z" (__sc0) : "i" (0x10), "0" (__sc0), "r" (__sc1)); return (__sc0); } void _start(int xx) { static int buf; buf = _dl_mmap(xx); }
(In reply to Oleg Endo from comment #11) > > seems to fix the test case of PR 34807. However, I've not tested it any > further and probably the fix is incomplete and works only for mem loads and > not stores. > In fact it can be broken again quite easily by inserting another insn that > requires R0 (tst #imm,r0 in this case): > > int glob, glob1; > > static int _dl_mmap (int xx) > { > register int __sc0 __asm__ ("r0") = glob1; > register int __sc1 __asm__ ("r1") = glob; > > if (xx & 3) > __asm__ ("trapa %1 " : "=z" (__sc0) : "i" (0x10), "0" (__sc0), "r" > (__sc1)); > > return (__sc0); > } > > void _start(int xx) > { > static int buf; > buf = _dl_mmap(xx); > } I've tried that test case with the sh-lra branch and the problems seem to be gone.
(In reply to Oleg Endo from comment #12) > (In reply to Oleg Endo from comment #11) > > > > seems to fix the test case of PR 34807. However, I've not tested it any > > further and probably the fix is incomplete and works only for mem loads and > > not stores. > > In fact it can be broken again quite easily by inserting another insn that > > requires R0 (tst #imm,r0 in this case): > > > > int glob, glob1; > > > > static int _dl_mmap (int xx) > > { > > register int __sc0 __asm__ ("r0") = glob1; > > register int __sc1 __asm__ ("r1") = glob; > > > > if (xx & 3) > > __asm__ ("trapa %1 " : "=z" (__sc0) : "i" (0x10), "0" (__sc0), "r" > > (__sc1)); > > > > return (__sc0); > > } > > > > void _start(int xx) > > { > > static int buf; > > buf = _dl_mmap(xx); > > } > > I've tried that test case with the sh-lra branch and the problems seem to be > gone. So is this FIXED yet then?
(In reply to Eric Gallager from comment #13) > > > > I've tried that test case with the sh-lra branch and the problems seem to be > > gone. > > So is this FIXED yet then? LRA is not enabled by default on SH, so I'd say no, not fixed yet. Please leave open.
(In reply to Oleg Endo from comment #14) > (In reply to Eric Gallager from comment #13) > > > > > > I've tried that test case with the sh-lra branch and the problems seem to be > > > gone. > > > > So is this FIXED yet then? > > LRA is not enabled by default on SH, so I'd say no, not fixed yet. Please > leave open. OK, please remember to come back to this if/when LRA is ever the default on SH then.