diff --git a/platform/unix/configure.ac b/platform/unix/configure.ac index 8ccf20b24..ddfa8345d 100644 --- a/platform/unix/configure.ac +++ b/platform/unix/configure.ac @@ -36,6 +36,12 @@ AS_VAR_IF([enable_osx], [no], [], #else AC_SUBST([LDFLAGS], ["${LDFLAGS} -framework CoreFoundation -framework Cocoa"]) AC_SUBST([CPPFLAGS], ["${CPPFLAGS} -I../platform/macosx"])) +# stb_image sse2 override (https://github.com/nothings/stb/issues/280) +AC_ARG_ENABLE([stbi-sse2-override], + AC_HELP_STRING([--enable-stbi-sse2-override], [Force stb_image SSE2 support]), [], [enable_stbi_sse2_override=no]) +AS_VAR_IF([enable_stbi_sse2_override], [no], [], #else + AC_SUBST([CPPFLAGS], ["${CPPFLAGS} -DLOVE_STBI_SSE2_OVERRIDE"])) + # --with-lua and --with-luaversion AC_ARG_WITH([lua], [AS_HELP_STRING([--with-lua], [Select the lua implementation])], [], [with_lua=luajit]) diff --git a/src/libraries/stb/stb_image.h b/src/libraries/stb/stb_image.h index fd4c872bc..13ba6c75c 100644 --- a/src/libraries/stb/stb_image.h +++ b/src/libraries/stb/stb_image.h @@ -712,12 +712,18 @@ static int stbi__sse2_available() static int stbi__sse2_available() { -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 // GCC 4.8 or later - // GCC 4.8+ has a nice way to do this - return __builtin_cpu_supports("sse2"); +#if defined(STBI__X64_TARGET) + // on x64, SSE2 can be assumed to be available. + return 1; +#elif defined(LOVE_STBI_SSE2_OVERRIDE) + return 1; #else - // portable way to do this, preferably without using GCC inline ASM? - // just bail for now. +# warning "stb_image compiled without SSE2 support, define LOVE_STBI_SSE2_OVERRIDE to force SSE2 support" + // __builtin_cpu_supports is buggy on GCC 5 and above, causing problems if + // referenced in a shared object, giving missing __cpu_model hidden symbol errors. + // To get around that, just assume that SSE2 is not available on x86. + // + // See https://github.com/nothings/stb/issues/280 for more information. return 0; #endif }