https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70611
Bug ID: 70611
Summary: Compiling binutils with -flto -Wstack-usage fails.
Product: gcc
Version: 5.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: dilyan.palauzov at aegee dot org
Target Milestone: ---
After binutils introduced passing -Wstack-usgage when compiling gas
(https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=9780e045073b1719a7a4c6cbe00e4aa7525bd180),
it does not compile anymore with -flto:
export CFLAGS="-pipe -O3 -fno-fat-lto-objects -flto"
export CXXFLAGS="-pipe -O3 -fno-fat-lto-objects -flto"
export LDFLAGS="-Wl,-O1,-z,relro,-s"
/git/binutils-gdb/gas/configure --with-system-zlib --enable-lto
--enable-threads --with-system-zlib --enable-compressed-debug-sections=none
make
[...]
make[2]: Entering directory '/root/binutils/gas'
/bin/bash ./libtool --tag=CC --mode=link gcc -W -Wall -Wstrict-prototypes
-Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -Wwrite-strings
-pipe -O3 -fno-fat-lto-objects -flto -Wl,-O1,-z,relro,-s -flto=8 -L/lib64 -o
as-new app.o as.o atof-generic.o compress-debug.o cond.o depend.o dwarf2dbg.o
dw2gencfi.o ecoff.o ehopt.o expr.o flonum-copy.o flonum-konst.o flonum-mult.o
frags.o hash.o input-file.o input-scrub.o listing.o literal.o macro.o
messages.o output-file.o read.o remap.o sb.o stabs.o subsegs.o symbols.o
write.o tc-i386.o obj-elf.o atof-ieee.o ../opcodes/libopcodes.la
../bfd/libbfd.la ../libiberty/libiberty.a -ldl
libtool: link: gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow
-Wstack-usage=262144 -Werror -Wwrite-strings -pipe -O3 -fno-fat-lto-objects
-flto -Wl,-O1 -Wl,-z -Wl,relro -Wl,-s -flto=8 -o as-new app.o as.o
atof-generic.o compress-debug.o cond.o depend.o dwarf2dbg.o dw2gencfi.o ecoff.o
ehopt.o expr.o flonum-copy.o flonum-konst.o flonum-mult.o frags.o hash.o
input-file.o input-scrub.o listing.o literal.o macro.o messages.o output-file.o
read.o remap.o sb.o stabs.o subsegs.o symbols.o write.o tc-i386.o obj-elf.o
atof-ieee.o -L/lib64 ../opcodes/.libs/libopcodes.a ../bfd/.libs/libbfd.a -lz
../libiberty/libiberty.a -ldl
/git/binutils-gdb/libiberty/make-relative-prefix.c: In function
'make_relative_prefix_1.constprop':
/git/binutils-gdb/libiberty/make-relative-prefix.c:228:1: error: stack usage
might be unbounded [-Werror=stack-usage=]
make_relative_prefix_1 (const char *progname, const char *bin_prefix,
^
lto1: all warnings being treated as errors
make[3]: *** [/tmp/ccGFedJA.ltrans24.ltrans.o] Error 1
make[3]: *** Waiting for unfinished jobs....
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/local/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Makefile:769: recipe for target 'as-new' failed
make[2]: *** [as-new] Error 1
make[2]: Leaving directory '/root/binutils/gas'
I use gcc (GCC) 5.3.1 20160407 and in /usr/local and have symlink
/usr/local/lib/bfd-plugins/liblto_plugin.so ->
/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/5.3.1/liblto_plugin.so .
This happens also when compiling ld.bfd, gprof, binutils/size .
I guess the problem is not in binutils, as it fails in libiberty, which comes
from gcc. I fails also when I replace libiberty bundled with binutils/master
with libiberty comming with gcc/gcc-5-branch .