https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70599
Bug ID: 70599 Summary: Crash when adding debug symbols to a program making heavy use of nested templates. Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: major Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: graemehattan7 at hotmail dot com Target Milestone: --- This issue was found while trying to compile the source code for the aprinter 3D printer firmware - https://github.com/ambrop72/aprinter Normal compilation works fine, the issue is when I try to add the -g option for a debug build. When I do this, the compilation resources increase until 100% cpu and memory are used. Eventually I get the following message: arm-none-eabi-gcc: internal compiler error: Killed (program cc1plus) Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. The aprinter software makes heavy use of nested templates, I imagine that this is what trigger the issue. I have attached the pre-processor output from the file that fails. Unfortunately this is quite large due to the number of headers defining template classes. The issue can be reproduced with the following command - arm-none-eabi-gcc -g -x c++ -c -mcpu=cortex-m3 -mthumb -Wall -Wextra -Wfatal-errors -Wno-unused -Wno-sign-compare -std=c++11 -fno-access-control aprinter-nixbuild.ii Note that there will be a lot of compiler warnings produced (~750 MB!) if the -Wno-unused flag is removed. This is in part because of the very long type names produced by template nesting. Additional info: arm-none-eabi-gcc -v Using built-in specs. COLLECT_GCC=/nix/store/hq0izgjckpfiw9mmbh4lz2skfx70bzlw-gcc-arm-embedded-fromsrc-5.3.0/bin/arm-none-eabi-gcc COLLECT_LTO_WRAPPER=/nix/store/hq0izgjckpfiw9mmbh4lz2skfx70bzlw-gcc-arm-embedded-fromsrc-5.3.0/libexec/gcc/arm-none-eabi/5.3.0/lto-wrapper Target: arm-none-eabi Configured with: ../gcc-5.3.0/configure --target=arm-none-eabi --prefix=/nix/store/hq0izgjckpfiw9mmbh4lz2skfx70bzlw-gcc-arm-embedded-fromsrc-5.3.0 --with-sysroot=/nix/store/hq0izgjckpfiw9mmbh4lz2skfx70bzlw-gcc-arm-embedded-fromsrc-5.3.0/arm-none-eabi --enable-interwork --disable-nls --with-build-time-tools=/nix/store/hq0izgjckpfiw9mmbh4lz2skfx70bzlw-gcc-arm-embedded-fromsrc-5.3.0/arm-none-eabi/bin --enable-poison-system-directories --enable-lto --enable-gold --disable-decimal-float --disable-libffi --disable-libgomp --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-threads --disable-shared --disable-tls --with-newlib --disable-libunwind-exceptions --enable-checking=release --enable-languages=c,c++ Thread model: single gcc version 5.3.0 (GCC) The compiler was built via the nix-build derivation included in aprinter - https://github.com/ambrop72/aprinter/blob/master/nix/gcc-arm-embedded-fromsrc.nix This includes some (small) custom patches which are included in the aprinter code. As far as I can see they are unrelated to the issue. I have also tried to use the arm-none-eabi compiler in the Ubunutu 15.10 repositories (4.9.3) and have the same issue - arm-none-eabi-gcc -v Using built-in specs. COLLECT_GCC=arm-none-eabi-gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-none-eabi/4.9.3/lto-wrapper Target: arm-none-eabi Configured with: ../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/lib/include' --mandir='/usr/lib/share/man' --infodir='/usr/lib/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir='/usr/lib/lib/x86_64-linux-gnu' --libexecdir='/usr/lib/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --mandir=/usr/share/man --enable-languages=c,c++,lto --enable-multilib --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --build=x86_64-linux-gnu --target=arm-none-eabi --with-system-zlib --with-gnu-as --with-gnu-ld --with-pkgversion=15:4.9.3+svn227297-1 --without-included-gettext --prefix=/usr/lib --infodir=/usr/share/doc/gcc-arm-none-eabi/info --htmldir=/usr/share/doc/gcc-arm-none-eabi/html --pdfdir=/usr/share/doc/gcc-arm-none-eabi/pdf --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --disable-libstdc++-v3 --host=x86_64-linux-gnu --with-headers=no --without-newlib --with-multilib-list=armv6-m,armv7-m,armv7e-m,armv7-r CFLAGS='-g -O2 -fstack-protector-strong' CPPFLAGS=-D_FORTIFY_SOURCE=2 CXXFLAGS='-g -O2 -fstack-protector-strong' FCFLAGS='-g -O2 -fstack-protector-strong' FFLAGS='-g -O2 -fstack-protector-strong' GCJFLAGS='-g -O2 -fstack-protector-strong' LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro' OBJCFLAGS='-g -O2 -fstack-protector-strong' OBJCXXFLAGS='-g -O2 -fstack-protector-strong' INHIBIT_LIBC_CFLAGS=-DUSE_TM_CLONE_REGISTRY=0 AR_FOR_TARGET=arm-none-eabi-ar AS_FOR_TARGET=arm-none-eabi-as LD_FOR_TARGET=arm-none-eabi-ld NM_FOR_TARGET=arm-none-eabi-nm OBJDUMP_FOR_TARGET=arm-none-eabi-objdump RANLIB_FOR_TARGET=arm-none-eabi-ranlib READELF_FOR_TARGET=arm-none-eabi-readelf STRIP_FOR_TARGET=arm-none-eabi-strip Thread model: single gcc version 4.9.3 20150529 (prerelease) (15:4.9.3+svn227297-1)