Skip to content

Commit

Permalink
Generalize AVR -Werror=array-bounds workaround (#21798)
Browse files Browse the repository at this point in the history
GCC 13 needs the same workaround as GCC 12.
To avoid having to maintain an ever-growing list of broken versions
apply the workaround wherever it can be used.

If at some point a fixed version of GCC is released the workaround can
be disabled for those fixed versions.

See #17064
  • Loading branch information
t-8ch authored Aug 23, 2023
1 parent f7cf066 commit f699fde
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions platforms/avr/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ HEX = $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature
EEP = $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT)
BIN =

# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
ifneq ($(findstring 12.,$(shell avr-gcc --version 2>/dev/null)),)
ifeq ("$(shell echo "int main(){}" | $(CC) --param=min-pagesize=0 -x c - -o /dev/null 2>&1)", "")

This comment has been minimized.

Copy link
@koron

koron Sep 16, 2023

This failed for MinGW-w64's avr-gcc 12.2

/dev/null is translated to nul by MinGW.
nul is always exsting on Windows, and can't be created.
and avr ld tries to create output file

Output of `echo 'int main() {}' | avr-gcc --param=min-pagesize=0 -x c - -o /dev/null` on MinGW
Using built-in specs.
Reading specs from d:/msys64/mingw64/bin/../lib/gcc/avr/12.2.0/device-specs/specs-avr2
COLLECT_GCC=D:\msys64\mingw64\bin\avr-gcc.exe
COLLECT_LTO_WRAPPER=d:/msys64/mingw64/bin/../libexec/gcc/avr/12.2.0/lto-wrapper.exe
Target: avr
Configured with: ../gcc-12.2.0/configure --build=x86_64-w64-mingw32 --prefix=/mingw64 --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --disable-shared --disable-threads --disable-libgomp --disable-libada --with-dwarf2 --enable-mingw-wildcard
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (GCC) 
COLLECT_GCC_OPTIONS='--param=min-pagesize=0' '-o' 'nul' '-v' '-mdouble=32' '-mlong-double=64' '-specs=device-specs/specs-avr2' '-dumpdir' 'a-'
 d:/msys64/mingw64/bin/../libexec/gcc/avr/12.2.0/cc1.exe -quiet -v -iprefix d:\msys64\mingw64\bin\../lib/gcc/avr/12.2.0/ - -mn-flash=6 -mskip-bug -quiet -dumpdir a- -dumpbase - -mdouble=32 -mlong-double=64 -version --param=min-pagesize=0 -o C:\Users\koron\AppData\Local\Temp\ccy9Ltta.s
GNU C17 (GCC) version 12.2.0 (avr)
	compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.26-GMP

warning: GMP header version 6.2.1 differs from library version 6.3.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "d:\msys64\mingw64\bin\../lib/gcc/avr/12.2.0/../../../../avr/sys-include"
ignoring duplicate directory "d:/msys64/mingw64/lib/gcc/../../lib/gcc/avr/12.2.0/include"
ignoring duplicate directory "d:/msys64/mingw64/lib/gcc/../../lib/gcc/avr/12.2.0/include-fixed"
ignoring nonexistent directory "d:/msys64/mingw64/lib/gcc/../../lib/gcc/avr/12.2.0/../../../../avr/sys-include"
ignoring duplicate directory "d:/msys64/mingw64/lib/gcc/../../lib/gcc/avr/12.2.0/../../../../avr/include"
#include "..." search starts here:
#include <...> search starts here:
 d:\msys64\mingw64\bin\../lib/gcc/avr/12.2.0/include
 d:\msys64\mingw64\bin\../lib/gcc/avr/12.2.0/include-fixed
 d:\msys64\mingw64\bin\../lib/gcc/avr/12.2.0/../../../../avr/include
End of search list.
GNU C17 (GCC) version 12.2.0 (avr)
	compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.26-GMP

warning: GMP header version 6.2.1 differs from library version 6.3.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 86152b58bc9ad39d340e567e0a5e2492
COLLECT_GCC_OPTIONS='--param=min-pagesize=0' '-o' 'nul' '-v' '-mdouble=32' '-mlong-double=64' '-specs=device-specs/specs-avr2' '-dumpdir' 'a-'
 d:/msys64/mingw64/bin/../lib/gcc/avr/12.2.0/../../../../avr/bin/as.exe -mmcu=avr2 -mgcc-isr -o C:\Users\koron\AppData\Local\Temp\ccCEdvBd.o C:\Users\koron\AppData\Local\Temp\ccy9Ltta.s
COMPILER_PATH=d:/msys64/mingw64/bin/../libexec/gcc/avr/12.2.0/;d:/msys64/mingw64/bin/../libexec/gcc/;d:/msys64/mingw64/bin/../lib/gcc/avr/12.2.0/../../../../avr/bin/
LIBRARY_PATH=d:/msys64/mingw64/bin/../lib/gcc/avr/12.2.0/;d:/msys64/mingw64/bin/../lib/gcc/;d:/msys64/mingw64/bin/../lib/gcc/avr/12.2.0/../../../../avr/lib/
COLLECT_GCC_OPTIONS='--param=min-pagesize=0' '-o' 'nul' '-v' '-mdouble=32' '-mlong-double=64' '-specs=device-specs/specs-avr2' '-dumpdir' 'a.'
 d:/msys64/mingw64/bin/../libexec/gcc/avr/12.2.0/collect2.exe -plugin d:/msys64/mingw64/bin/../libexec/gcc/avr/12.2.0/liblto_plugin.dll -plugin-opt=d:/msys64/mingw64/bin/../libexec/gcc/avr/12.2.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\koron\AppData\Local\Temp\cc6IQIng.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lm -plugin-opt=-pass-through=-lc -o nul -Ld:/msys64/mingw64/bin/../lib/gcc/avr/12.2.0 -Ld:/msys64/mingw64/bin/../lib/gcc -Ld:/msys64/mingw64/bin/../lib/gcc/avr/12.2.0/../../../../avr/lib C:\Users\koron\AppData\Local\Temp\ccCEdvBd.o --start-group -lgcc -lm -lc --end-group
d:/msys64/mingw64/bin/../lib/gcc/avr/12.2.0/../../../../avr/bin/ld.exe: cannot open output file nul: Invalid argument
collect2.exe: error: ld returned 1 exit status
COMPILEFLAGS += --param=min-pagesize=0
endif

Expand Down

0 comments on commit f699fde

Please sign in to comment.