Howdy!
So, I tend to want to just use CMake, Ninja, and Clang to build stuff and as recent as llvm 8 I didn’t have to use clang-cl.exe or work from the visual studdio developer shell.
So far everything I’ve wanted to build has worked just fine and dandy, but presently I’ve discovered that I can’t build SDL 2.0.10 this way.
There appears to be a problem with how SSE intrinsics are being detected.
The rough sequence of events that could lead to the following errors:
scoop install llvm
… download SDL2 sources and unpack them somewhere …
… then from the unpacked source root …
cmake -B.build -DCMAKE_BUILD_TYPE=Release -DCMAKE_RC_COMPILER=llvm-rc -GNinja
ninja -C .build SDL2-static
First error for me happens in SDL_audiocvt.c
but I know other sources have similar issues:
[7/150] Building C object CMakeFiles/SDL2-static.dir/src/audio/SDL_audiocvt.c.obj
FAILED: CMakeFiles/SDL2-static.dir/src/audio/SDL_audiocvt.c.obj
C:\Users\phote\scoop\shims\clang.exe -DUSING_GENERATED_CONFIG_H -Iinclude -I../include -idirafter C:/projects/slowgames/allyerfault/vendor/SDL2/2.0.10-src/src/video/khronos -IC:/projects/slowgames/allyerfault/vendor/SDL2/2.0.10-src/src/hidapi/hidapi -msse3 -msse2 -msse -m3dnow -mmmx -Wshadow -Wdeclaration-after-statement -Werror=declaration-after-statement -fno-strict-aliasing -Wall -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -MD -MT CMakeFiles/SDL2-static.dir/src/audio/SDL_audiocv
t.c.obj -MF CMakeFiles\SDL2-static.dir\src\audio\SDL_audiocvt.c.obj.d -o CMakeFiles/SDL2-static.dir/src/audio/SDL_audiocvt.c.obj -c ../src/audio/SDL_audiocvt.c
../src/audio/SDL_audiocvt.c:59:15: error: unknown type name '__m128'
const __m128 divby2 = _mm_set1_ps(0.5f);
^
../src/audio/SDL_audiocvt.c:59:31: warning: implicit declaration of function '_mm_set1_ps' is invalid in C99 [-Wimplicit-function-declaration]
const __m128 divby2 = _mm_set1_ps(0.5f);
^
../src/audio/SDL_audiocvt.c:61:13: warning: implicit declaration of function '_mm_store_ps' is invalid in C99 [-Wimplicit-function-declaration]
_mm_store_ps(dst, _mm_mul_ps(_mm_hadd_ps(_mm_load_ps(src), _mm_load_ps(src+4)), divby2));
^
../src/audio/SDL_audiocvt.c:61:31: warning: implicit declaration of function '_mm_mul_ps' is invalid in C99 [-Wimplicit-function-declaration]
_mm_store_ps(dst, _mm_mul_ps(_mm_hadd_ps(_mm_load_ps(src), _mm_load_ps(src+4)), divby2));
^
../src/audio/SDL_audiocvt.c:61:42: warning: implicit declaration of function '_mm_hadd_ps' is invalid in C99 [-Wimplicit-function-declaration]
_mm_store_ps(dst, _mm_mul_ps(_mm_hadd_ps(_mm_load_ps(src), _mm_load_ps(src+4)), divby2));
^
../src/audio/SDL_audiocvt.c:61:54: warning: implicit declaration of function '_mm_load_ps' is invalid in C99 [-Wimplicit-function-declaration]
_mm_store_ps(dst, _mm_mul_ps(_mm_hadd_ps(_mm_load_ps(src), _mm_load_ps(src+4)), divby2));
^
5 warnings and 1 error generated.
I see these functions and that type defined in the llvm installation so I feel pretty sure that there is a pretty simple configuration issue in the CMake build that isn’t handling this particular toolchain arrangement.
I know I can just run this run a developer shell and everything will be hunky dory but I’m really curious to figure out why this isn’t just working. I’d love it if someone more experienced in this matter could help me dig around.