Bug 22313 - [4.2 Regression] profiledbootstrap is broken on the mainline
Summary: [4.2 Regression] profiledbootstrap is broken on the mainline
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.2.0
: P1 critical
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: build, wrong-code
: 23502 27011 (view as bug list)
Depends on: 25518
Blocks: 24934
  Show dependency treegraph
 
Reported: 2005-07-05 18:36 UTC by bero
Modified: 2006-09-27 13:46 UTC (History)
11 users (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work: 4.0.2 4.1.0
Known to fail: 4.2.0
Last reconfirmed: 2006-06-05 10:19:37


Attachments
preprocessed source (58.88 KB, application/x-bzip2)
2005-07-05 18:37 UTC, bero
Details
Generated asm code (26.11 KB, application/x-bzip2)
2005-07-05 18:39 UTC, bero
Details
Preprocessed source of code triggering this in current 4.1 SVN (68.49 KB, application/x-bzip2)
2006-01-17 19:35 UTC, bero
Details
asm code generated by current 4.1 SVN (34.15 KB, application/x-bzip2)
2006-01-17 19:36 UTC, bero
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bero 2005-07-05 18:36:28 UTC
SSIA. 
Building with gcc 3.4.4, binutils 2.16.1 (tried 2.16.91.0.1 too, same 
behavior) results in 
 
stage1/xgcc -Bstage1/ -B/usr/i586-ark-linux/bin/ -c   -g -O2 -fprofile-use  
-freorder-blocks-and-partition -DIN_GCC   -W -Wall -Wwrite-strings  
-Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long  
-Wno-variadic-macros -Wold-style-definition -Werror -fno-common    
-DHAVE_CONFIG_H    -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include  
-I../../gcc/../libcpp/include  ../../gcc/attribs.c -o attribs.o  
/tmp/ccHE8Qe5.s: Assembler messages:  
/tmp/ccHE8Qe5.s:1539: Error: invalid sections for operation on `.LCFI11' and  
`.LCFI10'  
make[2]: *** [attribs.o] Error 1
Comment 1 bero 2005-07-05 18:37:25 UTC
Created attachment 9208 [details]
preprocessed source
Comment 2 bero 2005-07-05 18:39:01 UTC
Created attachment 9209 [details]
Generated asm code
Comment 3 Pawel Sikora 2005-07-26 18:32:02 UTC
imho the code is good. assembler should converts the local 
references into relocs off the .text section. 
 
        .section .rodata 
.zoo:   .long .foo-.zoo 
        .section .text 
.foo:   nop 
 
Disassembly of section .text: 
 
00000000 <.foo>: 
   0:   90                      nop 
 
RELOCATION RECORDS FOR [.rodata]: 
OFFSET   TYPE              VALUE 
00000000 R_386_PC32        .text 
 
(binutils-2.15.94.0.2.2) 
 
Comment 4 Andrew Pinski 2005-08-20 22:18:17 UTC
*** Bug 23502 has been marked as a duplicate of this bug. ***
Comment 5 Andrew Pinski 2005-08-20 22:20:10 UTC
Actually this effects x86_64 only or if you have a local patch to turn on omit frame pointer all the time 
and -fasynchronous-unwind-tables which is why only x86_64 is effected on a pure sources.
Comment 6 Andrew Pinski 2005-09-08 19:49:23 UTC
This works for me with binutils 2.15.
Comment 7 Ian Lance Taylor 2005-10-05 23:36:17 UTC
This is not a bug in the assembler.  The attached assembler code is trying to put the difference between a symbol in the .text section (.LCFI10) and the .text.unlikely section (.LCFI11) into the .debug_frame section.  There is no way to represent such a relocation in ELF.  It would require the relocation to specify two different symbols, which can not be done in ELF, or it would require a paired relocation, which is not supported for x86_64 ELF.

Comment #3 is incorrect as it refers to the special case in which the computed difference is being put into the same section as the subtrahend symbol.  That case does not apply here.
Comment 8 Andrew Pinski 2005-10-06 00:24:07 UTC
(In reply to comment #5)
> Actually this effects x86_64 only or if you have a local patch to turn on omit
> frame pointer all the time 
> and -fasynchronous-unwind-tables which is why only x86_64 is effected on a pure
> sources.

Actually this is on x86-linux-gnu with a newer binutils, I don't know why I attributed it to x86_64 for some reason, which means it is not related at all to -fasynchronous-unwind-tables.
Comment 9 Andrew Pinski 2005-10-06 00:32:49 UTC
Closing as works for me, this works for me and it worked for Honza on 2005-09-28, see PR 23396, comment #5.

Plus 2.15 errored out with your .s file.  So it looks like one of your local patches were breaking this.
Comment 10 bero 2005-10-10 21:48:15 UTC
This is still reproducable here [with unpatched sources], using binutils 2.16.1 and gcc 3.4.4 to compile the stage1 compiler
Comment 11 Mark Loeser 2005-11-06 20:29:36 UTC
This is reproducable on gcc mainline on amd64:

{standard input}: Assembler messages:
{standard input}:510: Error: can't resolve `.text.unlikely' {.text.unlikely section} - `.LFB96' {.text section}

Building gcc-4.1.0_beta20051105 with gcc-4.0.2, with binutils 2.16.91.0.3.  Same error with binutils-2.16.1 as well.
Comment 12 Andrew Pinski 2005-11-09 16:29:23 UTC
(In reply to comment #11)
> This is reproducable on gcc mainline on amd64:
This works for me with "GNU assembler 2.16.91 20051027" with the GCC mainline on i686-linux-gnu
And with "GNU assembler 2.16" with the GCC mainline on x86_64-linux-gnu.
Comment 13 Mark Loeser 2005-11-11 17:52:50 UTC
You should be able to reproduce this by setting BOOT_CFLAGS="-O2".  Eliminating that allows me to successfully compile gcc-4.1 on x86_64.
Comment 14 Andrew Pinski 2005-11-11 18:50:06 UTC
This is a bug still.
Comment 15 Andrew Pinski 2005-11-11 18:50:50 UTC
so with -g, it works but without -g it does not.
Comment 16 Andrew Pinski 2005-11-11 19:01:10 UTC
The problem is that dwarf2out_switch_text_section does not get called as the debug_hooks are set to none.

So the handling of NOTE_INSN_SWITCH_TEXT_SECTIONS is slightly wrong for this case.  Looking more into it.
Comment 17 Andrew Pinski 2005-11-11 19:10:25 UTC
Testing a fix for the with/without -g problem.
Comment 18 Andrew Pinski 2005-11-11 20:14:59 UTC
Patch posted for the x86_64 failure:
http://gcc.gnu.org/ml/gcc-patches/2005-11/msg00857.html

For the i686 failure, I don't know since I was not able to reproduce that.
Comment 19 Papadakos Panagiotis 2005-11-23 19:37:09 UTC
I don't know if this is related, but I can't compile make profiledbootstrap
on a x86 Linux. Stops in attribs.c. I don't know if it is related to this bug
but you can find more info in http://gcc.gnu.org/ml/gcc/2005-11/msg00906.html
Comment 20 Steven Bosscher 2005-12-16 22:46:39 UTC
Review mail was here: http://gcc.gnu.org/ml/gcc-patches/2005-12/msg00121.html
Comment 21 Mark Mitchell 2005-12-19 17:55:15 UTC
This is a bootstrap failure, and there is an approved patch, so this should be fixed before release: P1.
Comment 22 Andrew Pinski 2005-12-20 03:58:32 UTC
Test this again on the 4.1 branch and then will apply it there, the mainline currently ignores BOOT_CFLAGS so I cannot test it there.
Comment 23 Andrew Pinski 2005-12-20 04:53:09 UTC
Subject: Bug 22313

Author: pinskia
Date: Tue Dec 20 04:53:06 2005
New Revision: 108839

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108839
Log:
2005-12-19  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/22313
        * dwarf2out.c (dwarf2out_switch_text_section): Export.
        * debug.h (dwarf2out_switch_text_section): Prototype.
        * final.c (final_scan_insn): Call dwarf2out_switch_text_section
        if we need to call it for dwarf2 unwind info.


Forgot the PR number

Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog

Comment 24 Andrew Pinski 2005-12-20 04:53:16 UTC
Fixed on the 4.1 branch, will test the mainline with --disable-bootstrap since that caused BOOT_CFLAGS to be ignored.
Comment 25 Andrew Pinski 2005-12-20 06:46:09 UTC
This is now broken even with -g on the mainline so unassigning.
Comment 26 Papadakos Panagiotis 2005-12-20 16:07:49 UTC
I still can't profiledbootstrap gcc 4.1 branch. Stops with the following message:

tage1/xgcc -Bstage1/ -B/usr/gcc_4_1/i486-slackware-linux/bin/ -c   -O2 -g -fomit-frame-pointer -fprofile-use -freorder-blocks-and-partition -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-definition -Wmissing-format-attribute     -DHAVE_CONFIG_H -I. -I. -I../../gcc-4_1-branch/gcc -I../../gcc-4_1-branch/gcc/. -I../../gcc-4_1-branch/gcc/../include -I../../gcc-4_1-branch/gcc/../libcpp/include     ../../gcc-4_1-branch/gcc/attribs.c -o attribs.o
/tmp/ccXgVrwC.s: Assembler messages:
/tmp/ccXgVrwC.s:1280: Error: invalid sections for operation on `.LCFI71' and `.LCFI70'
make[2]: *** [attribs.o] Error 1

This is with binutils 2.16.91.0.4 20051111
and gcc version 4.0.3 20051207 (prerelease)
on a linux x86 machine.
Comment 27 bero 2006-01-17 19:34:07 UTC
Still breaks for me on 4.1 branch too (4.1 branch SVN ID 109831).
Linux x86, binutils 2.16.91.0.4

The error is related but slightly different and on a different file these days:

c-errors.c -o c-errors.o
stage1/xgcc -Bstage1/ -B/usr/i586-ark-linux/bin/ -c   -g -O2 -fprofile-use -freorder-blocks-and-partition -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-definition -Wmissing-format-attribute     -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include -I../../gcc/../libcpp/include     ../../gcc/c-lex.c -o c-lex.o
/tmp/ccMLYhJE.s: Assembler messages:
/tmp/ccMLYhJE.s:2979: Error: invalid sections for operation on `.LCFI22' and `.LCFI21'
/tmp/ccMLYhJE.s:3048: Error: invalid sections for operation on `.LCFI38' and `.LCFI37'
/tmp/ccMLYhJE.s:3242: Error: invalid sections for operation on `.LCFI76' and `.LCFI75'
/tmp/ccMLYhJE.s:3279: Error: invalid sections for operation on `.LCFI83' and `.LCFI82'
Comment 28 bero 2006-01-17 19:35:53 UTC
Created attachment 10664 [details]
Preprocessed source of code triggering this in current 4.1 SVN
Comment 29 Andrew Pinski 2006-01-17 19:36:53 UTC
(In reply to comment #27)
> Still breaks for me on 4.1 branch too (4.1 branch SVN ID 109831).
> Linux x86, binutils 2.16.91.0.4

Can you file a different bug and attach the .s file?  Because I don't see this at all.  Also can you try with a FSF release of binutils and not some hacked up version?
Comment 30 bero 2006-01-17 19:36:58 UTC
Created attachment 10665 [details]
asm code generated by current 4.1 SVN
Comment 31 Andrew Pinski 2006-03-03 18:25:09 UTC
I am going to apply my patch to the mainline in the next or two,  I will make sure I also apply my follow up patch too.
Comment 32 Andrew Pinski 2006-03-08 00:01:28 UTC
And now profiledbootstrap is broken a different way on the mainline so I am not fixing this.
Comment 33 Andrew Pinski 2006-04-03 22:05:09 UTC
*** Bug 27011 has been marked as a duplicate of this bug. ***
Comment 34 Alexandre Oliva 2006-05-29 09:15:08 UTC
I've completed a successful profiledbootstrap on amd64-linux-gnu last night.  Is anyone else still seeing this, or is it fixed?
Comment 35 Peter Doerfler 2006-05-29 09:39:39 UTC
FWIW profiledbootstrap still fails with -march=pentium4 and fortran enabled because of PR26449.
Last tested with 20060520.
Comment 36 Papadakos Panagiotis 2006-05-29 12:23:29 UTC
Still have this problen on x86 with latest gcc-4.1 SVN branch and
binutils 2.16.91.0.7.

stage1/xgcc -Bstage1/ -B/usr/i486-slackware-linux/bin/ -c   -O2 -g -fomit-frame-pointer -fprofile-use -freorder-blocks-and-partition -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-definition -Wmissing-format-attribute     -DHAVE_CONFIG_H -I. -I. -I../../gcc-4.1-branch/gcc -I../../gcc-4.1-branch/gcc/. -I../../gcc-4.1-branch/gcc/../include -I../../gcc-4.1-branch/gcc/../libcpp/include     ../../gcc-4.1-branch/gcc/attribs.c -o attribs.o
/tmp/ccoORGHT.s: Assembler messages:
/tmp/ccoORGHT.s:1280: Error: invalid sections for operation on `.LCFI71' and `.LCFI70'
make[2]: *** [attribs.o] Error 1
make[2]: Leaving directory `/root/SVN/GCC/build/gcc'
make[1]: *** [stagefeedback_build] Error 2
make[1]: Leaving directory `/root/SVN/GCC/build/gcc'
make: *** [profiledbootstrap] Error 2
Comment 37 roger 2006-07-17 22:15:29 UTC
I've now tested "make profiledbootstrap" on both mainline and the gcc-4_1-branch,
on both x86_64-unknown-linux-gnu and i686-pc-linux-gnu, and not only does the
profiled bootstrap build fine, but the dejagnu testsuite looks identical to a baseline "make bootstrap".

Could anyone confirm whether they're still seeing this problem?  Its likely
that Andrew Pinski's patches together with the resolution of PRs 25518 and
26449 have now resolved this issue.
Comment 38 Papadakos Panagiotis 2006-07-17 23:19:20 UTC
Unfortunately I still have the same problem..
Don't know if I am the only one!
This is during compiling gcc 4.1 SVN trunk

GNU ld version 2.16.91.0.7 20060317

gcc -v
Using built-in specs.
Target: i486-slackware-linux
Configured with: ../gcc-4.1-branch/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 4.1.2 20060601 (prerelease)

stage1/xgcc -Bstage1/ -B/usr/i486-slackware-linux/bin/ -c   -O2 -g -fomit-frame-pointer -fprofile-use -freorder-blocks-and-partition -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-definition -Wmissing-format-attribute     -DHAVE_CONFIG_H -I. -I. -I../../gcc-4.1-branch/gcc -I../../gcc-4.1-branch/gcc/. -I../../gcc-4.1-branch/gcc/../include -I../../gcc-4.1-branch/gcc/../libcpp/include     ../../gcc-4.1-branch/gcc/c-lang.c -o c-lang.o
stage1/xgcc -Bstage1/ -B/usr/i486-slackware-linux/bin/ -c   -O2 -g -fomit-frame-pointer -fprofile-use -freorder-blocks-and-partition -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-definition -Wmissing-format-attribute     -DHAVE_CONFIG_H -I. -I. -I../../gcc-4.1-branch/gcc -I../../gcc-4.1-branch/gcc/. -I../../gcc-4.1-branch/gcc/../include -I../../gcc-4.1-branch/gcc/../libcpp/include     ../../gcc-4.1-branch/gcc/stub-objc.c -o stub-objc.o
stage1/xgcc -Bstage1/ -B/usr/i486-slackware-linux/bin/ -c   -O2 -g -fomit-frame-pointer -fprofile-use -freorder-blocks-and-partition -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros -Wold-style-definition -Wmissing-format-attribute     -DHAVE_CONFIG_H -I. -I. -I../../gcc-4.1-branch/gcc -I../../gcc-4.1-branch/gcc/. -I../../gcc-4.1-branch/gcc/../include -I../../gcc-4.1-branch/gcc/../libcpp/include     ../../gcc-4.1-branch/gcc/attribs.c -o attribs.o
/tmp/ccqSKDxK.s: Assembler messages:
/tmp/ccqSKDxK.s:1280: Error: invalid sections for operation on `.LCFI71' and `.LCFI70'
Comment 39 roger 2006-07-24 00:45:11 UTC
My latest analysis and a possible patch/workaround have been posted here:
http://gcc.gnu.org/ml/gcc-patches/2006-07/msg01015.html
Comment 40 Jan Hubicka 2006-08-07 08:18:51 UTC
Roger,
the patch for advance loc seems sane solution to me (in my limited understanding
of dwarf2). 

If I understand it right, we need the advance_loc only when crossing the section boundary, so we ought to be able to use NOTE_INSN_SWITCH_TEXT_SECTIONS and use the advance_loc only when tripping over it.  Only anoying thing would be probably to get it passed out of final.c up to the offending place.

Thanks for looking into this,
Honza
Comment 41 Roger Sayle 2006-08-31 17:35:41 UTC
Subject: Bug 22313

Author: sayle
Date: Thu Aug 31 17:35:32 2006
New Revision: 116604

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116604
Log:

	PR other/22313
	* dwarf2out.c (add_fde_cfi): Use a set_loc if the current label is
	NULL, otherwise use an advance_loc4 to adjust relative to the 
	current label.
	(output_cfi) <DW_CFA_set_loc>: Update the current label.
	(dwarf2out_switch_text_section): Reset the current label to avoid
	using advance_loc4 over section boundaries.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c

Comment 42 Andrew Pinski 2006-08-31 17:53:13 UTC
Fixed.
Comment 43 Roger Sayle 2006-09-01 15:47:38 UTC
Subject: Bug 22313

Author: sayle
Date: Fri Sep  1 15:47:29 2006
New Revision: 116628

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=116628
Log:

	PR other/22313
	* dwarf2out.c (add_fde_cfi): Use a set_loc if the current label is
	NULL, otherwise use an advance_loc4 to adjust relative to the 
	current label.
	(output_cfi) <DW_CFA_set_loc>: Update the current label.
	(dwarf2out_switch_text_section): Reset the current label to avoid
	using advance_loc4 over section boundaries.


Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/dwarf2out.c