Index: ports/python_modules/python-host/nacl.patch |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/ports/python_modules/python-host/nacl.patch |
@@ -0,0 +1,627 @@ |
+diff --git a/Include/datetime.h b/Include/datetime.h |
+index 47abe5c..4884e79 100644 |
+--- a/Include/datetime.h |
++++ b/Include/datetime.h |
+@@ -166,6 +166,8 @@ typedef struct { |
+ |
+ #ifdef Py_BUILD_CORE |
+ |
++#define PyDataTime_STATIC 1 |
++ |
+ /* Macros for type checking when building the Python core. */ |
+ #define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType) |
+ #define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType) |
+diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py |
+index 2aa1cb1..e90c38f 100644 |
+--- a/Lib/distutils/unixccompiler.py |
++++ b/Lib/distutils/unixccompiler.py |
+@@ -286,3 +286,42 @@ class UnixCCompiler(CCompiler): |
+ |
+ # Oops, didn't find it in *any* of 'dirs' |
+ return None |
++ |
++# Thanks to the GPAW project for this function. |
++def _link_shared_object (self, |
++ objects, |
++ output_filename, |
++ output_dir=None, |
++ libraries=None, |
++ library_dirs=None, |
++ runtime_library_dirs=None, |
++ export_symbols=None, |
++ debug=0, |
++ extra_preargs=None, |
++ extra_postargs=None, |
++ build_temp=None, |
++ target_lang=None): |
++ |
++ if output_dir is None: |
++ (output_dir, output_filename) = os.path.split(output_filename) |
++ output_fullname = os.path.join(output_dir, output_filename) |
++ output_fullname = os.path.abspath(output_fullname) |
++ linkline = "%s %s" % (output_filename[:-2], output_fullname) |
++ for l in library_dirs: |
++ linkline += " -L" + l |
++ for l in libraries: |
++ linkline += " -l" + l |
++ old_fmt = self.static_lib_format |
++ self.static_lib_format = "%s%.0s" |
++ self.create_static_lib(objects, |
++ output_filename, |
++ output_dir, |
++ debug, |
++ target_lang) |
++ |
++ self.static_lib_format = old_fmt |
++ |
++# Only override when the NACL_SDK_ROOT |
++import os |
++if os.environ.get("NACL_PORT_BUILD", None) in ["dest", "bootstrap"]: |
++ UnixCCompiler.link_shared_object = _link_shared_object |
+diff --git a/Makefile.pre.in b/Makefile.pre.in |
+index 9d55550..09e7a69 100644 |
+--- a/Makefile.pre.in |
++++ b/Makefile.pre.in |
+@@ -592,14 +592,18 @@ Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule |
+ |
+ $(GRAMMAR_H): $(GRAMMAR_INPUT) $(PGENSRCS) |
+ @$(MKDIR_P) Include |
++ifndef CROSS_COMPILE |
+ $(MAKE) $(PGEN) |
++endif |
+ $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) |
+ $(GRAMMAR_C): $(GRAMMAR_H) $(GRAMMAR_INPUT) $(PGENSRCS) |
+ $(MAKE) $(GRAMMAR_H) |
+ touch $(GRAMMAR_C) |
+ |
++ifndef CROSS_COMPILE |
+ $(PGEN): $(PGENOBJS) |
+ $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN) |
++endif |
+ |
+ Parser/grammar.o: $(srcdir)/Parser/grammar.c \ |
+ $(srcdir)/Include/token.h \ |
+@@ -1000,6 +1004,7 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c |
+ $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \ |
+ $(DESTDIR)$(LIBDEST)/distutils/tests ; \ |
+ fi |
++ifndef CROSS_COMPILE |
+ PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ |
+ $(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ |
+ -d $(LIBDEST) -f \ |
+@@ -1018,6 +1023,7 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c |
+ $(PYTHON_FOR_BUILD) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ |
+ -d $(LIBDEST)/site-packages -f \ |
+ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages |
++endif |
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ |
+ $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt |
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ |
+diff --git a/Modules/_ctypes/libffi/configure b/Modules/_ctypes/libffi/configure |
+index 8230830..1ab4dcb 100755 |
+--- a/Modules/_ctypes/libffi/configure |
++++ b/Modules/_ctypes/libffi/configure |
+@@ -13393,7 +13393,7 @@ case "$host" in |
+ TARGETDIR=x86 |
+ if test $ac_cv_sizeof_size_t = 4; then |
+ case "$host" in |
+- *-gnux32) |
++ *-gnux32 | *-nacl) |
+ TARGET=X86_64 |
+ ;; |
+ *) |
+diff --git a/Modules/_ctypes/libffi/src/x86/ffi64.c b/Modules/_ctypes/libffi/src/x86/ffi64.c |
+index 2014af2..cacf894 100644 |
+--- a/Modules/_ctypes/libffi/src/x86/ffi64.c |
++++ b/Modules/_ctypes/libffi/src/x86/ffi64.c |
+@@ -202,10 +202,12 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[], |
+ case FFI_TYPE_DOUBLE: |
+ classes[0] = X86_64_SSEDF_CLASS; |
+ return 1; |
++#if FFI_TYPE_DOUBLE != FFI_TYPE_LONGDOUBLE |
+ case FFI_TYPE_LONGDOUBLE: |
+ classes[0] = X86_64_X87_CLASS; |
+ classes[1] = X86_64_X87UP_CLASS; |
+ return 2; |
++#endif |
+ case FFI_TYPE_STRUCT: |
+ { |
+ const int UNITS_PER_WORD = 8; |
+diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c |
+index b0386f0..a5c77b4 100644 |
+--- a/Modules/_testcapimodule.c |
++++ b/Modules/_testcapimodule.c |
+@@ -1278,6 +1278,9 @@ static int test_run_counter = 0; |
+ |
+ static PyObject * |
+ test_datetime_capi(PyObject *self, PyObject *args) { |
++#ifdef PyDataTime_STATIC |
++ Py_RETURN_NONE; |
++#else |
+ if (PyDateTimeAPI) { |
+ if (test_run_counter) { |
+ /* Probably regrtest.py -R */ |
+@@ -1295,6 +1298,7 @@ test_datetime_capi(PyObject *self, PyObject *args) { |
+ Py_RETURN_NONE; |
+ else |
+ return NULL; |
++#endif |
+ } |
+ |
+ |
+diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c |
+index 65ade9f..1a971dc 100644 |
+--- a/Modules/posixmodule.c |
++++ b/Modules/posixmodule.c |
+@@ -663,9 +663,13 @@ posix_error_with_unicode_filename(Py_UNICODE* name) |
+ |
+ |
+ static PyObject * |
+-posix_error_with_allocated_filename(char* name) |
++posix_error_with_allocated_filename(const char* func, char* name) |
+ { |
+- PyObject *rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); |
++ PyObject *rc; |
++ if (errno == ENOSYS) |
++ rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError, func); |
++ else |
++ rc = PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); |
+ PyMem_Free(name); |
+ return rc; |
+ } |
+@@ -826,7 +830,7 @@ posix_1str(PyObject *args, char *format, int (*func)(const char*)) |
+ res = (*func)(path1); |
+ Py_END_ALLOW_THREADS |
+ if (res < 0) |
+- return posix_error_with_allocated_filename(path1); |
++ return posix_error_with_allocated_filename(format, path1); |
+ PyMem_Free(path1); |
+ Py_INCREF(Py_None); |
+ return Py_None; |
+@@ -1859,7 +1863,7 @@ posix_chmod(PyObject *self, PyObject *args) |
+ res = chmod(path, i); |
+ Py_END_ALLOW_THREADS |
+ if (res < 0) |
+- return posix_error_with_allocated_filename(path); |
++ return posix_error_with_allocated_filename("chmod", path); |
+ PyMem_Free(path); |
+ Py_INCREF(Py_None); |
+ return Py_None; |
+@@ -1906,7 +1910,7 @@ posix_lchmod(PyObject *self, PyObject *args) |
+ res = lchmod(path, i); |
+ Py_END_ALLOW_THREADS |
+ if (res < 0) |
+- return posix_error_with_allocated_filename(path); |
++ return posix_error_with_allocated_filename("lchmod", path); |
+ PyMem_Free(path); |
+ Py_RETURN_NONE; |
+ } |
+@@ -1931,7 +1935,7 @@ posix_chflags(PyObject *self, PyObject *args) |
+ res = chflags(path, flags); |
+ Py_END_ALLOW_THREADS |
+ if (res < 0) |
+- return posix_error_with_allocated_filename(path); |
++ return posix_error_with_allocated_filename("chflags", path); |
+ PyMem_Free(path); |
+ Py_INCREF(Py_None); |
+ return Py_None; |
+@@ -1957,7 +1961,7 @@ posix_lchflags(PyObject *self, PyObject *args) |
+ res = lchflags(path, flags); |
+ Py_END_ALLOW_THREADS |
+ if (res < 0) |
+- return posix_error_with_allocated_filename(path); |
++ return posix_error_with_allocated_filename("lchflags", path); |
+ PyMem_Free(path); |
+ Py_INCREF(Py_None); |
+ return Py_None; |
+@@ -2028,7 +2032,7 @@ posix_chown(PyObject *self, PyObject *args) |
+ res = chown(path, uid, gid); |
+ Py_END_ALLOW_THREADS |
+ if (res < 0) |
+- return posix_error_with_allocated_filename(path); |
++ return posix_error_with_allocated_filename("chown", path); |
+ PyMem_Free(path); |
+ Py_INCREF(Py_None); |
+ return Py_None; |
+@@ -2083,7 +2087,7 @@ posix_lchown(PyObject *self, PyObject *args) |
+ res = lchown(path, uid, gid); |
+ Py_END_ALLOW_THREADS |
+ if (res < 0) |
+- return posix_error_with_allocated_filename(path); |
++ return posix_error_with_allocated_filename("lchown", path); |
+ PyMem_Free(path); |
+ Py_INCREF(Py_None); |
+ return Py_None; |
+@@ -2478,7 +2482,7 @@ posix_listdir(PyObject *self, PyObject *args) |
+ dirp = opendir(name); |
+ Py_END_ALLOW_THREADS |
+ if (dirp == NULL) { |
+- return posix_error_with_allocated_filename(name); |
++ return posix_error_with_allocated_filename("listdir", name); |
+ } |
+ if ((d = PyList_New(0)) == NULL) { |
+ Py_BEGIN_ALLOW_THREADS |
+@@ -2500,7 +2504,7 @@ posix_listdir(PyObject *self, PyObject *args) |
+ closedir(dirp); |
+ Py_END_ALLOW_THREADS |
+ Py_DECREF(d); |
+- return posix_error_with_allocated_filename(name); |
++ return posix_error_with_allocated_filename("listdir", name); |
+ } |
+ } |
+ if (ep->d_name[0] == '.' && |
+@@ -2660,7 +2664,7 @@ posix_mkdir(PyObject *self, PyObject *args) |
+ #endif |
+ Py_END_ALLOW_THREADS |
+ if (res < 0) |
+- return posix_error_with_allocated_filename(path); |
++ return posix_error_with_allocated_filename("mkdir", path); |
+ PyMem_Free(path); |
+ Py_INCREF(Py_None); |
+ return Py_None; |
+@@ -3059,7 +3063,7 @@ done: |
+ #endif /* HAVE_UTIMES */ |
+ } |
+ if (res < 0) { |
+- return posix_error_with_allocated_filename(path); |
++ return posix_error_with_allocated_filename("utime", path); |
+ } |
+ PyMem_Free(path); |
+ Py_INCREF(Py_None); |
+@@ -6286,7 +6290,7 @@ posix_readlink(PyObject *self, PyObject *args) |
+ n = readlink(path, buf, (int) sizeof buf); |
+ Py_END_ALLOW_THREADS |
+ if (n < 0) |
+- return posix_error_with_allocated_filename(path); |
++ return posix_error_with_allocated_filename("readlink", path); |
+ |
+ PyMem_Free(path); |
+ v = PyString_FromStringAndSize(buf, n); |
+@@ -6532,7 +6536,7 @@ posix_open(PyObject *self, PyObject *args) |
+ PyErr_Clear(); |
+ #endif |
+ |
+- if (!PyArg_ParseTuple(args, "eti|i", |
++ if (!PyArg_ParseTuple(args, "eti|i:open", |
+ Py_FileSystemDefaultEncoding, &file, |
+ &flag, &mode)) |
+ return NULL; |
+@@ -6541,7 +6545,7 @@ posix_open(PyObject *self, PyObject *args) |
+ fd = open(file, flag, mode); |
+ Py_END_ALLOW_THREADS |
+ if (fd < 0) |
+- return posix_error_with_allocated_filename(file); |
++ return posix_error_with_allocated_filename("open", file); |
+ PyMem_Free(file); |
+ return PyInt_FromLong((long)fd); |
+ } |
+diff --git a/Modules/pwdmodule.c b/Modules/pwdmodule.c |
+index c2907f6..faa3ad6 100644 |
+--- a/Modules/pwdmodule.c |
++++ b/Modules/pwdmodule.c |
+@@ -94,6 +94,29 @@ mkpwent(struct passwd *p) |
+ return v; |
+ } |
+ |
++#ifdef __native_client__ |
++// python relies on a working version of getpwuid(3) |
++// which Native Client does not yet provide. |
++// TODO(sbc): This should only really be needed when |
++// building for the sel_ldr. It should be possible to |
++// use the C-library version (which tries of open files |
++// under /etc) when using nacl_io. |
++static struct passwd *my_getpwuid(uid_t uid) |
++{ |
++ static struct passwd dummy = { |
++ "nacl_user", |
++ "nacl_pass", |
++ 1, |
++ 1, |
++ "NaCl User", |
++ "/home/nacl_user", |
++ "/bin/sh", |
++ }; |
++ return &dummy; |
++} |
++#define getpwuid my_getpwuid |
++#endif |
++ |
+ PyDoc_STRVAR(pwd_getpwuid__doc__, |
+ "getpwuid(uid) -> (pw_name,pw_passwd,pw_uid,\n\ |
+ pw_gid,pw_gecos,pw_dir,pw_shell)\n\ |
+diff --git a/Modules/python.c b/Modules/python.c |
+index 2739b8b..5a5b753 100644 |
+--- a/Modules/python.c |
++++ b/Modules/python.c |
+@@ -6,6 +6,19 @@ |
+ #include <floatingpoint.h> |
+ #endif |
+ |
++#ifdef __native_client__ |
++#include <stdio.h> |
++#include <sys/utsname.h> |
++ |
++// Dummy implementation of uname. This is only needed for the sel_ldr |
++// version of python. Otherwise it gets provided by nacl_io. |
++int uname(struct utsname *buf) |
++{ |
++ sprintf(buf->sysname, "NaCl"); |
++ return 0; |
++} |
++#endif |
++ |
+ int |
+ main(int argc, char **argv) |
+ { |
+@@ -20,5 +33,9 @@ main(int argc, char **argv) |
+ m = fpgetmask(); |
+ fpsetmask(m & ~FP_X_OFL); |
+ #endif |
++#ifdef __native_client__ |
++ setvbuf(stdout, NULL, _IOLBF, 0); |
++ setvbuf(stdin, NULL, _IOLBF, 0); |
++#endif |
+ return Py_Main(argc, argv); |
+ } |
+diff --git a/Modules/timemodule.c b/Modules/timemodule.c |
+index 12c43b0..b727afa 100644 |
+--- a/Modules/timemodule.c |
++++ b/Modules/timemodule.c |
+@@ -34,6 +34,11 @@ extern int ftime(struct timeb *); |
+ #endif /* MS_WINDOWS */ |
+ #endif /* HAVE_FTIME */ |
+ |
++#if defined(__native_client__) && !defined(__GLIBC__) |
++#define timezone _timezone |
++#define daylight _daylight |
++#endif |
++ |
+ #if defined(__WATCOMC__) && !defined(__QNX__) |
+ #include <i86.h> |
+ #else |
+diff --git a/Python/dynload_shlib.c b/Python/dynload_shlib.c |
+index 17ebab1..93ea45d 100644 |
+--- a/Python/dynload_shlib.c |
++++ b/Python/dynload_shlib.c |
+@@ -84,6 +84,11 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, |
+ PyOS_snprintf(funcname, sizeof(funcname), |
+ LEAD_UNDERSCORE "init%.200s", shortname); |
+ |
++ |
++/* Native Client's fstat() imlemenation doesn't set st_dev |
++ * and st_ino correctly so disable the dlopen handle cache. |
++ * TODO(sbc): fix NaCl's fstat() */ |
++#ifndef __native_client__ |
+ if (fp != NULL) { |
+ int i; |
+ struct stat statb; |
+@@ -107,6 +112,7 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, |
+ #endif |
+ } |
+ } |
++#endif |
+ |
+ #if !(defined(PYOS_OS2) && defined(PYCC_GCC)) |
+ dlopenflags = PyThreadState_GET()->interp->dlopenflags; |
+diff --git a/Python/getversion.c b/Python/getversion.c |
+index 7bd6efd..b4f6702 100644 |
+--- a/Python/getversion.c |
++++ b/Python/getversion.c |
+@@ -8,8 +8,8 @@ |
+ const char * |
+ Py_GetVersion(void) |
+ { |
+- static char version[250]; |
+- PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.80s", |
++ static char version[270]; |
++ PyOS_snprintf(version, sizeof(version), "%.80s (%.80s) %.100s", |
+ PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler()); |
+ return version; |
+ } |
+diff --git a/Python/thread.c b/Python/thread.c |
+index dd333e8..33fec81 100644 |
+--- a/Python/thread.c |
++++ b/Python/thread.c |
+@@ -14,9 +14,19 @@ |
+ library (e.g. gnu pth in pthread emulation) */ |
+ # ifdef HAVE_PTHREAD_H |
+ # include <pthread.h> /* _POSIX_THREADS */ |
++# if defined __native_client__ && !defined __GLIBC__ |
++ /* Under NaCl newlib neither pthread.h nor unistd.h defines _POSIX_THREADS. |
++ However this file expects it to be defined if pthreads are present so we |
++ define it here after including pthread.h |
++ TODO(sbc): remove this hack once newlib is fixed: |
++ https://code.google.com/p/nativeclient/issues/detail?id=3551 |
++ */ |
++# define _POSIX_THREADS |
++# endif |
+ # endif |
+ #endif |
+ |
++ |
+ #ifndef DONT_HAVE_STDIO_H |
+ #include <stdio.h> |
+ #endif |
+diff --git a/configure b/configure |
+index dc0dfd0..d45f7b0 100755 |
+--- a/configure |
++++ b/configure |
+@@ -2853,19 +2853,26 @@ if test "$cross_compiling" = yes; then |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for python interpreter for cross build" >&5 |
+ $as_echo_n "checking for python interpreter for cross build... " >&6; } |
+ if test -z "$PYTHON_FOR_BUILD"; then |
+- for interp in python$PACKAGE_VERSION python2 python; do |
+- which $interp >/dev/null 2>&1 || continue |
+- if $interp -c 'import sys;sys.exit(not (sys.version_info[:2] >= (2,7) and sys.version_info[0] < 3))'; then |
+- break |
+- fi |
+- interp= |
+- done |
++ case "$host" in |
++ *-*-nacl*) |
++ interp=$(cd ../build-nacl-host && pwd)/python |
++ ;; |
++ *) |
++ for interp in python$PACKAGE_VERSION python2 python; do |
++ which $interp >/dev/null 2>&1 || continue |
++ if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then |
++ break |
++ fi |
++ interp= |
++ done |
++ ;; |
++ esac |
+ if test x$interp = x; then |
+ as_fn_error $? "python$PACKAGE_VERSION interpreter not found" "$LINENO" 5 |
+ fi |
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $interp" >&5 |
+ $as_echo "$interp" >&6; } |
+- PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp |
++ PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(abs_srcdir)/Lib:$(abs_srcdir)/Lib/plat-$(MACHDEP) '$interp |
+ fi |
+ elif test "$cross_compiling" = maybe; then |
+ as_fn_error $? "Cross compiling required --host=HOST-TUPLE and --build=ARCH" "$LINENO" 5 |
+@@ -3168,6 +3175,9 @@ then |
+ # `define_xopen_source' in the case statement below. For the |
+ # current supported cross builds, this macro is not adjusted. |
+ case "$host" in |
++ *-*-nacl*) |
++ ac_sys_system=NaCl |
++ ;; |
+ *-*-linux*) |
+ ac_sys_system=Linux |
+ ;; |
+@@ -3217,6 +3227,15 @@ if test "$cross_compiling" = yes; then |
+ _host_cpu=$host_cpu |
+ esac |
+ ;; |
++ *-*-nacl*) |
++ case "$host_cpu" in |
++ arm*) |
++ _host_cpu=arm |
++ ;; |
++ *) |
++ _host_cpu=$host_cpu |
++ esac |
++ ;; |
+ *-*-cygwin*) |
+ _host_cpu= |
+ ;; |
+@@ -8246,7 +8265,7 @@ then |
+ fi |
+ fi |
+ ;; |
+- Linux*|GNU*|QNX*) |
++ Linux*|GNU*|QNX*|NaCl*) |
+ LDSHARED='$(CC) -shared' |
+ LDCXXSHARED='$(CXX) -shared';; |
+ BSD/OS*/4*) |
+@@ -8320,7 +8339,7 @@ then |
+ then CCSHARED="-fPIC"; |
+ else CCSHARED="+z"; |
+ fi;; |
+- Linux*|GNU*) CCSHARED="-fPIC";; |
++ Linux*|GNU*|NaCl*) CCSHARED="-fPIC";; |
+ BSD/OS*/4*) CCSHARED="-fpic";; |
+ FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";; |
+ OpenUNIX*|UnixWare*) |
+@@ -8354,7 +8373,7 @@ then |
+ LINKFORSHARED="-Wl,-E -Wl,+s";; |
+ # LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; |
+ BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";; |
+- Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; |
++ Linux*|GNU*|NaCl*) LINKFORSHARED="-Xlinker -export-dynamic";; |
+ # -u libsys_s pulls in all symbols in libsys |
+ Darwin/*) |
+ # -u _PyMac_Error is needed to pull in the mac toolbox glue, |
+diff --git a/configure.ac b/configure.ac |
+index 30f5bf4..4a8f64c 100644 |
+--- a/configure.ac |
++++ b/configure.ac |
+@@ -19,18 +19,25 @@ AC_SUBST(host) |
+ if test "$cross_compiling" = yes; then |
+ AC_MSG_CHECKING([for python interpreter for cross build]) |
+ if test -z "$PYTHON_FOR_BUILD"; then |
+- for interp in python$PACKAGE_VERSION python2 python; do |
+- which $interp >/dev/null 2>&1 || continue |
+- if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then |
+- break |
+- fi |
+- interp= |
+- done |
++ case "$host" in |
++ *-*-nacl*) |
++ interp=$(cd ../build-nacl-host && pwd)/python |
++ ;; |
++ *) |
++ for interp in python$PACKAGE_VERSION python2 python; do |
++ which $interp >/dev/null 2>&1 || continue |
++ if $interp -c 'import sys;sys.exit(not (sys.version_info@<:@:2@:>@ >= (2,7) and sys.version_info@<:@0@:>@ < 3))'; then |
++ break |
++ fi |
++ interp= |
++ done |
++ ;; |
++ esac |
+ if test x$interp = x; then |
+ AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found]) |
+ fi |
+ AC_MSG_RESULT($interp) |
+- PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/plat-$(MACHDEP) '$interp |
++ PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(abs_srcdir)/Lib:$(abs_srcdir)/Lib/plat-$(MACHDEP) '$interp |
+ fi |
+ elif test "$cross_compiling" = maybe; then |
+ AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH]) |
+@@ -318,6 +325,9 @@ then |
+ *-*-cygwin*) |
+ ac_sys_system=Cygwin |
+ ;; |
++ *-*-nacl*) |
++ ac_sys_system=NaCl |
++ ;; |
+ *) |
+ # for now, limit cross builds to known configurations |
+ MACHDEP="unknown" |
+@@ -361,6 +371,15 @@ if test "$cross_compiling" = yes; then |
+ _host_cpu=$host_cpu |
+ esac |
+ ;; |
++ *-*-nacl*) |
++ case "$host_cpu" in |
++ arm*) |
++ _host_cpu=arm |
++ ;; |
++ *) |
++ _host_cpu=$host_cpu |
++ esac |
++ ;; |
+ *-*-cygwin*) |
+ _host_cpu= |
+ ;; |
+@@ -2024,7 +2043,7 @@ then |
+ fi |
+ fi |
+ ;; |
+- Linux*|GNU*|QNX*) |
++ Linux*|GNU*|QNX*|NaCl*) |
+ LDSHARED='$(CC) -shared' |
+ LDCXXSHARED='$(CXX) -shared';; |
+ BSD/OS*/4*) |
+@@ -2096,7 +2115,7 @@ then |
+ then CCSHARED="-fPIC"; |
+ else CCSHARED="+z"; |
+ fi;; |
+- Linux*|GNU*) CCSHARED="-fPIC";; |
++ Linux*|GNU*|NaCl*) CCSHARED="-fPIC";; |
+ BSD/OS*/4*) CCSHARED="-fpic";; |
+ FreeBSD*|NetBSD*|OpenBSD*|DragonFly*) CCSHARED="-fPIC";; |
+ OpenUNIX*|UnixWare*) |
+@@ -2128,7 +2147,7 @@ then |
+ LINKFORSHARED="-Wl,-E -Wl,+s";; |
+ # LINKFORSHARED="-Wl,-E -Wl,+s -Wl,+b\$(BINLIBDEST)/lib-dynload";; |
+ BSD/OS/4*) LINKFORSHARED="-Xlinker -export-dynamic";; |
+- Linux*|GNU*) LINKFORSHARED="-Xlinker -export-dynamic";; |
++ Linux*|GNU*|NaCl*) LINKFORSHARED="-Xlinker -export-dynamic";; |
+ # -u libsys_s pulls in all symbols in libsys |
+ Darwin/*) |
+ # -u _PyMac_Error is needed to pull in the mac toolbox glue, |