[pypy-svn] r70305 - in pypy/trunk/pypy: . jit/backend/llvm/test jit/backend/x86/test jit/metainterp module/exceptions objspace/std/test tool translator/c/test translator/platform translator/platform/test
pedronis at codespeak.net
pedronis at codespeak.net
Mon Dec 28 17:08:07 CET 2009
Author: pedronis
Date: Mon Dec 28 17:08:06 2009
New Revision: 70305
Modified:
pypy/trunk/pypy/ (props changed)
pypy/trunk/pypy/jit/backend/llvm/test/conftest.py (props changed)
pypy/trunk/pypy/jit/backend/x86/test/test_gc_integration.py (props changed)
pypy/trunk/pypy/jit/metainterp/logger.py (props changed)
pypy/trunk/pypy/module/exceptions/ (props changed)
pypy/trunk/pypy/objspace/std/test/test_setobject.py (props changed)
pypy/trunk/pypy/tool/gcc_cache.py
pypy/trunk/pypy/translator/c/test/test_refcount.py (props changed)
pypy/trunk/pypy/translator/platform/__init__.py
pypy/trunk/pypy/translator/platform/darwin.py
pypy/trunk/pypy/translator/platform/posix.py
pypy/trunk/pypy/translator/platform/test/test_darwin.py
pypy/trunk/pypy/translator/platform/test/test_platform.py
Log:
- partial merge from Leonardo's force-arch-darwin branch, force 32 vs 64 bits builds based on the hosting python
- make sure the key used for the gcc cache also uses information from the platform (name, 64/32 bits, relevant environment values)
Modified: pypy/trunk/pypy/tool/gcc_cache.py
==============================================================================
--- pypy/trunk/pypy/tool/gcc_cache.py (original)
+++ pypy/trunk/pypy/tool/gcc_cache.py Mon Dec 28 17:08:06 2009
@@ -10,7 +10,7 @@
def cache_file_path(c_files, eci, cachename):
cache_dir = cache_dir_root.join(cachename).ensure(dir=1)
filecontents = [c_file.read() for c_file in c_files]
- key = repr((filecontents, eci))
+ key = repr((filecontents, eci, platform.key()))
hash = md5(key).hexdigest()
return cache_dir.join(hash)
Modified: pypy/trunk/pypy/translator/platform/__init__.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/__init__.py (original)
+++ pypy/trunk/pypy/translator/platform/__init__.py Mon Dec 28 17:08:06 2009
@@ -52,6 +52,8 @@
name = "abstract platform"
c_environ = None
+ relevant_environ = []
+
so_prefixes = ['']
def __init__(self, cc):
@@ -98,6 +100,12 @@
return (self.__class__ is other.__class__ and
self.__dict__ == other.__dict__)
+ def key(self):
+ bits = [self.__class__.__name__, 'cc=%s' % self.cc]
+ for varname in self.relevant_environ:
+ bits.append('%s=%s' % (varname, os.environ.get(varname)))
+ return ' '.join(bits)
+
# some helpers which seem to be cross-platform enough
def _execute_c_compiler(self, cc, args, outname):
@@ -171,8 +179,15 @@
else:
host_factory = Linux64
elif sys.platform == 'darwin':
- from pypy.translator.platform.darwin import Darwin
- host_factory = Darwin
+ from pypy.translator.platform.darwin import Darwin_i386, Darwin_x86_64
+ import platform
+ if platform.machine() == 'i386':
+ if sys.maxint <= 2147483647:
+ host_factory = Darwin_i386
+ else:
+ host_factory = Darwin_x86_64
+ else:
+ host_factory = Darwin
elif sys.platform == 'freebsd7':
from pypy.translator.platform.freebsd7 import Freebsd7, Freebsd7_64
import platform
Modified: pypy/trunk/pypy/translator/platform/darwin.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/darwin.py (original)
+++ pypy/trunk/pypy/translator/platform/darwin.py Mon Dec 28 17:08:06 2009
@@ -4,7 +4,7 @@
class Darwin(posix.BasePosix):
name = "darwin"
-
+
link_flags = ['-mmacosx-version-min=10.4']
cflags = ['-O3', '-fomit-frame-pointer', '-mmacosx-version-min=10.4']
standalone_only = ['-mdynamic-no-pic']
@@ -44,3 +44,13 @@
include_dirs = self._includedirs(eci.include_dirs)
return (args + frameworks + include_dirs)
+class Darwin_i386(Darwin):
+ name = "darwin_i386"
+ link_flags = ['-arch', 'i386', '-mmacosx-version-min=10.4']
+ cflags = ['-arch', 'i386', '-O3', '-fomit-frame-pointer', '-mmacosx-version-min=10.4']
+
+class Darwin_x86_64(Darwin):
+ name = "darwin_x86_64"
+ link_flags = ['-arch', 'x86_64', '-mmacosx-version-min=10.4']
+ cflags = ['-arch', 'x86_64', '-O3', '-fomit-frame-pointer', '-mmacosx-version-min=10.4']
+
Modified: pypy/trunk/pypy/translator/platform/posix.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/posix.py (original)
+++ pypy/trunk/pypy/translator/platform/posix.py Mon Dec 28 17:08:06 2009
@@ -10,6 +10,8 @@
exe_ext = ''
make_cmd = 'make'
+ relevant_environ=['CPATH', 'LIBRARY_PATH', 'C_INCLUDE_PATH']
+
def __init__(self, cc=None):
if cc is None:
cc = 'gcc'
Modified: pypy/trunk/pypy/translator/platform/test/test_darwin.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/test/test_darwin.py (original)
+++ pypy/trunk/pypy/translator/platform/test/test_darwin.py Mon Dec 28 17:08:06 2009
@@ -2,17 +2,25 @@
""" File containing darwin platform tests
"""
-import py, sys
+import py, sys, platform
if sys.platform != 'darwin':
py.test.skip("Darwin only")
from pypy.tool.udir import udir
-from pypy.translator.platform.darwin import Darwin
+from pypy.translator.platform.darwin import Darwin_i386, Darwin_x86_64
from pypy.translator.platform.test.test_platform import TestPlatform as BasicTest
from pypy.translator.tool.cbuild import ExternalCompilationInfo
+if platform.machine() == 'i386':
+ if sys.maxint <= 2147483647:
+ host_factory = Darwin_i386
+ else:
+ host_factory = Darwin_x86_64
+else:
+ host_factory = Darwin
+
class TestDarwin(BasicTest):
- platform = Darwin()
+ platform = host_factory()
def test_frameworks(self):
objcfile = udir.join('test_simple.m')
@@ -39,3 +47,81 @@
res = self.platform.execute(executable)
self.check_res(res)
+ def test_64_32_results(self):
+ if platform.machine() != 'i386':
+ py.test.skip("i386 only")
+ plat32 = Darwin_i386()
+ plat64 = Darwin_x86_64()
+ cfile = udir.join('test_int_size.c')
+ cfile.write(r'''
+ #include <stdio.h>
+ #include <limits.h>
+
+ int main() {
+ printf("%d\n", INT_MAX < LONG_MAX);
+ return 0;
+ }
+ ''')
+ eci = ExternalCompilationInfo()
+ executable = plat32.compile([cfile], eci)
+ res = plat32.execute(executable)
+ self.check_res(res, '0\n')
+ if host_factory == Darwin_x86_64:
+ executable = plat64.compile([cfile], eci)
+ res = plat64.execute(executable)
+ self.check_res(res, '1\n')
+
+ def test_longsize(self):
+ if platform.machine() != 'i386':
+ py.test.skip("i386 only")
+ cfile = udir.join('test_int_size.c')
+ cfile.write(r'''
+ #include <stdio.h>
+ #include <limits.h>
+
+ int main() {
+ printf("%ld\n", LONG_MAX);
+ return 0;
+ }
+ ''')
+ eci = ExternalCompilationInfo()
+ executable = self.platform.compile([cfile], eci)
+ res = self.platform.execute(executable)
+ self.check_res(res, str(sys.maxint) + '\n')
+
+ def test_32bit_makefile(self):
+ if platform.machine() != 'i386':
+ py.test.skip("i386 only")
+ plat32 = Darwin_i386()
+ plat64 = Darwin_x86_64()
+ eci = ExternalCompilationInfo()
+ cfile_content =r'''
+ #include <stdio.h>
+ #include <limits.h>
+
+ int main() {
+ printf("%d\n", INT_MAX < LONG_MAX);
+ return 0;
+ }
+ '''
+
+ tmpdir = udir.join('32_makefile' + self.__class__.__name__).ensure(dir=1)
+ cfile = tmpdir.join('test_int_size.c')
+ cfile.write(cfile_content)
+ mk = plat32.gen_makefile([cfile], ExternalCompilationInfo(),
+ path=tmpdir)
+ mk.write()
+ plat32.execute_makefile(mk)
+ res = plat32.execute(tmpdir.join('test_int_size'))
+ self.check_res(res, '0\n')
+ if host_factory == Darwin_x86_64:
+ tmpdir = udir.join('64_makefile' + self.__class__.__name__).ensure(dir=1)
+ cfile = tmpdir.join('test_int_size.c')
+ cfile.write(cfile_content)
+ mk = plat64.gen_makefile([cfile], ExternalCompilationInfo(),
+ path=tmpdir)
+ mk.write()
+ plat64.execute_makefile(mk)
+ res = plat64.execute(tmpdir.join('test_int_size'))
+ self.check_res(res, '1\n')
+
Modified: pypy/trunk/pypy/translator/platform/test/test_platform.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/test/test_platform.py (original)
+++ pypy/trunk/pypy/translator/platform/test/test_platform.py Mon Dec 28 17:08:06 2009
@@ -115,6 +115,16 @@
finally:
del os.environ['_SOME_VARIABLE_2']
+ def test_key(self):
+ class XPlatform(Platform):
+ relevant_environ = ['CPATH']
+
+ def __init__(self):
+ self.cc = 'xcc'
+ x = XPlatform()
+ res = x.key()
+ assert res.startswith('XPlatform cc=xcc CPATH=')
+
def test_equality():
class X(Platform):
def __init__(self):
More information about the Pypy-commit
mailing list