The latest compiler build from CVS sources on 07-28-2005 segfaults while building libgcc for arm-softfloat target with -O2,O2,Os opt levels. The error does not happen when -O1 is used The program compiles fine when I use my host compiler which is gcc version 4.0.1 20050727 (Red Hat 4.0.1-5) error log ================================ __do_global_ctors_aux Analyzing compilation unitPerforming intraprocedural optimizations Assembling functions: __do_global_ctors_aux /home/kraj/a.c: In function '__do_global_ctors_aux': /home/kraj/a.c:8: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. ==================================== How to reporoduce gcc -O2 -c testcase.c testcase.c ==================================== typedef void (*func_ptr) (void); static func_ptr __CTOR_END__[1] = {(func_ptr) 0 }; static void __attribute__((used)) __do_global_ctors_aux (void) { func_ptr *p; for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--) (*p) (); } =======================================================
Confirmed, backtrace: #0 0x007f7a4c in add_branch_dependences (head=0x1e918f0, tail=0x1e918f0) at ../../gcc/sched- rgn.c:1987 #1 0x007f818c in compute_block_backward_dependences (bb=0) at ../../gcc/sched-rgn.c:2142 #2 0x007f8a80 in schedule_region (rgn=3) at ../../gcc/sched-rgn.c:2290 #3 0x007f9828 in schedule_insns (dump_file=0x0) at ../../gcc/sched-rgn.c:2547 #4 0x007f9e14 in rest_of_handle_sched2 () at ../../gcc/sched-rgn.c:2700 #5 0x0063bbd0 in execute_one_pass (pass=0x8a4e94) at ../../gcc/passes.c:793 This is an RTL optimization bug.
This seems to have been caused by some checkin that went in after 7/27/2005 (i.e only checkins that went in today 7/28) because when I cvs up -D 2005-07-27 I dont get the segfault.
(In reply to comment #2) > This seems to have been caused by some checkin that went in after 7/27/2005 (i.e > only checkins that went in today 7/28) because when I cvs up -D 2005-07-27 I > dont get the segfault. Amends, To narrow it further the problem is caused by some checkin that happened on 7/27 because upto 0:00 hours it builds ok but not cvs up -D "2005-07-27 23:59"
Did the build which worked include the fix for PR rtl-optimization/17808? You can find out by looking at ChangeLog.
Try this, like Richard Earnshaw is doing. Index: sched-rgn.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/sched-rgn.c,v retrieving revision 1.99 diff -u -p -r1.99 sched-rgn.c --- sched-rgn.c 27 Jul 2005 16:28:34 -0000 1.99 +++ sched-rgn.c 28 Jul 2005 23:31:29 -0000 @@ -1977,17 +1977,17 @@ add_branch_dependences (rtx head, rtx ta if (!reload_completed || ! JUMP_P (tail)) return; - insn = PREV_INSN (tail); + insn = tail; while (insn != head) { + insn = PREV_INSN (insn); + /* Note that we want to add this dependency even when sched_insns_conditions_mutex_p returns true. The whole point is that we _want_ this dependency, even if these insns really are independent. */ if (INSN_P (insn) && GET_CODE (PATTERN (insn)) == COND_EXEC) add_dependence (tail, insn, REG_DEP_ANTI); - - insn = PREV_INSN (insn); } #endif }
The problem indeed was caused by checkin for PR rtl-optimization/17808. I verified it. Then I tried the Steven's fix above and I was able to build the GCC and rest of toolchain. I havent tested the compiler.
Subject: Bug 23117 CVSROOT: /cvs/gcc Module name: gcc Changes by: rearnsha@gcc.gnu.org 2005-07-29 09:32:16 Modified files: gcc : ChangeLog sched-rgn.c Log message: Richard Earnshaw <richard.earnshaw@arm.com> Steven Bosscher <stevenb@suse.de> PR rtl-optimization/23117 * sched-rgn.c (add_branch_dependences): Handle COND_EXEC correctly when head == tail. Tidy comment. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9597&r2=2.9598 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/sched-rgn.c.diff?cvsroot=gcc&r1=1.99&r2=1.100
Fixed with suggested patch.
*** Bug 23136 has been marked as a duplicate of this bug. ***