FreddieChopin / bleeding-edge-toolchain

All-in-one script to build bleeding-edge-toolchain for ARM microcontrollers
71 stars 24 forks source link

GCC 12.2.0 / MacOS ARM64 #30

Closed 42Bastian closed 1 year ago

42Bastian commented 1 year ago

gcc-12.2.0-final build stops with internal compiler error during libgcc build.

With gcc-12.1.0 it works.

FreddieChopin commented 1 year ago

Can you upload the console contents (just the last "block" would be enough) and maybe try finding the relevant .log file somewhere inside the build directory?

42Bastian commented 1 year ago

I will check, but it takes some time as I deleted it already.

42Bastian commented 1 year ago

Though 12.1.0 build completes, the big-endian patch I applied does not work. I will try 12.2.0 when this patch works. Edit: Ran build again, now the patch works.

42Bastian commented 1 year ago

Here now the compile which fails for 12.2.0

/Users/bastian/develop/gcc/buildNative/gcc-12.2.0-final/./gcc/xgcc -B/Users/bastian/develop/gcc/buildNative/gcc-12.2.0-final/./gcc/ -B/Users/bastian/develop/gcc/installNative/arm-none-eabi/bin/ -B/Users/bastian/develop/gcc/installNative/arm-none-eabi/lib/ -isystem /Users/bastian/develop/gcc/installNative/arm-none-eabi/include -isystem /Users/bastian/develop/gcc/installNative/arm-none-eabi/sys-include    -g -O2 -pipe -ffunction-sections -fdata-sections -marm -march=armv5te+fp -mfloat-abi=softfp -O2  -g -O2 -pipe -ffunction-sections -fdata-sections  -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fno-inline -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc  -fno-inline -I. -I. -I../../../../.././gcc -I/Users/bastian/develop/gcc/sources/gcc-12.2.0/libgcc -I/Users/bastian/develop/gcc/sources/gcc-12.2.0/libgcc/. -I/Users/bastian/develop/gcc/sources/gcc-12.2.0/libgcc/../gcc -I/Users/bastian/develop/gcc/sources/gcc-12.2.0/libgcc/../include     -o _fixunsdfsi.o -MT _fixunsdfsi.o -MD -MP -MF _fixunsdfsi.dep -DL_fixunsdfsi -c /Users/bastian/develop/gcc/sources/gcc-12.2.0/libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
xgcc: internal compiler error: Segmentation fault: 11 signal terminated program cc1
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.
make[4]: *** [_divdc3.o] Error 4
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [multi-do] Error 1
make[2]: *** [all-multi] Error 2
make[1]: *** [all-target-libgcc] Error 2
make: *** [all] Error 2

Just to note: Linux and cross-win64 build on WSL2 works.

42Bastian commented 1 year ago

If is not always the same line which throws the segmentation fault. Succesive runs stop at different places.

42Bastian commented 1 year ago

Compiling GCC with -O0 prevents the crash. I will try if -O1 or -Os work. Only need to find a way how build-....sh can feed this into the GCC makefile.

42Bastian commented 1 year ago

Building gcc-final with

    CFLAGS=-O1 CXXFLAGS=-O1

fixes the segmentation fault issue.

573,574c573
<           --with-multilib-list=rmprofile \
<           CFLAGS=-O1 CXXFLAGS=-O1"
---
>           --with-multilib-list=rmprofile"
FreddieChopin commented 1 year ago

One more thing you could also try is changing nproc="$(sysctl -n hw.ncpu)" to just nproc=1. If only the optimization helps, then I guess it must be some upstream GCC bug - either in the toolchain on your PC or in the GCC source that is compiled.

42Bastian commented 1 year ago

I give it a try.

42Bastian commented 1 year ago

I tried it. -j 1 does not help. 12.2.0 and 12.3.0 need -O1 for CFLAGS/CXXFLAGS when building gcc on MacOS. Could be an XCode problem. But it does not matter much. The M1 Mac is blasting quick and my main development machine is a PC (Windows/WSL2) so I do not care if -O1 or -O2 for the tools.