animetosho / rapidyenc

SIMD accelerated yEnc en/decode C library
5 stars 0 forks source link

Building with MinGW #3

Closed mnightingale closed 10 months ago

mnightingale commented 10 months ago

I've figured out that to use a static build of the library with Go on Windows I must use mingw-w64 to build it, builds from msvc are not supported.

So I've setup MSYS2 and building with gcc, however, I get a load of similar errors such as:

...
[  3%] Building CXX object CMakeFiles/rapidyenc.dir/src/platform.cc.obj
In file included from C:\[snip]\rapidyenc\src\common.h:123,
                 from C:\[snip]\rapidyenc\src\platform.cc:1:
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/tmmintrin.h: In function '__m128i _mm_hadd_epi16(__m128i, __m128i)':
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/13.2.0/include/tmmintrin.h:42:20: error: '__builtin_ia32_phaddw128' was not declared in this scope; did you mean '__builtin_ia32_paddw128'?
   42 |   return (__m128i) __builtin_ia32_phaddw128 ((__v8hi)__X, (__v8hi)__Y);
...

From what I can gather GCC isn't letting it use intrinsics without the relevant compiler flags -march=native or -msse4 etc. If I pass -DCMAKE_CXX_FLAGS=-msse4 I can build it, but I don't know if that's any better than -march=native.

If I understand correctly then the problem is that common.h is getting included in files which don't actually need intrinsics?

I've no idea why I've successfully made Linux x64 builds with gcc but on Windows it complains.

I'm attempting to build with:

msys2-x86_64-20231026.exe and add C:\msys64\mingw64\bin to PATH pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make

cmake -S rapidyenc -B rapidyenc/build -G "MinGW Makefiles"
cmake --build rapidyenc/build --config Release --target rapidyenc_static

Thanks for the looking, this should be the last platform giving me problems.

animetosho commented 10 months ago

Thanks!