Bug 649023

Summary: python-devel on ppc64 requires "-m64" on gcc command line
Product: Red Hat Enterprise Linux 6 Reporter: Dave Malcolm <dmalcolm>
Component: pythonAssignee: Dave Malcolm <dmalcolm>
Status: CLOSED WONTFIX QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: medium Docs Contact:
Priority: low    
Version: 6.0CC: jgalipea, lockhart, sgallagh
Target Milestone: rc   
Target Release: ---   
Hardware: ppc64   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-11-02 21:24:58 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dave Malcolm 2010-11-02 19:02:50 UTC
Description of problem:
  $ rpm -q python python-libs python-devel gcc
  python-2.6.5-3.el6.ppc64
  python-libs-2.6.5-3.el6.ppc64
  python-libs-2.6.5-3.el6.ppc
  python-devel-2.6.5-3.el6.ppc64
  gcc-4.4.4-13.el6.ppc64

  $ cat test.c
  #include <Python.h>
  int main() {  return 0; }

Compiles OK on ppc64 with "-m64":
  $ gcc -m64 -I/usr/include/python2.6 test.c
  $ echo $?
  0

Fails without "-m64":
  $ gcc -I/usr/include/python2.6 test.c
  In file included from /usr/include/python2.6/Python.h:8,
                   from test.c:1:
  /usr/include/python2.6/pyconfig.h:4:25: error: pyconfig-32.h: No such file or directory

Version-Release number of selected component (if applicable):
  python-2.6.5-3.el6.ppc64
  python-libs-2.6.5-3.el6.ppc64
  python-libs-2.6.5-3.el6.ppc
  python-devel-2.6.5-3.el6.ppc64
  gcc-4.4.4-13.el6.ppc64
  glibc-headers-2.12-1.7.el6_0.3.ppc64

How reproducible:
100%

Steps to Reproduce:
As above
  
Additional info:
pyconfig.h is a downstream-modified copy in our RPMs:

#include <bits/wordsize.h>

#if __WORDSIZE == 32
#include "pyconfig-32.h"
#elif __WORDSIZE == 64
#include "pyconfig-64.h"
#else
#error "Unknown word size"
#endif


glibc-headers-2.12-1.7.el6_0.3.ppc64's /usr/include/bits/wordsize.h begins:
/* Determine the wordsize from the preprocessor defines.  */

#if defined __powerpc64__
# define __WORDSIZE	64
# define __WORDSIZE_COMPAT32	1
#else
# define __WORDSIZE	32
#endif

and this is coming out as "32" on ppc64 without -m64

Comment 2 Dave Malcolm 2010-11-02 19:29:09 UTC
$ rpm -qf /usr/lib/python2.6/config/Makefile
python-2.6.5-3.el6.ppc

/usr/lib/python2.6/config/Makefile has:
OPT=            -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -D_GNU_SOURCE -fPIC -fwrapv
BASECFLAGS=      -fno-strict-aliasing
CFLAGS=         $(BASECFLAGS) $(OPT) $(EXTRA_CFLAGS)

$ rpm -qf /usr/lib64/python2.6/config/Makefile
python-2.6.5-3.el6.ppc64

whereas /usr/lib64/python2.6/config/Makefile has:

OPT=            -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mminimal-toc -D_GNU_SOURCE -fPIC -fwrapv
BASECFLAGS=      -fno-strict-aliasing
CFLAGS=         $(BASECFLAGS) $(OPT) $(EXTRA_CFLAGS)

So a module using:
  distutils.sysconfig.get_config_vars("CFLAGS")
will work, but one using "BASECFLAGS" will fail on ppc64, unless "-m64" also is used (e.g. by setting CFLAGS).

It looks like rpmbuild on pp64 sets CFLAGS to a value that includes "-m64", so in theory this shouldn't be a problem.

Comment 4 Dave Malcolm 2010-11-02 19:40:26 UTC
Looks similar to bug 647413 (though that's python26.x86_64 on EPEL5)

Comment 7 Dave Malcolm 2010-11-02 21:22:22 UTC
We split pyconfig.h into pyconfig-32.h and pyconfig-64.h in order to allow both to be installed on 64-bit boxes (see bug 139911 and bug 192747).

We are relying on #include <bits/wordsize.h> setting __WORDSIZE to 32 or 64 as appropriate.  On ppc64 it appears that gcc requires -m64 to be passed on the command line, but I don't see a workaround for that without breaking the fix for bug 139911).

If there's a specific build scenario in which this fails, please open a bug.

Comment 8 RHEL Program Management 2010-11-02 21:24:58 UTC
Development Management has reviewed and declined this request.  You may appeal
this decision by reopening this request.