I got this error when trying to compile GRUB (latest bzr) on amd64 with -flto: lto1: internal compiler error: compressed stream: buffer error The culprit was an acinclude check, which can be reduced to the following test case: asm (".globl start; start: nop"); int main () { } I'm not sure this can be considered valid C (or at least valid GNU C). I'm tentatively setting ice-on-invalid-code keyword. If I understand correctly, it is equivalent to: void start () { asm ("nop"); } int main () { } In any case I suppose if the code isn't valid, GCC ought to fail more gracefully than this, so I report anyway in case you'd like to know :-)
top level asm is valid GNU C code.
The issue here is that the asm doesn't switch sections properly and we emit LTO sections before the actual assembly. So we end up with ... .section .gnu.lto_.opts,"",@progbits .string "x\001\001," .string "\323\377\001" .string "" ... .ascii "\"\306\003T" .section .gnu.lto_main #APP .globl start; start: nop #NO_APP .text .globl main .type main, @function main: pushl %ebp movl %esp, %ebp popl %ebp ret .size main, .-main .comm gnu_lto_v1,1,1 where after finishing .gnu.lto_.opts we switch "back" to .gnu.lto_main which then has the toplevel asm appended. Oops. Now assembling the testcase w/o LTO also gets us .file "t.c" #APP .globl start; start: nop #NO_APP .text .globl main .type main, @function main: ... thus the asm gets emitted in the default section. Which means the testcase is kind of invalid (and the issue is that we emit LTO stuff at the beginning, not at the end where it could remain unspecified).
Fixed.
Subject: Bug 42392 Author: rguenth Date: Wed Dec 16 23:07:10 2009 New Revision: 155298 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155298 Log: 2009-12-16 Richard Guenther <rguenther@suse.de> PR lto/42392 * langhooks.c (lhd_begin_section): Make sure to switch back to the text section, not some random one. * gcc.dg/lto/20091216-1_0.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/lto/20091216-1_0.c Modified: trunk/gcc/ChangeLog trunk/gcc/langhooks.c trunk/gcc/testsuite/ChangeLog