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

Unified 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: Final update with merge against current naclports.py Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ports/python_modules/numpy/modules.list ('k') | ports/python_modules/numpy/pkg_info » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ports/python_modules/numpy/nacl.patch
===================================================================
new file mode 100644
--- /dev/null
+++ b/ports/python_modules/numpy/nacl.patch
@@ -0,0 +1,174 @@
+diff --git a/numpy/core/code_generators/generate_numpy_api.py b/numpy/core/code_generators/generate_numpy_api.py
+index ce270a6..4094a56 100644
+--- a/numpy/core/code_generators/generate_numpy_api.py
++++ b/numpy/core/code_generators/generate_numpy_api.py
+@@ -111,14 +111,18 @@ _import_array(void)
+ }
+ #if NPY_BYTE_ORDER == NPY_BIG_ENDIAN
+ if (st != NPY_CPU_BIG) {
+- PyErr_Format(PyExc_RuntimeError, "FATAL: module compiled as "\
+- "big endian, but detected different endianness at runtime");
++ PyErr_Format(PyExc_RuntimeError, "FATAL: (for real) module compiled as "\
++ "big endian, but detected different endianness at runtime. "\
++ "(%%d %%d %%d) (%%d %%d)", st, (int) NPY_CPU_BIG, (int) NPY_CPU_LITTLE,
++ (int) NPY_BIG_ENDIAN, (int) NPY_LITTLE_ENDIAN);
+ return -1;
+ }
+ #elif NPY_BYTE_ORDER == NPY_LITTLE_ENDIAN
+ if (st != NPY_CPU_LITTLE) {
+- PyErr_Format(PyExc_RuntimeError, "FATAL: module compiled as "\
+- "little endian, but detected different endianness at runtime");
++ PyErr_Format(PyExc_RuntimeError, "FATAL: (for real) module compiled as "\
++ "little endian, but detected different endianness at runtime. " \
++ "(%%d %%d %%d) (%%d %%d)", st, (int) NPY_CPU_BIG, (int) NPY_CPU_LITTLE,
++ (int) NPY_BIG_ENDIAN, (int) NPY_LITTLE_ENDIAN);
+ return -1;
+ }
+ #endif
+diff --git a/numpy/core/include/numpy/npy_cpu.h b/numpy/core/include/numpy/npy_cpu.h
+index ab14731..86c48ac 100644
+--- a/numpy/core/include/numpy/npy_cpu.h
++++ b/numpy/core/include/numpy/npy_cpu.h
+@@ -27,7 +27,10 @@
+ * i386 by Sun compilers on opensolaris at least
+ */
+ #define NPY_CPU_X86
+-#elif defined(__x86_64__) || defined(__amd64__) || defined(__x86_64) || defined(_M_AMD64)
++/* For [P]NaCl toolchain, we need to define a CPU manually in order to ensure
++ * it has been defined at all. This only comes into play in a handful of
++ * places, but is necessary to generate any code at all. */
++#elif defined(__x86_64__) || defined(__amd64__) || defined(__x86_64) || defined(_M_AMD64) || defined (__native_client__)
+ /*
+ * both __x86_64__ and __amd64__ are defined by gcc
+ * __x86_64 defined by sun compiler on opensolaris at least
+diff --git a/numpy/core/setup.py b/numpy/core/setup.py
+index 28b15aa..a6c8513 100644
+--- a/numpy/core/setup.py
++++ b/numpy/core/setup.py
+@@ -288,7 +288,7 @@ def check_types(config_cmd, ext, build_dir):
+ "Cannot compile 'Python.h'. Perhaps you need to "\
+ "install python-dev|python-devel.")
+ res = config_cmd.check_header("endian.h")
+- if res:
++ if res and os.environ.get("NACL_PORT_BUILD") not in ["host", "bootstrap"]:
+ private_defines.append(('HAVE_ENDIAN_H', 1))
+ public_defines.append(('NPY_HAVE_ENDIAN_H', 1))
+
+@@ -465,7 +465,7 @@ def configuration(parent_package='',top_path=None):
+ 'MOTOROLA_EXTENDED_12_BYTES_BE',
+ 'IEEE_QUAD_LE', 'IEEE_QUAD_BE',
+ 'IEEE_DOUBLE_LE', 'IEEE_DOUBLE_BE',
+- 'DOUBLE_DOUBLE_BE']:
++ 'DOUBLE_DOUBLE_BE', "NO_LONG_DOUBLE"]:
+ moredefs.append(('HAVE_LDOUBLE_%s' % rep, 1))
+ else:
+ raise ValueError("Unrecognized long double format: %s" % rep)
+@@ -648,12 +648,13 @@ def configuration(parent_package='',top_path=None):
+ # explicitly add an extension which has generate_config_h and
+ # generate_numpyconfig_h as sources *before* adding npymath.
+
+- config.add_extension('_dummy',
+- sources = [join('src', 'dummymodule.c'),
+- generate_config_h,
+- generate_numpyconfig_h,
+- generate_numpy_api]
+- )
++ if os.environ.get("NACL_PORT_BUILD") != "bootstrap":
++ config.add_extension('_dummy',
++ sources = [join('src', 'dummymodule.c'),
++ generate_config_h,
++ generate_numpyconfig_h,
++ generate_numpy_api]
++ )
+
+ #######################################################################
+ # npymath library #
+diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
+index bad3607..1574d0d 100644
+--- a/numpy/core/setup_common.py
++++ b/numpy/core/setup_common.py
+@@ -3,6 +3,7 @@ from __future__ import division, absolute_import, print_function
+ # Code common to build tools
+ import sys
+ from os.path import join
++import os
+ import warnings
+ import copy
+ import binascii
+@@ -304,5 +305,7 @@ def long_double_representation(lines):
+ if saw is not None:
+ raise ValueError("Unrecognized format (%s)" % saw)
+ else:
++ if os.environ.get("NACL_PORT_BUILD") == "bootstrap":
++ return "NO_LONG_DOUBLE"
+ # We never detected the after_sequence
+ raise ValueError("Could not lock sequences (%s)" % saw)
+diff --git a/numpy/core/src/npymath/npy_math_private.h b/numpy/core/src/npymath/npy_math_private.h
+index 2bca6bf..9d35356 100644
+--- a/numpy/core/src/npymath/npy_math_private.h
++++ b/numpy/core/src/npymath/npy_math_private.h
+@@ -51,29 +51,27 @@
+ * fix this at some point */
+ #define IEEE_WORD_ORDER NPY_BYTE_ORDER
+
+-#if IEEE_WORD_ORDER == NPY_BIG_ENDIAN
++#if (IEEE_WORD_ORDER == NPY_LITTLE_ENDIAN) || defined(__native_client__)
+
+ typedef union
+ {
+ double value;
+ struct
+ {
+- npy_uint32 msw;
+ npy_uint32 lsw;
++ npy_uint32 msw;
+ } parts;
+ } ieee_double_shape_type;
+
+-#endif
+-
+-#if IEEE_WORD_ORDER == NPY_LITTLE_ENDIAN
++#elif IEEE_WORD_ORDER == NPY_BIG_ENDIAN
+
+ typedef union
+ {
+ double value;
+ struct
+ {
+- npy_uint32 lsw;
+ npy_uint32 msw;
++ npy_uint32 lsw;
+ } parts;
+ } ieee_double_shape_type;
+
+diff --git a/numpy/core/src/private/npy_fpmath.h b/numpy/core/src/private/npy_fpmath.h
+index 8a120ca..984bd65 100644
+--- a/numpy/core/src/private/npy_fpmath.h
++++ b/numpy/core/src/private/npy_fpmath.h
+@@ -7,6 +7,10 @@
+ #include "numpy/npy_cpu.h"
+ #include "numpy/npy_common.h"
+
++#ifdef __native_client__
++ #define HAVE_LDOUBLE_IEEE_DOUBLE_LE
++#endif
++
+ #ifdef NPY_OS_DARWIN
+ /* This hardcoded logic is fragile, but universal builds makes it
+ * difficult to detect arch-specific features */
+diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
+index f77e525..7bdaee6 100644
+--- a/numpy/distutils/misc_util.py
++++ b/numpy/distutils/misc_util.py
+@@ -2036,6 +2036,11 @@ def get_cmd(cmdname, _cache={}):
+
+ def get_numpy_include_dirs():
+ # numpy_include_dirs are set by numpy/core/setup.py, otherwise []
++ if os.environ.get("NACL_PORT_BUILD") == "dest":
++ # We fake our numpy includes when building on the destination.
++ base_path = os.environ["NACL_BUILD_TREE"]
++ return [os.path.join(base_path,
++ "lib/python2.7/site-packages/numpy/core/include")]
+ include_dirs = Configuration.numpy_include_dirs[:]
+ if not include_dirs:
+ import numpy
« no previous file with comments | « ports/python_modules/numpy/modules.list ('k') | ports/python_modules/numpy/pkg_info » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698