#277 builtins unusable under -O0, no crt apps impossible


Using mingw-w32-bin_i686-mingw_20111219.zip, mingw64 GCC can not use GCC builtins under -O0 optimization level preventing the creation of any PEs which do not link to the CRT. Under all -O flags (I tried -O1 -O2 -Ofast ) except -O0, the program will compile. A sample program is included. It is called memcpy.c. It was compiled with i686-w64-mingw32-gcc.exe memcpy.c -nostdlib -lkernel32 -o memcpy.exe -v -Wall -O0" . Mingw64 GCC converted the __builtin_memcpy function to memcpy, which is a CRT function, then fail when they can't link to the CRT. Mingw.org GCC does NOT exhibit this.

I brought up the problem in these 2 places before.


  • bulk88

    bulk88 - 2012-03-12

    CL output of mingw64 comiling attempts

  • bulk88

    bulk88 - 2012-03-12
  • Jonathan Yong

    Jonathan Yong - 2012-03-12
    • status: open --> closed-invalid
  • Jonathan Yong

    Jonathan Yong - 2012-03-12

    Cygwin GCC does the same thing, so its not mingw-w64 specific. Also, <http://gcc.gnu.org/ml/gcc-help/2008-08/msg00065.html>

    So you may want to contact gcc-help instead.

  • bulk88

    bulk88 - 2012-03-12

    Did you read the line where this is a bug specific to mingw64 gcc, and that mingw.org gcc doesn't have this bug?

  • bulk88

    bulk88 - 2012-03-12
    • status: closed-invalid --> open-invalid
  • Jonathan Yong

    Jonathan Yong - 2012-03-12

    I'm saying its not a mingw-w64 bug, its a GCC behavior. So please contact gcc-help for help on forcing built-ins to be emitted.

  • Mark Dootson

    Mark Dootson - 2012-03-12

    This issue also raised in connection with Strawberry Perl and future use of perlmingw.sf.net

    The difference between mingw.org and mingw-w64 is that the default options output by mingw-w64 output correctly


    whilst mingw.org outputs


    If you explicitly pass -mtune=i386 to the 32 bit mingw-w64, that has no problem with builtins

    Likewise if you explicitly pass -mtune=generic to mingw.org, that fails too.

    There's know equivalent 'hack' for 64bit mingw-w64 where -mtune options don't help.

    Hopefully, this may point up where the actual issue is for someone - it isn't clear to me at all.

  • Kai Tietz

    Kai Tietz - 2012-03-30
    • status: open-invalid --> pending-invalid

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks