https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69552

            Bug ID: 69552
           Summary: flto save-temps overwrites file
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Say we use save-temps with flto in it's simplest form:
...
$ gcc -O2 -flto banana.c orange.c lemon.c -O2 -fno-use-linker-plugin
-flto-partition=none -save-temps
...

After compilation we have:
...
$ ls -1 | egrep -v '\.(c|i)$'
a.out
banana.o
banana.s
lemon.o
lemon.s
orange.o
orange.s
...

Both lemon.s and orange.s contain gimple and assembly from the initial cc1
invocation.

But banana.s contains only assembly, and contains at the beginning '.file
"<artifical>"'. It contains the output of lto1.

When adding -c, we see the original contents of banana.s from cc1: gimple and
assembly, starting with '.file "banana.c"'.

So, we appear to be using the file banana.s twice in the compilation process.

Confirmed by grepping:
...
$ gcc -O2 -flto banana.c orange.c lemon.c -O2 -fno-use-linker-plugin
-flto-partition=none -save-temps -v  2>&1 | grep '\-o banana.s'
 libexec/gcc/x86_64-pc-linux-gnu/6.0.0/cc1 -fpreprocessed banana.i -quiet
-dumpbase banana.c -mtune=generic -march=x86-64 -auxbase banana -O2 -O2
-version -flto -fno-use-linker-plugin -flto-partition=none -o banana.s
 libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto1 -quiet -dumpbase banana.o
-mtune=generic -march=x86-64 -mtune=generic -march=x86-64 -auxbase-strip
/tmp/ccbAWzhX.lto.o -O2 -O2 -O2 -O2 -version -fmath-errno -fsigned-zeros
-ftrapping-math -fno-trapv -fno-openmp -fno-openacc -fno-use-linker-plugin
-flto-partition=none @/tmp/cctx7jrX -o banana.s
...

Reply via email to