After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 755455 - undefined reference to `__builtin_popcount'
undefined reference to `__builtin_popcount'
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
3.18.x
Other OpenBSD
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2015-09-23 08:39 UTC by Antoine Jacoutot
Modified: 2015-09-23 15:35 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Improve compiler detection for __builtin_popcount() (1.83 KB, patch)
2015-09-23 10:05 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review

Description Antoine Jacoutot 2015-09-23 08:39:57 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.
Comment 1 Emmanuele Bassi (:ebassi) 2015-09-23 10:05:52 UTC
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.
Comment 2 Emmanuele Bassi (:ebassi) 2015-09-23 10:07:18 UTC
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.
Comment 3 Matthias Clasen 2015-09-23 12:54:02 UTC
Review of attachment 311933 [details] [review]:

Looks good, thanks
Comment 4 Emmanuele Bassi (:ebassi) 2015-09-23 13:01:01 UTC
Attachment 311933 [details] pushed as a080cb4 - Improve compiler detection for __builtin_popcount()
Comment 5 Antoine Jacoutot 2015-09-23 13:25:45 UTC
A bit late to the party, but yeah, that fixes the build.
Thanks a lot guys.
Comment 6 Fan, Chun-wei 2015-09-23 15:35:46 UTC
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!