[Bug lto/89896] New: -flto=4 is confused by presence of all.o in a local directory. -flto=1 is not.
slyfox at inbox dot ru
gcc-bugzilla@gcc.gnu.org
Sun Mar 31 09:43:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89896
Bug ID: 89896
Summary: -flto=4 is confused by presence of all.o in a local
directory. -flto=1 is not.
Product: gcc
Version: 8.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: slyfox at inbox dot ru
CC: marxin at gcc dot gnu.org
Target Milestone: ---
The bug is originally discovered by Fabio Coatti in
https://bugs.gentoo.org/682018.
There isl-0.21 fails to link when built with CFLAGS="-O2 -flto=4 -pipe"
LDFLAGS="${CFLAGS}". The trigger is all.c file name in isl source three. It
gets translated to all.o.
Here is the minimal reproducer:
$ cat foo.bash
#!/bin/bash
export LANG=C
cc=gcc
mk() {
local flag=$1
rm -rf -- *.o *.so*
${cc} ${flag} -fPIC -c all.c -o all.o
${cc} ${flag} -fPIC -c isl.c -o isl.o
# Note: all.o is not used here and yet in interferes with -flto=4
${cc} ${flag} -fPIC -shared isl.o -o libisl.so
}
# empty files are enough to trigger a bug
touch all.c isl.c
echo "=== -flto=1 (works) ==="
mk "-flto=1"
echo "=== -flto=4 (fails) ==="
mk "-flto=4"
Running:
$ ./foo.bash
=== -flto=1 (works) ===
=== -flto=4 (fails) ===
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../lib64/../lib64/Scrt1.o: in
function `_start':
/usr/src/debug/sys-libs/glibc-2.29-r1/glibc-2.29/csu/../sysdeps/x86_64/start.S:104:
undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: all] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/../../../../x86_64-pc-linux-gnu/bin/ld:
error: lto-wrapper failed
collect2: error: ld returned 1 exit status
Note: all.o is never passed to gcc as an input. And yet it's presence
interferes with the driver.
More information about the Gcc-bugs
mailing list