Bug 46898 - libgcc build failure on lm32-elf
Summary: libgcc build failure on lm32-elf
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.6.0
: P3 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-12 00:33 UTC by Masaki MURANAKA
Modified: 2014-03-02 21:55 UTC (History)
6 users (show)

See Also:
Host: lm32-pizzafactory-elf
Target:
Build: i386-apple-darwin10.5.0
Known to work: 4.5.2
Known to fail:
Last reconfirmed: 2011-01-25 14:58:49


Attachments
testcase (39 bytes, text/plain)
2010-12-12 00:33 UTC, Masaki MURANAKA
Details
Patch to config/lm32.[ch] (incomplete) (1.43 KB, patch)
2010-12-12 03:26 UTC, Masaki MURANAKA
Details | Diff
testcase after applied attachment 22719 (94 bytes, text/plain)
2010-12-12 03:37 UTC, Masaki MURANAKA
Details
testcase after applied attachment 22719 (79 bytes, text/plain)
2010-12-12 05:14 UTC, Masaki MURANAKA
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Masaki MURANAKA 2010-12-12 00:33:38 UTC
Created attachment 22718 [details]
testcase

cc1 -g conftest.c

conftest.c:1:0: internal compiler error: in dwarf2out_frame_init, at dwarf2out.c:4260
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://sourceforge.jp/projects/pf3gnuchains/ticket/> for instructions.

cc1 -version
GNU C (GCC) version 4.6.0 20101207 (experimental) (lm32-elf)
	compiled by GNU C version 4.2.1 (Apple Inc. build 5664), GMP version 4.2.4, MPFR version 2.4.1, MPC version 0.8
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Comment 1 Masaki MURANAKA 2010-12-12 03:26:03 UTC
Created attachment 22719 [details]
Patch to config/lm32.[ch]  (incomplete)

This issue was discussed at gcc-patches ML on 2010-10-29 but not applied to trunk.
The attached patch is modified to apply to gcc/trunk@167329.

We will get the another issue after applying this patch, but at least it will fix the part of this issue.
Comment 2 Masaki MURANAKA 2010-12-12 03:37:21 UTC
Created attachment 22720 [details]
testcase after applied attachment 22719 [details]

(In reply to comment #1)
> We will get the another issue after applying this patch, but at least it will
> fix the part of this issue.

The console out is follows:

$ ./cc1 testcase.i
 crash
Analyzing compilation unit
Performing interprocedural optimizations
 <*free_lang_data> <visibility> <early_local_cleanups> <emutls> <whole-program> <inline>Assembling functions:
 crashSegmentation fault
Comment 3 Masaki MURANAKA 2010-12-12 05:14:11 UTC
Created attachment 22721 [details]
testcase after applied attachment 22719 [details]

In reply to comment #2)

more simplified testcase.
Comment 4 Joel Sherrill 2011-01-25 04:15:05 UTC
The libgcc problem impacts lm32-rtems also.  Can the patch be applied?
Comment 5 Joel Sherrill 2011-01-25 14:58:49 UTC
I can confirm this on the lm32-rtems.

This is a serious regression from 4.5.2 since it prevents all lm32 targets from building.
Comment 6 Sebastien Bourdeauducq 2011-02-01 21:03:09 UTC
Original/complete patch is at
http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02561.html
Comment 7 Joel Sherrill 2011-02-01 21:37:05 UTC
Does the patch fix things for you(In reply to comment #6)
> Original/complete patch is at
> http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02561.html

Does this fix the head for you?

If so, I say commit it.  It is utterly broken now so building would be an improvement.

Jon.. any thoughts?
Comment 8 Sebastien Bourdeauducq 2011-02-01 22:00:24 UTC
After applying the above patch, the segmentation fault in cc1 is due to a stack overflow, which is likely to originate from infinite recursion:

(...)

#244 0x08238ddc in emit_move_insn (x=0xb7d69d10, y=0xb7d8c42c)
    at ../../gcc/gcc/expr.c:3391
#245 0x0821e153 in force_reg (mode=SImode, x=0xb7d69d00)
    at ../../gcc/gcc/explow.c:670
#246 0x0821e747 in memory_address_addr_space (mode=SImode, 
    x=<value optimized out>, as=0 '\000') at ../../gcc/gcc/explow.c:499
#247 0x0820e020 in change_address_1 (memref=0xb7d8c414, mode=SImode, 
    addr=0xb7d69d00, validate=1) at ../../gcc/gcc/emit-rtl.c:1935
#248 0x0821e499 in validize_mem (ref=0xb7d8c414) at ../../gcc/gcc/explow.c:537
#249 0x08238ddc in emit_move_insn (x=0xb7d69cf0, y=0xb7d8c414)
    at ../../gcc/gcc/expr.c:3391
#250 0x0821e153 in force_reg (mode=SImode, x=0xb7d69ce0)
    at ../../gcc/gcc/explow.c:670
#251 0x0821e747 in memory_address_addr_space (mode=SImode, 
    x=<value optimized out>, as=0 '\000') at ../../gcc/gcc/explow.c:499
#252 0x0820e020 in change_address_1 (memref=0xb7d8c3fc, mode=SImode, 
    addr=0xb7d69ce0, validate=1) at ../../gcc/gcc/emit-rtl.c:1935
#253 0x0821e499 in validize_mem (ref=0xb7d8c3fc) at ../../gcc/gcc/explow.c:537

(...)

#488 0x0821e499 in validize_mem (ref=0xb7cf1f90) at ../../gcc/gcc/explow.c:537
#489 0x08238ddc in emit_move_insn (x=0xb7d696f0, y=0xb7cf1f90)
    at ../../gcc/gcc/expr.c:3391
#490 0x0821e153 in force_reg (mode=SImode, x=0xb7d69640)
    at ../../gcc/gcc/explow.c:670
#491 0x0821e747 in memory_address_addr_space (mode=SImode, 
    x=<value optimized out>, as=0 '\000') at ../../gcc/gcc/explow.c:499
#492 0x0820e020 in change_address_1 (memref=0xb7cf1f78, mode=SImode, 
    addr=0xb7d69640, validate=1) at ../../gcc/gcc/emit-rtl.c:1935
#493 0x0823423c in expand_expr_real_1 (exp=<value optimized out>, 
    target=0xb7d69660, tmode=SImode, modifier=EXPAND_NORMAL, 
    alt_rtl=0xbfffed0c) at ../../gcc/gcc/expr.c:8460
#494 0x0823dee2 in store_expr (exp=0xb7d70000, target=0xb7d69660, 
    call_param_p=0, nontemporal=0 '\000') at ../../gcc/gcc/expr.c:4674
#495 0x0824037b in expand_assignment (to=0xb7d6af30, from=0xb7d70000, 
    nontemporal=0 '\000') at ../../gcc/gcc/expr.c:4447
#496 0x0818e3fa in expand_gimple_stmt_1 (stmt=0xb7d6ae70)
    at ../../gcc/gcc/cfgexpand.c:2000
#497 expand_gimple_stmt (stmt=0xb7d6ae70) at ../../gcc/gcc/cfgexpand.c:2109
#498 0x08190016 in expand_gimple_basic_block (bb=0xb7d663c0)
    at ../../gcc/gcc/cfgexpand.c:3579
#499 0x081952dc in gimple_expand_cfg () at ../../gcc/gcc/cfgexpand.c:4062
#500 0x0837fb79 in execute_one_pass (pass=0x8808440)
    at ../../gcc/gcc/passes.c:1561
#501 0x0837fe1d in execute_pass_list (pass=0x8808440)
    at ../../gcc/gcc/passes.c:1616
#502 0x0847fe9a in tree_rest_of_compilation (fndecl=0xb7d65780)
    at ../../gcc/gcc/tree-optimize.c:422
#503 0x0861327f in cgraph_expand_function (node=0xb7d73000)
    at ../../gcc/gcc/cgraphunit.c:1563
#504 0x08616124 in cgraph_output_in_order () at ../../gcc/gcc/cgraphunit.c:1716
#505 cgraph_optimize () at ../../gcc/gcc/cgraphunit.c:1877
#506 0x08616445 in cgraph_finalize_compilation_unit ()
    at ../../gcc/gcc/cgraphunit.c:1083
#507 0x080b2c98 in c_write_global_declarations ()
    at ../../gcc/gcc/c-decl.c:9872
#508 0x0841dc69 in compile_file (argc=1, argv=0xbffff304)
    at ../../gcc/gcc/toplev.c:591
#509 do_compile (argc=1, argv=0xbffff304) at ../../gcc/gcc/toplev.c:1874
#510 toplev_main (argc=1, argv=0xbffff304) at ../../gcc/gcc/toplev.c:1937
#511 0x0814022b in main (argc=1, argv=0xbffff304) at ../../gcc/gcc/main.c:36
Comment 9 Sebastien Bourdeauducq 2011-02-25 16:40:52 UTC
I ran git bisect for this. Here is the result:

74897bc755ddcb5ff67a91570c83e910ed950c7c is the first bad commit
commit 74897bc755ddcb5ff67a91570c83e910ed950c7c
Author: rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Aug 5 15:39:54 2010 +0000

    PR 45189
    Unbreak ia64 build after last dwarf2out.c change.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162917 138bc75d-0d04-0410-961f-82ee72b054a4
Comment 10 Joel Sherrill 2011-02-25 17:30:46 UTC
Richard I added this to you since I think Sebastian's bisect turned up a patch by you.
Comment 11 Sebastien Bourdeauducq 2011-02-25 18:49:46 UTC
Actually, Jon's patch (http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02561.html) fixes this one problem introduced by Richard's commit. But after Jon's patch is applied, the next commit to break LM32 is:

5ae82d58486a4ee6a9a7d5ca5fef2b43c2d53eb4 is the first bad commit
commit 5ae82d58486a4ee6a9a7d5ca5fef2b43c2d53eb4
Author: jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Sep 29 14:49:14 2010 +0000

    gcc:
    	* optc-gen.awk: Generate global_options initializer instead of
    	individual variables.  Add x_ prefix to names of structure
    	members.
    	* opth-gen.awk: Generate gcc_options structure.  Add x_ prefix to
    	names of structure members.
    	* doc/tm.texi.in (HARD_FRAME_POINTER_IS_FRAME_POINTER,
    	HARD_FRAME_POINTER_IS_ARG_POINTER): Document.
    	* doc/tm.texi: Regenerate.
    	* alias.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
    	* builtins.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER.
    	* c-parser.c (disable_extension_diagnostics,
    	restore_extension_diagnostics): Update names of cpp_options
    	members.
    	* combine.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
    	* common.opt (fcompare-debug-second): Don't use Var.
    	* config/alpha/alpha.h (target_flags): Remove.
    	* config/arm/arm.h (HARD_FRAME_POINTER_IS_FRAME_POINTER,
    	HARD_FRAME_POINTER_IS_ARG_POINTER): Define.
    	* config/bfin/bfin.h (target_flags): Remove.
    	* config/cris/cris.h (target_flags): Remove.
    	* config/i386/i386-c.c (ix86_pragma_target_parse): Update names of
    	cl_target_option members.
    	* config/i386/i386.c (ix86_force_align_arg_pointer): Remove.
    	(ix86_function_specific_print, ix86_valid_target_attribute_tree,
    	ix86_can_inline_p): Update names of cl_target_option members.
    	* config/i386/i386.h (ix86_isa_flags): Remove.
    	* config/lm32/lm32.h (target_flags): Remove.
    	* config/mcore/mcore.h (mcore_stack_increment): Remove.
    	* config/mcore/mcore.md (addsi3): Remove extern declaration of
    	flag_omit_frame_pointer.
    	* config/mep/mep.h (target_flags): Remove.
    	* config/mips/mips.h (HARD_FRAME_POINTER_IS_FRAME_POINTER,
    	HARD_FRAME_POINTER_IS_ARG_POINTER): Define.
    	* config/mmix/mmix.h (target_flags): Remove.
    	* config/rs6000/rs6000.h (rs6000_xilinx_fpu, flag_pic,
    	flag_expensive_optimizations): Remove.
    	* config/s390/s390.h (flag_pic): Remove.
    	* config/score/score-conv.h (target_flags): Remove.
    	* config/sh/sh.h (sh_fixed_range_str): Remove.
    	* config/spu/spu.h (target_flags, spu_fixed_range_string): Remove.
    	* dbxout.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER
    	* df-scan.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
    	* diagnostic.c (diagnostic_initialize): Update names of
    	diagnostic_context members.
    	* diagnostic.h (diagnostic_context): Rename inhibit_warnings and
    	warn_system_headers.
    	(diagnostic_report_warnings_p): Update for new names.
    	* dwarf2out.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER
    	* emit-rtl.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER and
    	HARD_FRAME_POINTER_IS_ARG_POINTER.
    	* flags.h (flag_compare_debug): Declare.
    	* ira.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
    	* opts.c (flag_compare_debug): Define.
    	(common_handle_option): Update names of diagnostic_context
    	members.  Handle -fcompare-debug-second.
    	(fast_math_flags_struct_set_p): Update names of cl_optimization
    	members.
    	* reginfo.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
    	* regrename.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
    	* reload.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
    	* reload1.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
    	* resource.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
    	* rtl.h (HARD_FRAME_POINTER_IS_FRAME_POINTER,
    	HARD_FRAME_POINTER_IS_ARG_POINTER): Define and use.
    	* sel-sched.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
    	* stmt.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER.
    
    gcc/c-family:
    	* c-common.c (c_cpp_error): Update names of diagnostic_context
    	members.
    	* c-cppbuiltin.c (c_cpp_builtins_optimize_pragma): Update names of
    	cl_optimization members.
    	* c-opts.c (warning_as_error_callback, c_common_handle_option,
    	sanitize_cpp_opts, finish_options): Update names of cpp_options
    	members.
    
    gcc/fortran:
    	* cpp.c (cpp_define_builtins): Update names of gfc_option_t
    	members.
    	(gfc_cpp_post_options): Update names of cpp_options members.
    	(cb_cpp_error): Update names of diagnostic_context members.
    	* f95-lang.c (gfc_init_builtin_functions): Update names of
    	gfc_option_t members.
    	* gfortran.h (gfc_option_t): Rename warn_conversion and
    	flag_openmp.
    	* intrinsic.c (gfc_convert_type_warn): Update names of
    	gfc_option_t members.
    	* options.c (gfc_init_options, gfc_post_options, set_Wall,
    	gfc_handle_option): Update names of gfc_option_t members.
    	* parse.c (next_free, next_fixed): Update names of gfc_option_t
    	members.
    	* scanner.c (pedantic): Remove extern declaration.
    	(skip_free_comments, skip_fixed_comments, include_line): Update
    	names of gfc_option_t members.
    	* trans-decl.c (gfc_generate_function_code): Update names of
    	gfc_option_t members.
    
    gcc/java:
    	* java-tree.h (flag_filelist_file, flag_assert, flag_jni,
    	flag_force_classes_archive_check, flag_redundant, flag_newer,
    	flag_use_divide_subroutine, flag_use_atomic_builtins,
    	flag_use_boehm_gc, flag_hash_synchronization,
    	flag_check_references, flag_optimize_sci, flag_indirect_classes,
    	flag_indirect_dispatch, flag_store_check,
    	flag_reduced_reflection): Remove.
    	* jcf-dump.c (flag_newer): Remove.
    	* jcf.h (quiet_flag): Remove.
    	* parse.h (quiet_flag): Remove.
    
    libcpp:
    	* include/cpplib.h (cpp_options): Rename warn_deprecated,
    	warn_traditional, warn_long_long and pedantic.
    	* directives.c (directive_diagnostics, _cpp_handle_directive):
    	Update names of cpp_options members.
    	* expr.c (cpp_classify_number, eval_token): Update names of
    	cpp_options members.
    	* init.c (cpp_create_reader, post_options): Update names of
    	cpp_options members.
    	* internal.h (CPP_PEDANTIC, CPP_WTRADITIONAL): Update names of
    	cpp_options members.
    	* macro.c (parse_params): Update names of cpp_options members.
    
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164723 138bc75d-0d04-0410-961f-82ee72b054a4

:040000 040000 7f1331709080b6ee7e383796c8fa4355f232dbaf da4cb5c8a6fc4a9f8d71f635429eff580271b6ac M	gcc
:040000 040000 1d94fafabedba4ed1f5a3b3624fe80a36d5a4349 57209d9534c8b500c849d601201aaa4e0248f0b6 M	libcpp
Comment 12 Sebastien Bourdeauducq 2011-02-25 19:04:07 UTC
ok... breaks it, but with a syntax error (seems to have been fixed in the meantime), not for the cc1 segfault we're looking for.
Comment 13 Sebastien Bourdeauducq 2011-02-25 19:24:24 UTC
Author: lekernel
Date: Fri Feb 25 19:24:20 2011
New Revision: 170502

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170502
Log:
2011-02-25  Sebastien Bourdeauducq <sebastien@milkymist.org>

	PR gcc/46898
	* config/lm32/lm32.md (ashrsi3): Added needed variable.

2011-02-25  Jon Beniston <jon@beniston.com>

	PR gcc/46898
	* config/lm32/lm32.h (INCOMING_RETURN_ADDR_RTX): New.
	* config/lm32/lm32.md (ashlsi3): Remove unused variable.
	* config/lm32/lm32.c (TARGET_EXCEPT_UNWIND_INFO): New.
	(lm32_block_move_inline): Add type cast to remove warning.
	(lm32_expand_prologue): Generate fp in a way compatible with
	dwarf2out.
	(gen_int_relational): Move declarations to start of function.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/lm32/lm32.c
    trunk/gcc/config/lm32/lm32.h
    trunk/gcc/config/lm32/lm32.md
Comment 14 Sebastien Bourdeauducq 2011-02-25 19:26:31 UTC
This gets the C compiler to build; if C++ is enabled, this triggers the cc1 segfault above.
Comment 15 Thibault North 2011-04-12 19:07:04 UTC
Same problem with the AVR arch, using the same testcase:
avr-gcc-4.5.2: OK
avr-gcc-4.6.0: avr-gcc -gdwarf-2 foo.c 
foo.c:1:0: internal compiler error: in dwarf2out_frame_init, at dwarf2out.c:4260
Please submit a full bug report,
with preprocessed source if appropriate.

$ avr-gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/avr-gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/avr/4.6.0/lto-wrapper
Target: avr
Configured with: ../gcc-4.6.0/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-system-zlib --enable-version-specific-runtime-libs --with-pkgversion='Fedora 4.6.0-1.fc14' --with-bugurl=https://bugzilla.redhat.com/
Thread model: single
gcc version 4.6.0 (Fedora 4.6.0-1.fc14)
Comment 16 Eric Weddington 2011-07-24 22:32:03 UTC
(In reply to comment #15)
> Same problem with the AVR arch, using the same testcase:
> avr-gcc-4.5.2: OK
> avr-gcc-4.6.0: avr-gcc -gdwarf-2 foo.c 
> foo.c:1:0: internal compiler error: in dwarf2out_frame_init, at
> dwarf2out.c:4260
> Please submit a full bug report,
> with preprocessed source if appropriate.
> 
> $ avr-gcc -v
> Using built-in specs.
> COLLECT_GCC=/usr/bin/avr-gcc
> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/avr/4.6.0/lto-wrapper
> Target: avr
> Configured with: ../gcc-4.6.0/configure --prefix=/usr --mandir=/usr/share/man
> --infodir=/usr/share/info --target=avr --enable-languages=c,c++ --disable-nls
> --disable-libssp --with-system-zlib --enable-version-specific-runtime-libs
> --with-pkgversion='Fedora 4.6.0-1.fc14'
> --with-bugurl=https://bugzilla.redhat.com/
> Thread model: single
> gcc version 4.6.0 (Fedora 4.6.0-1.fc14)

Thibault,

Please retest with trunk and/or 4.6.1, and if problem still exists on avr target then please submit a separate bug report.

Eric Weddington
Comment 17 jbeniston@gcc.gnu.org 2014-03-02 19:58:59 UTC
Author: jbeniston
Date: Sun Mar  2 19:58:24 2014
New Revision: 208260

URL: http://gcc.gnu.org/viewcvs?rev=208260&root=gcc&view=rev
Log:
	PR bootstrap/48230
	PR bootstrap/50927
	PR bootstrap/52466
	PR target/46898
	* config/lm32/lm32.c (lm32_legitimate_constant_p): Remove, as incorrect.
	  (TARGET_LEGITIMATE_CONSTANT_P): Undefine, as not needed.  
	* config/lm32/lm32.md (movsi_insn): Add 32-bit immediate support.
	(simple_return, *simple_return): New patterns     
	* config/lm32/predicates.md (movsi_rhs_operand): Remove as obsolete.
	* configure.ac (force_sjlj_exceptions): Force sjlj exceptions for lm32.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/lm32/lm32.c
    trunk/gcc/config/lm32/lm32.md
    trunk/gcc/config/lm32/predicates.md
    trunk/gcc/configure.ac
Comment 18 Sebastien Bourdeauducq 2014-03-02 21:55:29 UTC
Fixed, see comment #17