GNOME Bugzilla – Bug 755455
undefined reference to `__builtin_popcount'
Last modified: 2015-09-23 15:35:46 UTC
Hi. Compiling gtk+ 3.18.0 fails on OpenBSD because of: undefined reference to `__builtin_popcount' I am not sure when __builtin_popcount was added to GCC, but could we modify the check for __GNUC__ in gtk/gtkcssselector.c so that it matches only for the version (and up) the builting was added? Thanks.
Created attachment 311933 [details] [review] Improve compiler detection for __builtin_popcount() The popcount builtin was added in GCC after version 4.2 (which is what some *BSDs are using), which means we need to be more specific when using it than just asking for GCC. While we're at it, we can improve the compiler detection, and use a builtin popcount on Clang ≥ 3.1 and MSVC 2008.
I used GCC 4.5 as the cut-off because that's the first version that I could find with Google. We could use 4.2 as the cut-off, but nothing except BSDs and MacOS uses it, so I think we're on the safe side anyway.
Review of attachment 311933 [details] [review]: Looks good, thanks
Attachment 311933 [details] pushed as a080cb4 - Improve compiler detection for __builtin_popcount()
A bit late to the party, but yeah, that fixes the build. Thanks a lot guys.
Hi, Just a note for records, I fixed the MSVC 2008+ portion as the patch here did not do it quite right, in commit ac62479, as MSVC 2008 means _MSC_VER <= 1500 and it should be __popcnt()m, not __popcount(). With blessings, thank you!