From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15130 invoked by alias); 26 May 2012 01:32:31 -0000 Received: (qmail 15122 invoked by uid 22791); 26 May 2012 01:32:30 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_BJ X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 26 May 2012 01:32:16 +0000 From: "jwatte at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53493] New: [4.7 regression] Compiling with -Os excludes PROGMEM array from generated object file (__attribute__((__progmem__))) Date: Sat, 26 May 2012 01:50:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jwatte at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-05/txt/msg02527.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53493 Bug #: 53493 Summary: [4.7 regression] Compiling with -Os excludes PROGMEM array from generated object file (__attribute__((__progmem__))) Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: jwatte@gmail.com I'm using AVR-GCC 4.7.0-1 from Arch Linux, if it matters. When compiling with -Os (which is pretty much a must for most source code,) an exported data array declared as PROGMEM will be removed by the compiler! Compare without -Os: Code: $ avr-gcc -mmcu=atmega328p -c foo.cpp -o foo.o && avr-objdump -s foo.o foo.o: file format elf32-avr Contents of section .progmem.data: 0000 666f6f00 foo. Contents of section .comment: 0000 00474343 3a202847 4e552920 342e372e .GCC: (GNU) 4.7. 0010 3000 0. to with -Os: Code: $ avr-gcc -Os -mmcu=atmega328p -c foo.cpp -o foo.o && avr-objdump -s foo.o foo.o: file format elf32-avr Contents of section .comment: 0000 00474343 3a202847 4e552920 342e372e .GCC: (GNU) 4.7. 0010 3000 0. Here is foo.cpp: Code: #include unsigned char const foo[4] PROGMEM = { 'f', 'o', 'o', 0 }; Must I add some magic GNU make hack to my makefiles to not pass -Os for these files? That's fairly cumbersome Is this a known bug? Is there a patch?