Skip to content

Commit

Permalink
Avoid __builtin_cpu_supports to workaround gcc bug. Refs #366
Browse files Browse the repository at this point in the history
* Upstream stb_image.h uses __builtin_cpu_supports to detect if SSE2 is
  available, but GCC versions from at least 5.4 and up to apparently
  6.1.1 on Fedora 24 then give an error about a missing hidden symbol
  __cpu_model when the resulting code is compiled into a DSO.
* Avoiding this by just assuming x64 gives SSE2 will fix 99% of cases,
  and it's not a big loss for the tiny minority with SSE2 on x86 to miss
  out. Thanks to @Anteru for this suggested fix!
  • Loading branch information
baldurk committed Sep 20, 2016
1 parent 45551e5 commit 953ebe0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions renderdoc/3rdparty/stb/stb_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,12 +712,15 @@ 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;
#else
// portable way to do this, preferably without using GCC inline ASM?
// just bail for now.
// __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
}
Expand Down

0 comments on commit 953ebe0

Please sign in to comment.