Menu

#712 Compilation/linking fails when compiling with -msse2/msse3/msse4.1/msse4.2

v1.0 (example)
closed-fixed
LIU Hao
None
5
2018-03-19
2018-03-13
Jan Dubiec
No

Test program:

#include <windows.h>

int main(int argc, char* argv[])
{
    MemoryBarrier();

    return 0;
}

$ gcc --version
gcc.exe (i686-posix-sjlj-rev1, Built by MinGW-W64 project) 6.3.0

$ gcc -msse2 -Wall testmb.c
R:\DOCUME~1\JDX~1.HS0\LOCALS~1\Temp\ccVV7ulN.o:testmb.c:(.text+0xc): undefined reference to `_mm_mfence'
collect2.exe: error: ld returned 1 exit status

Gcc 7.2.0 has the same problem. Everything is fine when the code is compiled with -msse or without -msse at all. It looks like a bug in header file(s) (winnt.h?) because _mm_mfence is defined in emmintrin.h.

Discussion

  • Zufu Liu

    Zufu Liu - 2018-03-13

    It's OK with gcc version 7.2.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) on Win 10 with Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz.

     
    • Jan Dubiec

      Jan Dubiec - 2018-03-13

      Oh, sorry, I didn't mention my platforms:
      1. Windows 7 Ultimate SP1 32 bit running on Core 2 Duo T7500, tested:
      – i686-5.2.0-win32-sjlj-rt_v4-rev0
      – i686-7.2.0-posix-dwarf-rt_v5-rev1
      – i686-7.2.0-posix-sjlj-rt_v5-rev1
      2. Windows XP Professional SP3 running on P4 Prescott, tested:
      – i686-6.3.0-posix-sjlj-rt_v5-rev1
      – i686-6.3.0-win32-sjlj-rt_v5-rev1
      – i686-7.2.0-posix-dwarf-rt_v5-rev1
      – i686-7.2.0-posix-sjlj-rt_v5-rev1

      All have the same problem.

       

      Last edit: Jan Dubiec 2018-03-13
  • LIU Hao

    LIU Hao - 2018-03-16
    • status: open --> open-accepted
    • assigned_to: LH_Mouse
     
  • LIU Hao

    LIU Hao - 2018-03-19
    • status: open-accepted --> closed-fixed
     
  • LIU Hao

    LIU Hao - 2018-03-19

    Fixed on master.

    On i686 -msse2 is not enabled by default, hence MemoryBarrier() is left unexpanded. GCC should have generated a warning about implicit function declaration which was removed in C99, but it doesn't because the function in question is brought in by a system header. An external definition is actually available, so there is neither compiler warnings nor linker errors.

     

Log in to post a comment.