Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: ports/python_modules/numpy/nacl.patch

Issue 138913004: Build system for statically-linked Python. (Closed) Base URL: https://naclports.googlecode.com/svn/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 diff --git a/numpy/core/code_generators/generate_numpy_api.py b/numpy/core/code_ generators/generate_numpy_api.py
2 index ce270a6..4094a56 100644
3 --- a/numpy/core/code_generators/generate_numpy_api.py
4 +++ b/numpy/core/code_generators/generate_numpy_api.py
5 @@ -111,14 +111,18 @@ _import_array(void)
6 }
7 #if NPY_BYTE_ORDER == NPY_BIG_ENDIAN
8 if (st != NPY_CPU_BIG) {
9 - PyErr_Format(PyExc_RuntimeError, "FATAL: module compiled as "\
10 - "big endian, but detected different endianness at runtime");
11 + PyErr_Format(PyExc_RuntimeError, "FATAL: (for real) module compiled as "\
12 + "big endian, but detected different endianness at runtime. "\
13 + "(%%d %%d %%d) (%%d %%d)", st, (int) NPY_CPU_BIG, (int) NPY_CPU_LI TTLE,
14 + (int) NPY_BIG_ENDIAN, (int) NPY_LITTLE_ENDIAN);
15 return -1;
16 }
17 #elif NPY_BYTE_ORDER == NPY_LITTLE_ENDIAN
18 if (st != NPY_CPU_LITTLE) {
19 - PyErr_Format(PyExc_RuntimeError, "FATAL: module compiled as "\
20 - "little endian, but detected different endianness at runtime");
21 + PyErr_Format(PyExc_RuntimeError, "FATAL: (for real) module compiled as "\
22 + "little endian, but detected different endianness at runtime. " \
23 + "(%%d %%d %%d) (%%d %%d)", st, (int) NPY_CPU_BIG, (int) NPY_CPU_LI TTLE,
24 + (int) NPY_BIG_ENDIAN, (int) NPY_LITTLE_ENDIAN);
25 return -1;
26 }
27 #endif
28 diff --git a/numpy/core/include/numpy/npy_cpu.h b/numpy/core/include/numpy/npy_c pu.h
29 index ab14731..4f7c439 100644
30 --- a/numpy/core/include/numpy/npy_cpu.h
31 +++ b/numpy/core/include/numpy/npy_cpu.h
32 @@ -27,7 +27,7 @@
33 * i386 by Sun compilers on opensolaris at least
34 */
35 #define NPY_CPU_X86
36 -#elif defined(__x86_64__) || defined(__amd64__) || defined(__x86_64) || defined (_M_AMD64)
37 +#elif defined(__x86_64__) || defined(__amd64__) || defined(__x86_64) || defined (_M_AMD64) || defined (__native_client__)
38 /*
39 * both __x86_64__ and __amd64__ are defined by gcc
40 * __x86_64 defined by sun compiler on opensolaris at least
41 diff --git a/numpy/core/setup.py b/numpy/core/setup.py
42 index 28b15aa..b1210ef 100644
43 --- a/numpy/core/setup.py
44 +++ b/numpy/core/setup.py
45 @@ -288,7 +288,7 @@ def check_types(config_cmd, ext, build_dir):
46 "Cannot compile 'Python.h'. Perhaps you need to "\
47 "install python-dev|python-devel.")
48 res = config_cmd.check_header("endian.h")
49 - if res:
50 + if res and os.environ.get("NACL_PORT_BUILD", None) not in ["host", "bootstr ap"]:
51 private_defines.append(('HAVE_ENDIAN_H', 1))
52 public_defines.append(('NPY_HAVE_ENDIAN_H', 1))
53
54 @@ -465,7 +465,7 @@ def configuration(parent_package='',top_path=None):
55 'MOTOROLA_EXTENDED_12_BYTES_BE',
56 'IEEE_QUAD_LE', 'IEEE_QUAD_BE',
57 'IEEE_DOUBLE_LE', 'IEEE_DOUBLE_BE',
58 - 'DOUBLE_DOUBLE_BE']:
59 + 'DOUBLE_DOUBLE_BE', "NO_LONG_DOUBLE"]:
60 moredefs.append(('HAVE_LDOUBLE_%s' % rep, 1))
61 else:
62 raise ValueError("Unrecognized long double format: %s" % re p)
63 @@ -648,12 +648,13 @@ def configuration(parent_package='',top_path=None):
64 # explicitly add an extension which has generate_config_h and
65 # generate_numpyconfig_h as sources *before* adding npymath.
66
67 - config.add_extension('_dummy',
68 - sources = [join('src', 'dummymodule.c'),
69 - generate_config_h,
70 - generate_numpyconfig_h,
71 - generate_numpy_api]
72 - )
73 + if os.environ.get("NACL_PORT_BUILD", None) != "bootstrap":
74 + config.add_extension('_dummy',
75 + sources = [join('src', 'dummymodule.c'),
76 + generate_config_h,
77 + generate_numpyconfig_h,
78 + generate_numpy_api]
79 + )
80
81 #######################################################################
82 # npymath library #
83 diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
84 index bad3607..bac26c7 100644
85 --- a/numpy/core/setup_common.py
86 +++ b/numpy/core/setup_common.py
87 @@ -3,6 +3,7 @@ from __future__ import division, absolute_import, print_function
88 # Code common to build tools
89 import sys
90 from os.path import join
91 +import os
92 import warnings
93 import copy
94 import binascii
95 @@ -304,5 +305,7 @@ def long_double_representation(lines):
96 if saw is not None:
97 raise ValueError("Unrecognized format (%s)" % saw)
98 else:
99 + if os.environ.get("NACL_PORT_BUILD", None) == "bootstrap":
Sam Clegg 2014/01/22 01:46:50 nit: you can remove the second arg here as None is
Matthew Turk 2014/01/22 21:14:31 Done.
100 + return "NO_LONG_DOUBLE"
101 # We never detected the after_sequence
102 raise ValueError("Could not lock sequences (%s)" % saw)
103 diff --git a/numpy/core/src/npymath/npy_math_private.h b/numpy/core/src/npymath/ npy_math_private.h
104 index 2bca6bf..9d35356 100644
105 --- a/numpy/core/src/npymath/npy_math_private.h
106 +++ b/numpy/core/src/npymath/npy_math_private.h
107 @@ -51,29 +51,27 @@
108 * fix this at some point */
109 #define IEEE_WORD_ORDER NPY_BYTE_ORDER
110
111 -#if IEEE_WORD_ORDER == NPY_BIG_ENDIAN
112 +#if (IEEE_WORD_ORDER == NPY_LITTLE_ENDIAN) || defined(__native_client__)
113
114 typedef union
115 {
116 double value;
117 struct
118 {
119 - npy_uint32 msw;
120 npy_uint32 lsw;
121 + npy_uint32 msw;
122 } parts;
123 } ieee_double_shape_type;
124
125 -#endif
126 -
127 -#if IEEE_WORD_ORDER == NPY_LITTLE_ENDIAN
128 +#elif IEEE_WORD_ORDER == NPY_BIG_ENDIAN
129
130 typedef union
131 {
132 double value;
133 struct
134 {
135 - npy_uint32 lsw;
136 npy_uint32 msw;
137 + npy_uint32 lsw;
138 } parts;
139 } ieee_double_shape_type;
140
141 diff --git a/numpy/core/src/private/npy_fpmath.h b/numpy/core/src/private/npy_fp math.h
142 index 8a120ca..984bd65 100644
143 --- a/numpy/core/src/private/npy_fpmath.h
144 +++ b/numpy/core/src/private/npy_fpmath.h
145 @@ -7,6 +7,10 @@
146 #include "numpy/npy_cpu.h"
147 #include "numpy/npy_common.h"
148
149 +#ifdef __native_client__
150 + #define HAVE_LDOUBLE_IEEE_DOUBLE_LE
151 +#endif
152 +
153 #ifdef NPY_OS_DARWIN
154 /* This hardcoded logic is fragile, but universal builds makes it
155 * difficult to detect arch-specific features */
156 diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
157 index f77e525..c876136 100644
158 --- a/numpy/distutils/misc_util.py
159 +++ b/numpy/distutils/misc_util.py
160 @@ -2036,6 +2036,11 @@ def get_cmd(cmdname, _cache={}):
161
162 def get_numpy_include_dirs():
163 # numpy_include_dirs are set by numpy/core/setup.py, otherwise []
164 + if os.environ.get("NACL_PORT_BUILD", None) == "dest":
165 + # We fake our numpy includes when building on the destination.
166 + base_path = os.environ["NACL_BUILD_TREE"]
167 + return [os.path.join(base_path,
168 + "lib/python2.7/site-packages/numpy/core/include")]
169 include_dirs = Configuration.numpy_include_dirs[:]
170 if not include_dirs:
171 import numpy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698