[Bug c/93196] New: GCC compiles c code, provides no executable output with option -O2

xiehongbiao at sensetime dot com gcc-bugzilla@gcc.gnu.org
Wed Jan 8 08:27:00 GMT 2020


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

            Bug ID: 93196
           Summary: GCC compiles c code, provides no executable output
                    with option -O2
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xiehongbiao at sensetime dot com
  Target Milestone: ---

Thanks for reading this.

I'm using gcc 5.4.0 to compile an open source project gmp-6.1.2. Some errors
happen in my Ubuntu16.04 mechine like below:

checking compiler cc -m32 -O2 -pedantic -fomit-frame-pointer ... no
checking compiler cc -O2 -pedantic -fomit-frame-pointer ... no, cmov
instruction, program does not run
configure: error: could not find a working compiler, see config.log for details

By check the config.log the issue can be narrow down to be an option "-O2" lead
to no executatle output in some special c code:

jiaojiancheng@jiaojiancheng:~/test_compile$ cat conftest.c
/* The following provokes an invalid instruction syntax from i386 gcc
   -march=pentiumpro on Solaris 2.8.  The native sun assembler
   requires a non-standard syntax for cmov which gcc (as of 2.95.2 at
   least) doesn't know.  */
#include "stdio.h"
int n;
int cmov () { return (n >= 0 ? n : 0); }
int main () { return 0; }

if run:
  gcc-5 -O1 -pedantic -fomit-frame-pointer -m64  conftest.c

There is an "a.out" generated. This is expected behavior

if run 
  gcc-5 -O2 -pedantic -fomit-frame-pointer -m64  conftest.c
Compiler doesn't report any message. But no "a.out" generated.

Is that an normal benavior? if yes, does that mean the logic in gmp-6.1.2 have
mistake.

Thanks.


More information about the Gcc-bugs mailing list