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: unassig...@gcc.gnu.org ReportedBy: jwa...@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 <avr/pgmspace.h> 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?