Author: Maciej Fijalkowski <[email protected]>
Branch: numpypy-out
Changeset: r53997:e43ad1eda2c5
Date: 2012-03-26 18:53 +0200
http://bitbucket.org/pypy/pypy/changeset/e43ad1eda2c5/
Log: merge default
diff --git a/pypy/doc/discussion/win64_todo.txt
b/pypy/doc/discussion/win64_todo.txt
new file mode 100644
--- /dev/null
+++ b/pypy/doc/discussion/win64_todo.txt
@@ -0,0 +1,9 @@
+2011-11-04
+ll_os.py has a problem with the file rwin32.py.
+Temporarily disabled for the win64_gborg branch. This needs to be
+investigated and re-enabled.
+Resolved, enabled.
+
+2011-11-05
+test_typed.py needs explicit tests to ensure that we
+handle word sizes right.
\ No newline at end of file
diff --git a/pypy/doc/windows.rst b/pypy/doc/windows.rst
--- a/pypy/doc/windows.rst
+++ b/pypy/doc/windows.rst
@@ -18,7 +18,8 @@
Edition. Other configurations may work as well.
The translation scripts will set up the appropriate environment variables
-for the compiler. They will attempt to locate the same compiler version that
+for the compiler, so you do not need to run vcvars before translation.
+They will attempt to locate the same compiler version that
was used to build the Python interpreter doing the
translation. Failing that, they will pick the most recent Visual Studio
compiler they can find. In addition, the target architecture
@@ -26,7 +27,7 @@
using a 32 bit Python and vice versa.
**Note:** PyPy is currently not supported for 64 bit Windows, and translation
-will be aborted in this case.
+will fail in this case.
The compiler is all you need to build pypy-c, but it will miss some
modules that relies on third-party libraries. See below how to get
@@ -57,7 +58,8 @@
install third-party libraries. We chose to install them in the parent
directory of the pypy checkout. For example, if you installed pypy in
``d:\pypy\trunk\`` (This directory contains a README file), the base
-directory is ``d:\pypy``.
+directory is ``d:\pypy``. You may choose different values by setting the
+INCLUDE, LIB and PATH (for DLLs)
The Boehm garbage collector
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -126,18 +128,54 @@
------------------------
You can compile pypy with the mingw compiler, using the --cc=mingw32 option;
-mingw.exe must be on the PATH.
+gcc.exe must be on the PATH. If the -cc flag does not begin with "ming", it
should be
+the name of a valid gcc-derivative compiler, i.e. x86_64-w64-mingw32-gcc for
the 64 bit
+compiler creating a 64 bit target.
-libffi for the mingw32 compiler
+libffi for the mingw compiler
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-To enable the _rawffi (and ctypes) module, you need to compile a mingw32
-version of libffi. I downloaded the `libffi source files`_, and extracted
-them in the base directory. Then run::
+To enable the _rawffi (and ctypes) module, you need to compile a mingw
+version of libffi. Here is one way to do this, wich should allow you to try
+to build for win64 or win32:
+
+#. Download and unzip a `mingw32 build`_ or `mingw64 build`_, say into c:\mingw
+#. If you do not use cygwin, you will need msys to provide make,
+ autoconf tools and other goodies.
+
+ #. Download and unzip a `msys for mingw`_, say into c:\msys
+ #. Edit the c:\msys\etc\fstab file to mount c:\mingw
+
+#. Download and unzip the `libffi source files`_, and extract
+ them in the base directory.
+#. Run c:\msys\msys.bat or a cygwin shell which should make you
+ feel better since it is a shell prompt with shell tools.
+#. From inside the shell, cd to the libffi directory and do::
sh ./configure
make
cp .libs/libffi-5.dll <somewhere on the PATH>
+If you can't find the dll, and the libtool issued a warning about
+"undefined symbols not allowed", you will need to edit the libffi
+Makefile in the toplevel directory. Add the flag -no-undefined to
+the definition of libffi_la_LDFLAGS
+
+If you wish to experiment with win64, you must run configure with flags::
+
+ sh ./configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32
+
+or such, depending on your mingw64 download.
+
+hacking on Pypy with the mingw compiler
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Since hacking on Pypy means running tests, you will need a way to specify
+the mingw compiler when hacking (as opposed to translating). As of
+March 2012, --cc is not a valid option for pytest.py. However if you set an
+environment variable CC it will allow you to choose a compiler.
+
+.. _'mingw32 build':
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Automated%20Builds
+.. _`mingw64 build`:
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Automated%20Builds
+.. _`msys for mingw`:
http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29
.. _`libffi source files`: http://sourceware.org/libffi/
.. _`RPython translation toolchain`: translation.html
diff --git a/pypy/doc/you-want-to-help.rst b/pypy/doc/you-want-to-help.rst
--- a/pypy/doc/you-want-to-help.rst
+++ b/pypy/doc/you-want-to-help.rst
@@ -56,12 +56,23 @@
xxx
-* JIT
+* Just-in-Time Compiler (JIT): `we have a tracing JIT`_ that traces the
+ interpreter written in RPython, rather than the user program that it
+ interprets. As a result it applies to any interpreter, i.e. any
+ language. But getting it to work correctly is not trivial: it
+ requires a small number of precise "hints" and possibly some small
+ refactorings of the interpreter. The JIT itself also has several
+ almost-independent parts: the tracer itself in ``jit/metainterp``, the
+ optimizer in ``jit/metainterp/optimizer`` that optimizes a list of
+ residual operations, and the backend in ``jit/backend/<machine-name>``
+ that turns it into machine code. Writing a new backend is a
+ traditional way to get into the project.
- xxx
+.. _`we have a tracing JIT`: jit/index.html
-* Garbage Collectors: as you can notice, there are no ``Py_INCREF/Py_DECREF``
- equivalents in RPython code. `Garbage collection in PyPy`_ is inserted
+* Garbage Collectors (GC): as you can notice if you are used to CPython's
+ C code, there are no ``Py_INCREF/Py_DECREF`` equivalents in RPython code.
+ `Garbage collection in PyPy`_ is inserted
during translation. Moreover, this is not reference counting; it is a real
GC written as more RPython code. The best one we have so far is in
``rpython/memory/gc/minimark.py``.
diff --git a/pypy/interpreter/astcompiler/test/test_astbuilder.py
b/pypy/interpreter/astcompiler/test/test_astbuilder.py
--- a/pypy/interpreter/astcompiler/test/test_astbuilder.py
+++ b/pypy/interpreter/astcompiler/test/test_astbuilder.py
@@ -10,16 +10,6 @@
from pypy.interpreter.astcompiler import ast, consts
-try:
- all
-except NameError:
- def all(iterable):
- for x in iterable:
- if not x:
- return False
- return True
-
-
class TestAstBuilder:
def setup_class(cls):
diff --git a/pypy/module/__pypy__/__init__.py b/pypy/module/__pypy__/__init__.py
--- a/pypy/module/__pypy__/__init__.py
+++ b/pypy/module/__pypy__/__init__.py
@@ -16,13 +16,15 @@
appleveldefs = {}
interpleveldefs = {}
if sys.platform.startswith("linux"):
+ from pypy.module.__pypy__ import interp_time
interpleveldefs["clock_gettime"] = "interp_time.clock_gettime"
interpleveldefs["clock_getres"] = "interp_time.clock_getres"
for name in [
"CLOCK_REALTIME", "CLOCK_MONOTONIC", "CLOCK_MONOTONIC_RAW",
"CLOCK_PROCESS_CPUTIME_ID", "CLOCK_THREAD_CPUTIME_ID"
]:
- interpleveldefs[name] = "space.wrap(interp_time.%s)" % name
+ if getattr(interp_time, name) is not None:
+ interpleveldefs[name] = "space.wrap(interp_time.%s)" % name
class Module(MixedModule):
diff --git a/pypy/module/__pypy__/interp_time.py
b/pypy/module/__pypy__/interp_time.py
--- a/pypy/module/__pypy__/interp_time.py
+++ b/pypy/module/__pypy__/interp_time.py
@@ -1,3 +1,4 @@
+from __future__ import with_statement
import sys
from pypy.interpreter.error import exception_from_errno
diff --git a/pypy/objspace/flow/test/test_objspace.py
b/pypy/objspace/flow/test/test_objspace.py
--- a/pypy/objspace/flow/test/test_objspace.py
+++ b/pypy/objspace/flow/test/test_objspace.py
@@ -1,6 +1,6 @@
from __future__ import with_statement
import new
-import py
+import py, sys
from pypy.objspace.flow.model import Constant, Block, Link, Variable
from pypy.objspace.flow.model import mkentrymap, c_last_exception
from pypy.interpreter.argument import Arguments
@@ -893,6 +893,8 @@
""" Tests code generated by pypy-c compiled with BUILD_LIST_FROM_ARG
bytecode
"""
+ if sys.version_info < (2, 7):
+ py.test.skip("2.7 only test")
self.patch_opcodes('BUILD_LIST_FROM_ARG')
try:
def f():
diff --git a/pypy/rlib/_rffi_stacklet.py b/pypy/rlib/_rffi_stacklet.py
--- a/pypy/rlib/_rffi_stacklet.py
+++ b/pypy/rlib/_rffi_stacklet.py
@@ -14,7 +14,7 @@
includes = ['src/stacklet/stacklet.h'],
separate_module_sources = ['#include "src/stacklet/stacklet.c"\n'],
)
-if sys.platform == 'win32':
+if 'masm' in dir(eci.platform): # Microsoft compiler
if is_emulated_long:
asmsrc = 'switch_x64_msvc.asm'
else:
diff --git a/pypy/rlib/_rsocket_rffi.py b/pypy/rlib/_rsocket_rffi.py
--- a/pypy/rlib/_rsocket_rffi.py
+++ b/pypy/rlib/_rsocket_rffi.py
@@ -58,12 +58,12 @@
header_lines = [
'#include <WinSock2.h>',
'#include <WS2tcpip.h>',
+ '#include <Mstcpip.h>',
# winsock2 defines AF_UNIX, but not sockaddr_un
'#undef AF_UNIX',
]
if _MSVC:
header_lines.extend([
- '#include <Mstcpip.h>',
# these types do not exist on microsoft compilers
'typedef int ssize_t;',
'typedef unsigned __int16 uint16_t;',
@@ -71,6 +71,7 @@
])
else: # MINGW
includes = ('stdint.h',)
+ """
header_lines.extend([
'''\
#ifndef _WIN32_WINNT
@@ -88,6 +89,7 @@
u_long keepaliveinterval;
};'''
])
+ """
HEADER = '\n'.join(header_lines)
COND_HEADER = ''
constants = {}
diff --git a/pypy/rlib/clibffi.py b/pypy/rlib/clibffi.py
--- a/pypy/rlib/clibffi.py
+++ b/pypy/rlib/clibffi.py
@@ -114,9 +114,10 @@
)
eci = rffi_platform.configure_external_library(
- 'libffi', eci,
+ 'libffi-5', eci,
[dict(prefix='libffi-',
include_dir='include', library_dir='.libs'),
+ dict(prefix=r'c:\mingw64', include_dir='include', library_dir='lib'),
])
else:
libffidir = py.path.local(pypydir).join('translator', 'c', 'src',
'libffi_msvc')
diff --git a/pypy/rlib/longlong2float.py b/pypy/rlib/longlong2float.py
--- a/pypy/rlib/longlong2float.py
+++ b/pypy/rlib/longlong2float.py
@@ -6,6 +6,7 @@
in which it does not work.
"""
+from __future__ import with_statement
from pypy.annotation import model as annmodel
from pypy.rlib.rarithmetic import r_int64
from pypy.rpython.lltypesystem import lltype, rffi
diff --git a/pypy/rlib/rmmap.py b/pypy/rlib/rmmap.py
--- a/pypy/rlib/rmmap.py
+++ b/pypy/rlib/rmmap.py
@@ -711,9 +711,9 @@
free = c_munmap_safe
elif _MS_WINDOWS:
- def mmap(fileno, length, flags=0, tagname="", access=_ACCESS_DEFAULT,
offset=0):
+ def mmap(fileno, length, tagname="", access=_ACCESS_DEFAULT, offset=0):
# XXX flags is or-ed into access by now.
-
+ flags = 0
# check size boundaries
_check_map_size(length)
map_size = length
diff --git a/pypy/rlib/rwin32.py b/pypy/rlib/rwin32.py
--- a/pypy/rlib/rwin32.py
+++ b/pypy/rlib/rwin32.py
@@ -141,6 +141,10 @@
cfile = udir.join('dosmaperr.c')
cfile.write(r'''
#include <errno.h>
+ #include <stdio.h>
+ #ifdef __GNUC__
+ #define _dosmaperr mingw_dosmaperr
+ #endif
int main()
{
int i;
diff --git a/pypy/rlib/test/autopath.py b/pypy/rlib/test/autopath.py
new file mode 100644
--- /dev/null
+++ b/pypy/rlib/test/autopath.py
@@ -0,0 +1,131 @@
+"""
+self cloning, automatic path configuration
+
+copy this into any subdirectory of pypy from which scripts need
+to be run, typically all of the test subdirs.
+The idea is that any such script simply issues
+
+ import autopath
+
+and this will make sure that the parent directory containing "pypy"
+is in sys.path.
+
+If you modify the master "autopath.py" version (in pypy/tool/autopath.py)
+you can directly run it which will copy itself on all autopath.py files
+it finds under the pypy root directory.
+
+This module always provides these attributes:
+
+ pypydir pypy root directory path
+ this_dir directory where this autopath.py resides
+
+"""
+
+def __dirinfo(part):
+ """ return (partdir, this_dir) and insert parent of partdir
+ into sys.path. If the parent directories don't have the part
+ an EnvironmentError is raised."""
+
+ import sys, os
+ try:
+ head = this_dir = os.path.realpath(os.path.dirname(__file__))
+ except NameError:
+ head = this_dir = os.path.realpath(os.path.dirname(sys.argv[0]))
+
+ error = None
+ while head:
+ partdir = head
+ head, tail = os.path.split(head)
+ if tail == part:
+ checkfile = os.path.join(partdir, os.pardir, 'pypy', '__init__.py')
+ if not os.path.exists(checkfile):
+ error = "Cannot find %r" % (os.path.normpath(checkfile),)
+ break
+ else:
+ error = "Cannot find the parent directory %r of the path %r" % (
+ partdir, this_dir)
+ if not error:
+ # check for bogus end-of-line style (e.g. files checked out on
+ # Windows and moved to Unix)
+ f = open(__file__.replace('.pyc', '.py'), 'r')
+ data = f.read()
+ f.close()
+ if data.endswith('\r\n') or data.endswith('\r'):
+ error = ("Bad end-of-line style in the .py files. Typically "
+ "caused by a zip file or a checkout done on Windows and "
+ "moved to Unix or vice-versa.")
+ if error:
+ raise EnvironmentError("Invalid source tree - bogus checkout! " +
+ error)
+
+ pypy_root = os.path.join(head, '')
+ try:
+ sys.path.remove(head)
+ except ValueError:
+ pass
+ sys.path.insert(0, head)
+
+ munged = {}
+ for name, mod in sys.modules.items():
+ if '.' in name:
+ continue
+ fn = getattr(mod, '__file__', None)
+ if not isinstance(fn, str):
+ continue
+ newname = os.path.splitext(os.path.basename(fn))[0]
+ if not newname.startswith(part + '.'):
+ continue
+ path = os.path.join(os.path.dirname(os.path.realpath(fn)), '')
+ if path.startswith(pypy_root) and newname != part:
+ modpaths = os.path.normpath(path[len(pypy_root):]).split(os.sep)
+ if newname != '__init__':
+ modpaths.append(newname)
+ modpath = '.'.join(modpaths)
+ if modpath not in sys.modules:
+ munged[modpath] = mod
+
+ for name, mod in munged.iteritems():
+ if name not in sys.modules:
+ sys.modules[name] = mod
+ if '.' in name:
+ prename = name[:name.rfind('.')]
+ postname = name[len(prename)+1:]
+ if prename not in sys.modules:
+ __import__(prename)
+ if not hasattr(sys.modules[prename], postname):
+ setattr(sys.modules[prename], postname, mod)
+
+ return partdir, this_dir
+
+def __clone():
+ """ clone master version of autopath.py into all subdirs """
+ from os.path import join, walk
+ if not this_dir.endswith(join('pypy','tool')):
+ raise EnvironmentError("can only clone master version "
+ "'%s'" % join(pypydir, 'tool',_myname))
+
+
+ def sync_walker(arg, dirname, fnames):
+ if _myname in fnames:
+ fn = join(dirname, _myname)
+ f = open(fn, 'rwb+')
+ try:
+ if f.read() == arg:
+ print "checkok", fn
+ else:
+ print "syncing", fn
+ f = open(fn, 'w')
+ f.write(arg)
+ finally:
+ f.close()
+ s = open(join(pypydir, 'tool', _myname), 'rb').read()
+ walk(pypydir, sync_walker, s)
+
+_myname = 'autopath.py'
+
+# set guaranteed attributes
+
+pypydir, this_dir = __dirinfo('pypy')
+
+if __name__ == '__main__':
+ __clone()
diff --git a/pypy/rpython/tool/rffi_platform.py
b/pypy/rpython/tool/rffi_platform.py
--- a/pypy/rpython/tool/rffi_platform.py
+++ b/pypy/rpython/tool/rffi_platform.py
@@ -660,8 +660,8 @@
if isinstance(fieldtype, lltype.FixedSizeArray):
size, _ = expected_size_and_sign
return lltype.FixedSizeArray(fieldtype.OF, size/_sizeof(fieldtype.OF))
- raise TypeError("conflicting field type %r for %r" % (fieldtype,
- fieldname))
+ raise TypeError("conflict between translating python and compiler field"
+ " type %r for %r" % (fieldtype, fieldname))
def expose_value_as_rpython(value):
if intmask(value) == value:
diff --git a/pypy/tool/release/package.py b/pypy/tool/release/package.py
--- a/pypy/tool/release/package.py
+++ b/pypy/tool/release/package.py
@@ -58,9 +58,13 @@
binaries = [(pypy_c, rename_pypy_c)]
#
if sys.platform == 'win32':
+ #Don't include a mscvrXX.dll, users should get their own.
+ #Instructions are provided on the website.
+
# Can't rename a DLL: it is always called 'libpypy-c.dll'
+
for extra in ['libpypy-c.dll',
- 'libexpat.dll', 'sqlite3.dll', 'msvcr100.dll',
+ 'libexpat.dll', 'sqlite3.dll',
'libeay32.dll', 'ssleay32.dll']:
p = pypy_c.dirpath().join(extra)
if not p.check():
diff --git a/pypy/translator/c/gcc/trackgcroot.py
b/pypy/translator/c/gcc/trackgcroot.py
--- a/pypy/translator/c/gcc/trackgcroot.py
+++ b/pypy/translator/c/gcc/trackgcroot.py
@@ -484,7 +484,9 @@
'shl', 'shr', 'sal', 'sar', 'rol', 'ror', 'mul', 'imul', 'div', 'idiv',
'bswap', 'bt', 'rdtsc',
'punpck', 'pshufd', 'pcmp', 'pand', 'psllw', 'pslld', 'psllq',
- 'paddq', 'pinsr', 'pmul', 'psrl', 'vmul',
+ 'paddq', 'pinsr', 'pmul', 'psrl',
+ # all vectors don't produce pointers
+ 'v',
# sign-extending moves should not produce GC pointers
'cbtw', 'cwtl', 'cwtd', 'cltd', 'cltq', 'cqto',
# zero-extending moves should not produce GC pointers
diff --git a/pypy/translator/c/src/libffi_msvc/win64.asm
b/pypy/translator/c/src/libffi_msvc/win64.asm
new file mode 100644
--- /dev/null
+++ b/pypy/translator/c/src/libffi_msvc/win64.asm
@@ -0,0 +1,156 @@
+PUBLIC ffi_call_AMD64
+
+EXTRN __chkstk:NEAR
+EXTRN ffi_closure_SYSV:NEAR
+
+_TEXT SEGMENT
+
+;;; ffi_closure_OUTER will be called with these registers set:
+;;; rax points to 'closure'
+;;; r11 contains a bit mask that specifies which of the
+;;; first four parameters are float or double
+;;;
+;;; It must move the parameters passed in registers to their stack location,
+;;; call ffi_closure_SYSV for the actual work, then return the result.
+;;;
+ffi_closure_OUTER PROC FRAME
+ ;; save actual arguments to their stack space.
+ test r11, 1
+ jne first_is_float
+ mov QWORD PTR [rsp+8], rcx
+ jmp second
+first_is_float:
+ movlpd QWORD PTR [rsp+8], xmm0
+
+second:
+ test r11, 2
+ jne second_is_float
+ mov QWORD PTR [rsp+16], rdx
+ jmp third
+second_is_float:
+ movlpd QWORD PTR [rsp+16], xmm1
+
+third:
+ test r11, 4
+ jne third_is_float
+ mov QWORD PTR [rsp+24], r8
+ jmp forth
+third_is_float:
+ movlpd QWORD PTR [rsp+24], xmm2
+
+forth:
+ test r11, 8
+ jne forth_is_float
+ mov QWORD PTR [rsp+32], r9
+ jmp done
+forth_is_float:
+ movlpd QWORD PTR [rsp+32], xmm3
+
+done:
+.ALLOCSTACK 40
+ sub rsp, 40
+.ENDPROLOG
+ mov rcx, rax ; context is first parameter
+ mov rdx, rsp ; stack is second parameter
+ add rdx, 40 ; correct our own area
+ mov rax, ffi_closure_SYSV
+ call rax ; call the real closure function
+ ;; Here, code is missing that handles float return values
+ add rsp, 40
+ movd xmm0, rax ; In case the closure returned a float.
+ ret 0
+ffi_closure_OUTER ENDP
+
+
+;;; ffi_call_AMD64
+
+stack$ = 0
+prepfunc$ = 32
+ecif$ = 40
+bytes$ = 48
+flags$ = 56
+rvalue$ = 64
+fn$ = 72
+
+ffi_call_AMD64 PROC FRAME
+
+ mov QWORD PTR [rsp+32], r9
+ mov QWORD PTR [rsp+24], r8
+ mov QWORD PTR [rsp+16], rdx
+ mov QWORD PTR [rsp+8], rcx
+.PUSHREG rbp
+ push rbp
+.ALLOCSTACK 48
+ sub rsp, 48 ; 00000030H
+.SETFRAME rbp, 32
+ lea rbp, QWORD PTR [rsp+32]
+.ENDPROLOG
+
+ mov eax, DWORD PTR bytes$[rbp]
+ add rax, 15
+ and rax, -16
+ call __chkstk
+ sub rsp, rax
+ lea rax, QWORD PTR [rsp+32]
+ mov QWORD PTR stack$[rbp], rax
+
+ mov rdx, QWORD PTR ecif$[rbp]
+ mov rcx, QWORD PTR stack$[rbp]
+ call QWORD PTR prepfunc$[rbp]
+
+ mov rsp, QWORD PTR stack$[rbp]
+
+ movlpd xmm3, QWORD PTR [rsp+24]
+ movd r9, xmm3
+
+ movlpd xmm2, QWORD PTR [rsp+16]
+ movd r8, xmm2
+
+ movlpd xmm1, QWORD PTR [rsp+8]
+ movd rdx, xmm1
+
+ movlpd xmm0, QWORD PTR [rsp]
+ movd rcx, xmm0
+
+ call QWORD PTR fn$[rbp]
+ret_int$:
+ cmp DWORD PTR flags$[rbp], 1 ; FFI_TYPE_INT
+ jne ret_float$
+
+ mov rcx, QWORD PTR rvalue$[rbp]
+ mov DWORD PTR [rcx], eax
+ jmp SHORT ret_nothing$
+
+ret_float$:
+ cmp DWORD PTR flags$[rbp], 2 ; FFI_TYPE_FLOAT
+ jne SHORT ret_double$
+
+ mov rax, QWORD PTR rvalue$[rbp]
+ movlpd QWORD PTR [rax], xmm0
+ jmp SHORT ret_nothing$
+
+ret_double$:
+ cmp DWORD PTR flags$[rbp], 3 ; FFI_TYPE_DOUBLE
+ jne SHORT ret_int64$
+
+ mov rax, QWORD PTR rvalue$[rbp]
+ movlpd QWORD PTR [rax], xmm0
+ jmp SHORT ret_nothing$
+
+ret_int64$:
+ cmp DWORD PTR flags$[rbp], 12 ; FFI_TYPE_SINT64
+ jne ret_nothing$
+
+ mov rcx, QWORD PTR rvalue$[rbp]
+ mov QWORD PTR [rcx], rax
+ jmp SHORT ret_nothing$
+
+ret_nothing$:
+ xor eax, eax
+
+ lea rsp, QWORD PTR [rbp+16]
+ pop rbp
+ ret 0
+ffi_call_AMD64 ENDP
+_TEXT ENDS
+END
diff --git a/pypy/translator/platform/__init__.py
b/pypy/translator/platform/__init__.py
--- a/pypy/translator/platform/__init__.py
+++ b/pypy/translator/platform/__init__.py
@@ -301,6 +301,8 @@
global platform
log.msg("Setting platform to %r cc=%s" % (new_platform,cc))
platform = pick_platform(new_platform, cc)
+ if not platform:
+ raise ValueError("pick_platform failed")
if new_platform == 'host':
global host
diff --git a/pypy/translator/platform/windows.py
b/pypy/translator/platform/windows.py
--- a/pypy/translator/platform/windows.py
+++ b/pypy/translator/platform/windows.py
@@ -7,15 +7,27 @@
from pypy.translator.platform import log, _run_subprocess
from pypy.translator.platform import Platform, posix
+def _get_compiler_type(cc, x64_flag):
+ import subprocess
+ if not cc:
+ cc = os.environ.get('CC','')
+ if not cc:
+ return MsvcPlatform(cc=cc, x64=x64_flag)
+ elif cc.startswith('mingw'):
+ return MingwPlatform(cc)
+ try:
+ subprocess.check_output([cc, '--version'])
+ except:
+ raise ValueError,"Could not find compiler specified by cc option" + \
+ " '%s', it must be a valid exe file on your path"%cc
+ return MingwPlatform(cc)
+
def Windows(cc=None):
- if cc == 'mingw32':
- return MingwPlatform(cc)
- else:
- return MsvcPlatform(cc, False)
+ return _get_compiler_type(cc, False)
+
+def Windows_x64(cc=None):
+ return _get_compiler_type(cc, True)
-def Windows_x64(cc=None):
- return MsvcPlatform(cc, True)
-
def _get_msvc_env(vsver, x64flag):
try:
toolsdir = os.environ['VS%sCOMNTOOLS' % vsver]
@@ -31,14 +43,16 @@
vcvars = os.path.join(toolsdir, 'vsvars32.bat')
import subprocess
- popen = subprocess.Popen('"%s" & set' % (vcvars,),
+ try:
+ popen = subprocess.Popen('"%s" & set' % (vcvars,),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- stdout, stderr = popen.communicate()
- if popen.wait() != 0:
- return
-
+ stdout, stderr = popen.communicate()
+ if popen.wait() != 0:
+ return None
+ except:
+ return None
env = {}
stdout = stdout.replace("\r\n", "\n")
@@ -395,7 +409,9 @@
so_ext = 'dll'
def __init__(self, cc=None):
- Platform.__init__(self, 'gcc')
+ if not cc:
+ cc = 'gcc'
+ Platform.__init__(self, cc)
def _args_for_shared(self, args):
return ['-shared'] + args
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit