blob: e6d6c65bbe4204f9a4aba180c61f143ed402ed7f [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001Author: Andrei Gherzan <andrei@gherzan.ro>
2Date: Sun Mar 25 02:02:27 2012 +0200
3
4This patch was added for 64bit host machines. In the compile process python
5is checking if platform is a 64bit platform using sys.maxint which is the host's
6value. The patch fixes this issue so that python would check if TARGET machine
7is 64bit not the HOST machine. In this way will have "dl" and "imageop" modules
8built if HOST machine is 64bit but the target machine is 32bit.
9
10Signed-off-by: Andrei Gherzan <andrei@gherzan.ro>
11
12Upstream-Status: Pending
13
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050014Index: Python-2.7.11/setup.py
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015===================================================================
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050016--- Python-2.7.11.orig/setup.py
17+++ Python-2.7.11/setup.py
18@@ -35,6 +35,21 @@ COMPILED_WITH_PYDEBUG = ('--with-pydebug
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019 # This global variable is used to hold the list of modules to be disabled.
20 disabled_module_list = []
21
22+def target_is_64bit_platform ():
23+ """
24+ In case of cross-compile, some modules are not build as setup checks if HOST
25+ is 64bit and not TARGET.
26+ As python was built for TARGET we can check this in pyconfig.h in this way:
27+ Sizeof LONG on a 32 bit platform is 4 bytes
28+ Sizeof LONG on a 64 bit platform is 8 bytes
29+ """
30+ pyconf = open("pyconfig.h").read()
31+ aux = re.search(r"#s*define\s+SIZEOF_LONG\s+8\s*", pyconf)
32+ if aux is not None:
33+ return True
34+ else:
35+ return False
36+
37 def add_dir_to_list(dirlist, dir):
38 """Add the directory 'dir' to the list 'dirlist' (at the front) if
39 1) 'dir' is not already in 'dirlist'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050040@@ -716,7 +731,7 @@ class PyBuildExt(build_ext):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041 exts.append( Extension('audioop', ['audioop.c']) )
42
43 # Disabled on 64-bit platforms
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050044- if sys.maxsize != 9223372036854775807L:
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045+ if not target_is_64bit_platform():
46 # Operations on images
47 exts.append( Extension('imageop', ['imageop.c']) )
48 else:
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050049@@ -1545,7 +1560,7 @@ class PyBuildExt(build_ext):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050 missing.append('_codecs_%s' % loc)
51
52 # Dynamic loading module
53- if sys.maxint == 0x7fffffff:
54+ if not target_is_64bit_platform():
55 # This requires sizeof(int) == sizeof(long) == sizeof(char*)
56 dl_inc = find_file('dlfcn.h', [], inc_dirs)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050057 if (dl_inc is not None) and (host_platform not in ['atheos']):