Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | Author: Andrei Gherzan <andrei@gherzan.ro> |
| 2 | Date: Sun Mar 25 02:02:27 2012 +0200 |
| 3 | |
| 4 | This patch was added for 64bit host machines. In the compile process python |
| 5 | is checking if platform is a 64bit platform using sys.maxint which is the host's |
| 6 | value. The patch fixes this issue so that python would check if TARGET machine |
| 7 | is 64bit not the HOST machine. In this way will have "dl" and "imageop" modules |
| 8 | built if HOST machine is 64bit but the target machine is 32bit. |
| 9 | |
| 10 | Signed-off-by: Andrei Gherzan <andrei@gherzan.ro> |
| 11 | |
| 12 | Upstream-Status: Pending |
| 13 | |
| 14 | Index: Python-2.7.2/setup.py |
| 15 | =================================================================== |
| 16 | --- Python-2.7.2.orig/setup.py 2012-03-25 01:10:41.540163187 +0200 |
| 17 | +++ Python-2.7.2/setup.py 2012-03-25 01:26:06.092539990 +0200 |
| 18 | @@ -23,6 +23,21 @@ |
| 19 | # 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' |
| 40 | @@ -628,7 +643,7 @@ |
| 41 | exts.append( Extension('audioop', ['audioop.c']) ) |
| 42 | |
| 43 | # Disabled on 64-bit platforms |
| 44 | - if sys.maxint != 9223372036854775807L: |
| 45 | + if not target_is_64bit_platform(): |
| 46 | # Operations on images |
| 47 | exts.append( Extension('imageop', ['imageop.c']) ) |
| 48 | else: |
| 49 | @@ -1418,7 +1433,7 @@ |
| 50 | 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) |
| 57 | if (dl_inc is not None) and (platform not in ['atheos']): |