Author: Maciej Fijalkowski <[email protected]>
Branch:
Changeset: r63587:ffb4b149feac
Date: 2013-04-24 10:45 +0200
http://bitbucket.org/pypy/pypy/changeset/ffb4b149feac/
Log: Refactor code a bit so there is less duplication. Use clang on
darwin and *bsd, it seems that GCC there is incredibly buggy (and I
DONT WANT TO CARE)
diff --git a/rpython/translator/platform/bsd.py
b/rpython/translator/platform/bsd.py
new file mode 100644
--- /dev/null
+++ b/rpython/translator/platform/bsd.py
@@ -0,0 +1,31 @@
+
+import os
+from pypy.translator.platform import posix
+
+class BSD(posix.BasePosix):
+ DEFAULT_CC = 'clang'
+
+ so_ext = 'so'
+ make_cmd = 'gmake'
+
+ standalone_only = []
+ shared_only = []
+
+ def _args_for_shared(self, args):
+ return ['-shared'] + args
+
+ def _include_dirs_for_libffi(self):
+ return [os.path.join(os.environ.get("LOCALBASE", "/usr/local"),
"include")]
+
+ def _library_dirs_for_libffi(self):
+ return [os.path.join(os.environ.get("LOCALBASE", "/usr/local"), "lib")]
+
+ def _preprocess_include_dirs(self, include_dirs):
+ res_incl_dirs = list(include_dirs)
+ res_incl_dirs.append(os.path.join(os.environ.get("LOCALBASE",
"/usr/local"), "include"))
+ return res_incl_dirs
+
+ def _preprocess_library_dirs(self, library_dirs):
+ res_lib_dirs = list(library_dirs)
+ res_lib_dirs.append(os.path.join(os.environ.get("LOCALBASE",
"/usr/local"), "lib"))
+ return res_lib_dirs
diff --git a/rpython/translator/platform/darwin.py
b/rpython/translator/platform/darwin.py
--- a/rpython/translator/platform/darwin.py
+++ b/rpython/translator/platform/darwin.py
@@ -9,11 +9,7 @@
shared_only = ()
so_ext = 'dylib'
-
- # NOTE: With asmgcc GCC 4.2 will fail at runtime due to subtle issues,
- # possibly related to GC roots. Using LLVM-GCC or Clang will break the
- # build. On Darwin asmgcc is not the default anymore, so it is fine to use
- # whatever gcc we find on the system
+ DEFAULT_CC = 'clang'
def _args_for_shared(self, args):
return (list(self.shared_only)
@@ -26,10 +22,6 @@
def _library_dirs_for_libffi(self):
return ['/usr/lib']
- def check___thread(self):
- # currently __thread is not supported by Darwin gccs
- return False
-
def _frameworks(self, frameworks):
args = []
for f in frameworks:
diff --git a/rpython/translator/platform/freebsd.py
b/rpython/translator/platform/freebsd.py
--- a/rpython/translator/platform/freebsd.py
+++ b/rpython/translator/platform/freebsd.py
@@ -1,60 +1,14 @@
"""Support for FreeBSD."""
import os
+from rpython.translator.platform.bsd import BSD
-from rpython.translator.platform import posix
-
-def get_env(key, default):
- if key in os.environ:
- return os.environ[key]
- else:
- return default
-
-def get_env_vector(key, default):
- string = get_env(key, default)
- # XXX: handle quotes
- return string.split()
-
-class Freebsd(posix.BasePosix):
+class Freebsd(BSD):
name = "freebsd"
- link_flags = ['-pthread'] + get_env_vector('LDFLAGS', '')
+ link_flags = ['-pthread'] + os.environ.get('LDFLAGS', '').split()
cflags = ['-O3', '-pthread', '-fomit-frame-pointer'
- ] + get_env_vector('CFLAGS', '')
- standalone_only = []
- shared_only = []
- so_ext = 'so'
- make_cmd = 'gmake'
-
- def __init__(self, cc=None):
- if cc is None:
- cc = get_env("CC", "gcc")
- super(Freebsd, self).__init__(cc)
-
- def _args_for_shared(self, args):
- return ['-shared'] + args
-
- def _preprocess_include_dirs(self, include_dirs):
- res_incl_dirs = list(include_dirs)
- res_incl_dirs.append(os.path.join(get_env("LOCALBASE", "/usr/local"),
"include"))
- return res_incl_dirs
-
- def _preprocess_library_dirs(self, library_dirs):
- res_lib_dirs = list(library_dirs)
- res_lib_dirs.append(os.path.join(get_env("LOCALBASE", "/usr/local"),
"lib"))
- return res_lib_dirs
-
- def _include_dirs_for_libffi(self):
- return [os.path.join(get_env("LOCALBASE", "/usr/local"), "include")]
-
- def _library_dirs_for_libffi(self):
- return [os.path.join(get_env("LOCALBASE", "/usr/local"), "lib")]
+ ] + os.environ.get('CFLAGS', '').split()
class Freebsd_64(Freebsd):
shared_only = ('-fPIC',)
-
-class GNUkFreebsd(Freebsd):
- extra_libs = ('-lrt',)
-
-class GNUkFreebsd_64(Freebsd_64):
- extra_libs = ('-lrt',)
diff --git a/rpython/translator/platform/openbsd.py
b/rpython/translator/platform/openbsd.py
--- a/rpython/translator/platform/openbsd.py
+++ b/rpython/translator/platform/openbsd.py
@@ -2,60 +2,17 @@
import os
-from rpython.translator.platform import posix
+from pypy.translator.platform.bsd import BSD
-def get_env(key, default):
- if key in os.environ:
- return os.environ[key]
- else:
- return default
-
-def get_env_vector(key, default):
- string = get_env(key, default)
- # XXX: handle quotes
- return string.split()
-
-class OpenBSD(posix.BasePosix):
+class OpenBSD(BSD):
name = "openbsd"
- link_flags = get_env_vector("LDFLAGS", '-pthread')
- cflags = get_env_vector("CFLAGS", "-O3 -pthread -fomit-frame-pointer
-D_BSD_SOURCE")
- standalone_only = []
- shared_only = []
- so_ext = 'so'
- make_cmd = 'gmake'
-
- def __init__(self, cc=None):
- if cc is None:
- cc = get_env("CC", "gcc")
- super(OpenBSD, self).__init__(cc)
-
- def _args_for_shared(self, args):
- return ['-shared'] + args
-
- def _preprocess_include_dirs(self, include_dirs):
- res_incl_dirs = list(include_dirs)
- res_incl_dirs.append(os.path.join(get_env("LOCALBASE", "/usr/local"),
"include"))
- return res_incl_dirs
-
- def _preprocess_library_dirs(self, library_dirs):
- res_lib_dirs = list(library_dirs)
- res_lib_dirs.append(os.path.join(get_env("LOCALBASE", "/usr/local"),
"lib"))
- return res_lib_dirs
-
- def _include_dirs_for_libffi(self):
- return [os.path.join(get_env("LOCALBASE", "/usr/local"), "include")]
-
- def _library_dirs_for_libffi(self):
- return [os.path.join(get_env("LOCALBASE", "/usr/local"), "lib")]
+ link_flags = os.environ.get("LDFLAGS", '-pthread').split()
+ cflags = os.environ.get("CFLAGS", "-O3 -pthread -fomit-frame-pointer
-D_BSD_SOURCE").split()
def _libs(self, libraries):
libraries=set(libraries + ("intl", "iconv", "compat"))
return ['-l%s' % lib for lib in libraries if lib not in ["crypt",
"dl", "rt"]]
- def check___thread(self):
- # currently __thread is not supported by Darwin gccs
- return False
-
class OpenBSD_64(OpenBSD):
shared_only = ('-fPIC',)
diff --git a/rpython/translator/platform/posix.py
b/rpython/translator/platform/posix.py
--- a/rpython/translator/platform/posix.py
+++ b/rpython/translator/platform/posix.py
@@ -13,13 +13,10 @@
relevant_environ = ('CPATH', 'LIBRARY_PATH', 'C_INCLUDE_PATH')
+ DEFAULT_CC = 'gcc'
+
def __init__(self, cc=None):
- if cc is None:
- try:
- cc = os.environ['CC']
- except KeyError:
- cc = 'gcc'
- self.cc = cc
+ self.cc = cc or os.environ.get('CC', self.DEFAULT_CC)
def _libs(self, libraries):
return ['-l%s' % lib for lib in libraries]
@@ -250,7 +247,7 @@
self.defs = {}
self.lines = []
self.makefile_dir = py.path.local(path)
-
+
def pathrel(self, fpath):
if fpath.dirpath() == self.makefile_dir:
return fpath.basename
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit