public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tk@the-tk.com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug lto/66228] New: Compiling simple program with -flto -O1 causes mad behaviour
Date: Wed, 20 May 2015 20:38:00 -0000	[thread overview]
Message-ID: <bug-66228-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 66228
           Summary: Compiling simple program with -flto -O1 causes mad
                    behaviour
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tk@the-tk.com
  Target Milestone: ---

Created attachment 35582
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35582&action=edit
This is the wtf.i file left over from running gcc -v -save-temps -flto -O1
wtf.c

This code, when compiled with -O1 and -flto and ran with no arguments passed
prints:

./a.out: Incorrect number of arguments
./a.out: WTF?

And exits returning 1.

This behaviour is obviously incorrect.

This has been tested on versions (various people):
4.8.4
4.9.2 20150304
5.1.0 20150505
5.1.1 20150519

The version I am personally using is 4.9.2 20150304.

Here is the output of `gcc -v -save-temps -flto -O1 wtf.c':

Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-4.9-20150304/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib
--disable-werror --enable-checking=release
Thread model: posix
gcc version 4.9.2 20150304 (prerelease) (GCC) 
COLLECT_GCC_OPTIONS='-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-D'
'_FORTIFY_SOURCE=2' '-pie' '-fstack-protector-strong' '-v' '-save-temps'
'-flto' '-O1' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/cc1 -E -quiet -v -D
_FORTIFY_SOURCE=2 wtf.c -mtune=generic -march=x86-64 -fPIE
-fstack-protector-strong -flto -O1 -fpch-preprocess -o wtf.i
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/include
 /usr/local/include
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-D'
'_FORTIFY_SOURCE=2' '-pie' '-fstack-protector-strong' '-v' '-save-temps'
'-flto' '-O1' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/cc1 -fpreprocessed wtf.i -quiet
-dumpbase wtf.c -mtune=generic -march=x86-64 -auxbase wtf -O1 -version -fPIE
-fstack-protector-strong -flto -o wtf.s
GNU C (GCC) version 4.9.2 20150304 (prerelease) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.9.2 20150304 (prerelease), GMP version
6.0.0, MPFR version 3.1.2-p11, MPC version 1.0.2
warning: MPC header version 1.0.2 differs from library version 1.0.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (GCC) version 4.9.2 20150304 (prerelease) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.9.2 20150304 (prerelease), GMP version
6.0.0, MPFR version 3.1.2-p11, MPC version 1.0.2
warning: MPC header version 1.0.2 differs from library version 1.0.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: de1e8c8938fc18eb6d7bf643b5ef22cd
COLLECT_GCC_OPTIONS='-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-D'
'_FORTIFY_SOURCE=2' '-pie' '-fstack-protector-strong' '-v' '-save-temps'
'-flto' '-O1' '-mtune=generic' '-march=x86-64'
 as -v --64 -o wtf.o wtf.s
GNU assembler version 2.25.0 (x86_64-unknown-linux-gnu) using BFD version (GNU
Binutils) 2.25.0
COMPILER_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-D'
'_FORTIFY_SOURCE=2' '-pie' '-fstack-protector-strong' '-v' '-save-temps'
'-flto' '-O1' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/collect2 -plugin
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
-plugin-opt=-fresolution=wtf.res -plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -flto
--build-id --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker
/lib64/ld-linux-x86-64.so.2 -pie
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/Scrt1.o
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/crti.o
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/crtbeginS.o
-L/usr/lib/hardening-wrapper/bin -L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2
-L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib -L/lib/../lib
-L/usr/lib/../lib -L/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../.. wtf.o
-lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s
--no-as-needed /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/crtendS.o
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/crtn.o
 /usr/bin/gcc @/tmp/ccxHh0w0.args
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-4.9-20150304/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib
--disable-werror --enable-checking=release
Thread model: posix
gcc version 4.9.2 20150304 (prerelease) (GCC) 
COLLECT_GCC_OPTIONS='-c' '-fno-trapv' '-fno-strict-overflow' '-mtune=generic'
'-march=x86-64' '-O1' '-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-D'
'_FORTIFY_SOURCE=2' '-pie' '-fstack-protector-strong' '-v' '-save-temps' '-O1'
'-mtune=generic' '-march=x86-64'
'-fltrans-output-list=/tmp/cckzPbXh.ltrans.out' '-fwpa' '-fresolution=wtf.res'
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto1 -quiet -dumpbase wtf.o
-mtune=generic -march=x86-64 -mtune=generic -march=x86-64 -auxbase wtf -O1 -O1
-version -fno-trapv -fno-strict-overflow -fPIE -fstack-protector-strong
-fltrans-output-list=/tmp/cckzPbXh.ltrans.out -fwpa -fresolution=wtf.res
@/tmp/ccOxcM5h
GNU GIMPLE (GCC) version 4.9.2 20150304 (prerelease) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.9.2 20150304 (prerelease), GMP version
6.0.0, MPFR version 3.1.2-p11, MPC version 1.0.2
warning: MPC header version 1.0.2 differs from library version 1.0.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU GIMPLE (GCC) version 4.9.2 20150304 (prerelease) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.9.2 20150304 (prerelease), GMP version
6.0.0, MPFR version 3.1.2-p11, MPC version 1.0.2
warning: MPC header version 1.0.2 differs from library version 1.0.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COMPILER_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/../lib/:/lib/../lib/../lib/:/usr/lib/../lib/../lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../:/lib/:/usr/lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-c' '-fno-trapv' '-fno-strict-overflow' '-mtune=generic'
'-march=x86-64' '-O1' '-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-D'
'_FORTIFY_SOURCE=2' '-pie' '-fstack-protector-strong' '-v' '-save-temps' '-O1'
'-mtune=generic' '-march=x86-64'
'-fltrans-output-list=/tmp/cckzPbXh.ltrans.out' '-fwpa' '-fresolution=wtf.res'
[Leaving LTRANS /tmp/ccxHh0w0.args]
[Leaving LTRANS /tmp/cckzPbXh.ltrans.out]
 /usr/bin/gcc @/tmp/ccUKvuJr.args
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-4.9-20150304/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib
--disable-werror --enable-checking=release
Thread model: posix
gcc version 4.9.2 20150304 (prerelease) (GCC) 
COLLECT_GCC_OPTIONS='-c' '-fno-trapv' '-fno-strict-overflow' '-mtune=generic'
'-march=x86-64' '-O1' '-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-D'
'_FORTIFY_SOURCE=2' '-pie' '-fstack-protector-strong' '-v' '-save-temps' '-O1'
'-mtune=generic' '-march=x86-64'
'-fltrans-output-list=/tmp/cckzPbXh.ltrans.out' '-fltrans' '-o'
'/tmp/cckzPbXh.ltrans0.ltrans.o'
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto1 -quiet -dumpbase
cckzPbXh.ltrans0.o -mtune=generic -march=x86-64 -mtune=generic -march=x86-64
-auxbase-strip /tmp/cckzPbXh.ltrans0.ltrans.o -O1 -O1 -version -fno-trapv
-fno-strict-overflow -fPIE -fstack-protector-strong
-fltrans-output-list=/tmp/cckzPbXh.ltrans.out -fltrans @/tmp/ccNoDh2g -o
cckzPbXh.ltrans0.s
GNU GIMPLE (GCC) version 4.9.2 20150304 (prerelease) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.9.2 20150304 (prerelease), GMP version
6.0.0, MPFR version 3.1.2-p11, MPC version 1.0.2
warning: MPC header version 1.0.2 differs from library version 1.0.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU GIMPLE (GCC) version 4.9.2 20150304 (prerelease) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.9.2 20150304 (prerelease), GMP version
6.0.0, MPFR version 3.1.2-p11, MPC version 1.0.2
warning: MPC header version 1.0.2 differs from library version 1.0.3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='-c' '-fno-trapv' '-fno-strict-overflow' '-mtune=generic'
'-march=x86-64' '-O1' '-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-D'
'_FORTIFY_SOURCE=2' '-pie' '-fstack-protector-strong' '-v' '-save-temps' '-O1'
'-mtune=generic' '-march=x86-64'
'-fltrans-output-list=/tmp/cckzPbXh.ltrans.out' '-fltrans' '-o'
'/tmp/cckzPbXh.ltrans0.ltrans.o'
 as -v --64 -o /tmp/cckzPbXh.ltrans0.ltrans.o cckzPbXh.ltrans0.s
GNU assembler version 2.25.0 (x86_64-unknown-linux-gnu) using BFD version (GNU
Binutils) 2.25.0
COMPILER_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/
LIBRARY_PATH=/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/../lib/:/lib/../lib/../lib/:/usr/lib/../lib/../lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/hardening-wrapper/bin/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../:/lib/:/usr/lib/:/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-c' '-fno-trapv' '-fno-strict-overflow' '-mtune=generic'
'-march=x86-64' '-O1' '-B' '/usr/lib/hardening-wrapper/bin' '-fPIE' '-D'
'_FORTIFY_SOURCE=2' '-pie' '-fstack-protector-strong' '-v' '-save-temps' '-O1'
'-mtune=generic' '-march=x86-64'
'-fltrans-output-list=/tmp/cckzPbXh.ltrans.out' '-fltrans' '-o'
'/tmp/cckzPbXh.ltrans0.ltrans.o'
[Leaving LTRANS /tmp/ccUKvuJr.args]
[Leaving LTRANS /tmp/cckzPbXh.ltrans0.o]


             reply	other threads:[~2015-05-20 20:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-20 20:38 tk@the-tk.com [this message]
2015-05-21  8:55 ` [Bug lto/66228] " rguenth at gcc dot gnu.org
2021-08-25 20:50 ` pinskia at gcc dot gnu.org
2021-08-25 20:55 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-66228-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).