Bug 1046350

Summary: libvirt-python: C modules fail to build on Mac (OS X)
Product: [Community] Virtualization Tools Reporter: Shanto <shanto>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: crobinso, rbalakri
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Mac OS   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-04-10 17:27:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Shanto 2013-12-24 19:21:00 UTC
Description of problem:
libvirt-python package from PyPI fails to build on OS X 10.9.

Version-Release number of selected component (if applicable):
1.2.0

How reproducible:
Installing libvirt-python from pip.

Steps to Reproduce:
1. (sudo) port install libvirt # MacPorts
2. pip install libvirt-python

Actual results:
./libvirt-utils.h:87:22: error: token is not a valid binary operator in a preprocessor subexpression
#   if __GNUC_PREREQ (3, 3)
       ~~~~~~~~~~~~~ ^
./libvirt-utils.h:99:22: error: token is not a valid binary operator in a preprocessor subexpression
#   if __GNUC_PREREQ (3, 4)
       ~~~~~~~~~~~~~ ^
2 errors generated.
error: command '/usr/bin/clang' failed with exit status 1

Expected results:
C modules in libvirt-python should compile and install properly.

Additional information:
__GNUC_PREREQ macro is not defined in OS X. Some developers use alternative method to detect GNU C version as follows:

#define __GNUC_VERSION__ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
#if __GNUC_VERSION__ >= 30400
# ...features...
#endif

Comment 1 Cole Robinson 2016-04-10 17:27:19 UTC
This was fixed by:

commit c6ff569fb6a535cb625cd99d22052f756eae5b56
Author: Doug Goldstein <cardoe>
Date:   Sun Dec 29 16:52:15 2013 -0600

    define __GNUC_PREREQ macro before using it
    
    We brought over use of the __GNUC_PREREQ macro from libvirt but didn't
    bring over the definition of it. This brings over the macro from libvirt
    sources.