https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78531
Bug ID: 78531 Summary: [7 Regression] gnat bootstrap broken on linux targets with _FORTIFY_SOURCE enabled Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: bootstrap Assignee: unassigned at gcc dot gnu.org Reporter: doko at gcc dot gnu.org Target Milestone: --- seen with trunk r242874 on all linux architectures, and this patch to enable the build with -D_FORTIFY_SOURCE=2. This works on the gcc-6-branch, system glibc is 2.24. --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -1176,6 +1176,10 @@ c_cpp_builtins (cpp_reader *pfile) builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0); builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0); + /* Fortify Source enabled by default for optimization levels > 0 */ + if (optimize) + builtin_define_with_int_value ("_FORTIFY_SOURCE", 2); + /* Misc. */ if (flag_gnu89_inline) cpp_define (pfile, "__GNUC_GNU_INLINE__"); /<<PKGBUILDDIR>>/build/./prev-gcc/xgcc -B/<<PKGBUILDDIR>>/build/./prev-gcc/ -B/usr/x86_64-linux-gnu/bin/ -B/usr/x86_64-linux-gnu/bin/ -B/usr/x86_64-linux-gnu/lib/ -isystem /usr/x86_64-linux-gnu/include -isystem /usr/x86_64-linux-gnu/sys-include -isystem /<<PKGBUILDDIR>>/build/sys-include -c -g -O2 -fno-stack-protector -gnatpg -W -Wall -nostdinc -I- -I. -Iada/generated -Iada -I../../src/gcc/ada -I../../src/gcc/ada/gcc-interface ../../src/gcc/ada/a-charac.ads -o ada/a-charac.o *** buffer overflow detected ***: /<<PKGBUILDDIR>>/build/./prev-gcc/gnat1 terminated ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x790cb)[0x7f4945f4a0cb] /lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x54)[0x7f4945feb2c4] /lib/x86_64-linux-gnu/libc.so.6(+0x118240)[0x7f4945fe9240] /<<PKGBUILDDIR>>/build/./prev-gcc/gnat1[0x6f73c6] /<<PKGBUILDDIR>>/build/./prev-gcc/gnat1(gigi+0xcc9)[0x705dc9] /<<PKGBUILDDIR>>/build/./prev-gcc/gnat1(back_end__call_back_end+0x1b0)[0x9e8d40] /<<PKGBUILDDIR>>/build/./prev-gcc/gnat1(_ada_gnat1drv+0x897)[0x9e9ba7] /<<PKGBUILDDIR>>/build/./prev-gcc/gnat1[0x6c866d] /<<PKGBUILDDIR>>/build/./prev-gcc/gnat1[0xd7920f] /<<PKGBUILDDIR>>/build/./prev-gcc/gnat1(_ZN6toplev4mainEiPPc+0x6ef)[0x6ac8bf] /<<PKGBUILDDIR>>/build/./prev-gcc/gnat1(main+0x27)[0x6aec37] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f4945ef13f1] /<<PKGBUILDDIR>>/build/./prev-gcc/gnat1(_start+0x2a)[0x6af02a] ======= Memory map: ======== 00400000-01df1000 r-xp 00000000 fd:01 530541 /<<PKGBUILDDIR>>/build/prev-gcc/gnat1 01ff0000-01ff9000 r--p 019f0000 fd:01 530541 /<<PKGBUILDDIR>>/build/prev-gcc/gnat1 01ff9000-02007000 rw-p 019f9000 fd:01 530541 /<<PKGBUILDDIR>>/build/prev-gcc/gnat1 02007000-0267f000 rw-p 00000000 00:00 0 02b53000-02cc2000 rw-p 00000000 00:00 0 [heap] 7f4945933000-7f4945949000 r-xp 00000000 fd:01 529904 /<<PKGBUILDDIR>>/build/prev-gcc/libgcc_s.so.1 7f4945949000-7f4945b48000 ---p 00016000 fd:01 529904 /<<PKGBUILDDIR>>/build/prev-gcc/libgcc_s.so.1 7f4945b48000-7f4945b49000 r--p 00015000 fd:01 529904 /<<PKGBUILDDIR>>/build/prev-gcc/libgcc_s.so.1 7f4945b49000-7f4945b4a000 rw-p 00016000 fd:01 529904 /<<PKGBUILDDIR>>/build/prev-gcc/libgcc_s.so.1 7f4945b4a000-7f4945b63000 rw-p 00000000 00:00 0 7f4945cd1000-7f4945ed1000 rw-p 00000000 00:00 0 7f4945ed1000-7f494608e000 r-xp 00000000 fd:01 257285 /lib/x86_64-linux-gnu/libc-2.24.so 7f494608e000-7f494628e000 ---p 001bd000 fd:01 257285 /lib/x86_64-linux-gnu/libc-2.24.so 7f494628e000-7f4946292000 r--p 001bd000 fd:01 257285 /lib/x86_64-linux-gnu/libc-2.24.so 7f4946292000-7f4946294000 rw-p 001c1000 fd:01 257285 /lib/x86_64-linux-gnu/libc-2.24.so 7f4946294000-7f4946298000 rw-p 00000000 00:00 0 7f4946298000-7f49463a0000 r-xp 00000000 fd:01 257184 /lib/x86_64-linux-gnu/libm-2.24.so 7f49463a0000-7f494659f000 ---p 00108000 fd:01 257184 /lib/x86_64-linux-gnu/libm-2.24.so 7f494659f000-7f49465a0000 r--p 00107000 fd:01 257184 /lib/x86_64-linux-gnu/libm-2.24.so 7f49465a0000-7f49465a1000 rw-p 00108000 fd:01 257184 /lib/x86_64-linux-gnu/libm-2.24.so 7f49465a1000-7f49465ba000 r-xp 00000000 fd:01 257301 /lib/x86_64-linux-gnu/libz.so.1.2.8 7f49465ba000-7f49467b9000 ---p 00019000 fd:01 257301 /lib/x86_64-linux-gnu/libz.so.1.2.8 7f49467b9000-7f49467ba000 r--p 00018000 fd:01 257301 /lib/x86_64-linux-gnu/libz.so.1.2.8 7f49467ba000-7f49467bb000 rw-p 00019000 fd:01 257301 /lib/x86_64-linux-gnu/libz.so.1.2.8 7f49467bb000-7f49467be000 r-xp 00000000 fd:01 257282 /lib/x86_64-linux-gnu/libdl-2.24.so 7f49467be000-7f49469bd000 ---p 00003000 fd:01 257282 /lib/x86_64-linux-gnu/libdl-2.24.so 7f49469bd000-7f49469be000 r--p 00002000 fd:01 257282 /lib/x86_64-linux-gnu/libdl-2.24.so 7f49469be000-7f49469bf000 rw-p 00003000 fd:01 257282 /lib/x86_64-linux-gnu/libdl-2.24.so 7f49469bf000-7f4946a3e000 r-xp 00000000 fd:01 266273 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.1 7f4946a3e000-7f4946c3d000 ---p 0007f000 fd:01 266273 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.1 7f4946c3d000-7f4946c3e000 r--p 0007e000 fd:01 266273 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.1 7f4946c3e000-7f4946c3f000 rw-p 0007f000 fd:01 266273 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.1 7f4946c3f000-7f4946ca2000 r-xp 00000000 fd:01 266354 /usr/lib/x86_64-linux-gnu/libmpfr.so.4.1.5 7f4946ca2000-7f4946ea1000 ---p 00063000 fd:01 266354 /usr/lib/x86_64-linux-gnu/libmpfr.so.4.1.5 7f4946ea1000-7f4946ea3000 r--p 00062000 fd:01 266354 /usr/lib/x86_64-linux-gnu/libmpfr.so.4.1.5 7f4946ea3000-7f4946ea4000 rw-p 00064000 fd:01 266354 /usr/lib/x86_64-linux-gnu/libmpfr.so.4.1.5 7f4946ea4000-7f4946ebb000 r-xp 00000000 fd:01 266369 /usr/lib/x86_64-linux-gnu/libmpc.so.3.0.0 7f4946ebb000-7f49470ba000 ---p 00017000 fd:01 266369 /usr/lib/x86_64-linux-gnu/libmpc.so.3.0.0 7f49470ba000-7f49470bb000 r--p 00016000 fd:01 266369 /usr/lib/x86_64-linux-gnu/libmpc.so.3.0.0 7f49470bb000-7f49470bc000 rw-p 00017000 fd:01 266369 /usr/lib/x86_64-linux-gnu/libmpc.so.3.0.0 7f49470bc000-7f494723f000 r-xp 00000000 fd:01 265189 /usr/lib/x86_64-linux-gnu/libisl.so.15.2.1 7f494723f000-7f494743e000 ---p 00183000 fd:01 265189 /usr/lib/x86_64-linux-gnu/libisl.so.15.2.1 7f494743e000-7f494743f000 r--p 00182000 fd:01 265189 /usr/lib/x86_64-linux-gnu/libisl.so.15.2.1 7f494743f000-7f4947441000 rw-p 00183000 fd:01 265189 /usr/lib/x86_64-linux-gnu/libisl.so.15.2.1 7f4947441000-7f4947466000 r-xp 00000000 fd:01 257196 /lib/x86_64-linux-gnu/ld-2.24.so 7f49474ea000-7f494751f000 rw-p 00000000 00:00 0 7f494754c000-7f4947550000 rw-p 00000000 00:00 0 7f494757d000-7f4947581000 rw-p 00000000 00:00 0 7f4947595000-7f494765b000 rw-p 00000000 00:00 0 7f494765b000-7f4947665000 rw-p 00000000 00:00 0 7f4947665000-7f4947666000 r--p 00024000 fd:01 257196 /lib/x86_64-linux-gnu/ld-2.24.so 7f4947666000-7f4947667000 rw-p 00025000 fd:01 257196 /lib/x86_64-linux-gnu/ld-2.24.so 7f4947667000-7f4947668000 rw-p 00000000 00:00 0 7ffc8a440000-7ffc8a487000 rw-p 00000000 00:00 0 [stack] 7ffc8a5a0000-7ffc8a5a2000 r--p 00000000 00:00 0 [vvar] 7ffc8a5a2000-7ffc8a5a4000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] +===========================GNAT BUG DETECTED==============================+ | 7.0.0 20161124 (experimental) [trunk revision 242837] (x86_64-linux-gnu) | | Program_Error unhandled signal | | Error detected at system.ads:178:5 | | Please submit a bug report; see http://gcc.gnu.org/bugs.html. | | Use a subject line meaningful to you and us to track the bug. | | Include the entire contents of this bug box in the report. | | Include the exact command that you entered. | | Also include sources listed below. | +==========================================================================+ Please include these source files with error report Note that list may not be accurate in some cases, so please double check that the problem can still be reproduced with the set of files listed. Consider also -gnatd.n switch (see debug.adb). ../../src/gcc/ada/system.ads ../../src/gcc/ada/a-charac.ads ../../src/gcc/ada/ada.ads compilation abandoned ../../src/gcc/ada/gcc-interface/Make-lang.in:119: recipe for target 'ada/a-charac.o' failed make[5]: *** [ada/a-charac.o] Error 1 Makefile:4655: recipe for target 'all-stage3-gcc' failed make[4]: *** [all-stage3-gcc] Error 2 make[4]: Leaving directory '/<<PKGBUILDDIR>>/build' Makefile:26581: recipe for target 'stage3-bubble' failed make[3]: *** [stage3-bubble] Error 2 make[3]: Leaving directory '/<<PKGBUILDDIR>>/build' Makefile:26644: recipe for target 'bootstrap' failed make[2]: *** [bootstrap] Error 2