[pypy-commit] pypy kill-exported-symbols-list: Try another approach: kill 'eci.exported_symbols'
arigo
noreply at buildbot.pypy.org
Thu Oct 23 11:30:46 CEST 2014
Author: Armin Rigo <arigo at tunes.org>
Branch: kill-exported-symbols-list
Changeset: r74103:aab7e664e48a
Date: 2014-10-23 11:30 +0200
http://bitbucket.org/pypy/pypy/changeset/aab7e664e48a/
Log: Try another approach: kill 'eci.exported_symbols'
diff --git a/rpython/rlib/entrypoint.py b/rpython/rlib/entrypoint.py
--- a/rpython/rlib/entrypoint.py
+++ b/rpython/rlib/entrypoint.py
@@ -6,6 +6,11 @@
from rpython.rlib.objectmodel import we_are_translated
+def export_symbol(func):
+ func.exported_symbol = True
+ return func
+
+
def entrypoint_lowlevel(key, argtypes, c_name=None, relax=False):
""" Note: entrypoint should call llop.gc_stack_bottom on it's own.
That's necessary for making it work with asmgcc and hence JIT
@@ -14,16 +19,13 @@
if key == 'main' than it's included by default
"""
- from rpython.translator.tool.cbuild import ExternalCompilationInfo
-
def deco(func):
secondary_entrypoints.setdefault(key, []).append((func, argtypes))
if c_name is not None:
func.c_name = c_name
if relax:
func.relax_sig_check = True
- func._compilation_info = ExternalCompilationInfo(
- export_symbols=[c_name or func.func_name])
+ export_symbol(func)
return func
return deco
@@ -33,8 +35,6 @@
def entrypoint(key, argtypes, c_name=None):
"""if key == 'main' than it's included by default
"""
- from rpython.translator.tool.cbuild import ExternalCompilationInfo
-
def deco(func):
source = py.code.Source("""
def wrapper(%(args)s):
@@ -67,8 +67,7 @@
wrapper.func_name = func.func_name
if c_name is not None:
wrapper.c_name = c_name
- wrapper._compilation_info = ExternalCompilationInfo(
- export_symbols=[c_name or func.func_name])
+ export_symbol(wrapper)
return wrapper
return deco
diff --git a/rpython/rlib/rposix.py b/rpython/rlib/rposix.py
--- a/rpython/rlib/rposix.py
+++ b/rpython/rlib/rposix.py
@@ -44,7 +44,7 @@
/* This function emulates what the windows CRT
does to validate file handles */
- int
+ RPY_EXPORTED_FOR_TESTS int
_PyVerify_fd(int fd)
{
const int i1 = fd >> IOINFO_L2E;
@@ -81,15 +81,12 @@
return 0;
}
''',]
- export_symbols = ['_PyVerify_fd']
else:
separate_module_sources = []
- export_symbols = []
includes=['errno.h','stdio.h']
errno_eci = ExternalCompilationInfo(
includes=includes,
separate_module_sources=separate_module_sources,
- export_symbols=export_symbols,
)
_get_errno, _set_errno = CExternVariable(INT, 'errno', errno_eci,
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -627,8 +627,10 @@
getter_name = 'get_' + name
setter_name = 'set_' + name
- getter_prototype = "%(c_type)s %(getter_name)s ();" % locals()
- setter_prototype = "void %(setter_name)s (%(c_type)s v);" % locals()
+ getter_prototype = (
+ "RPY_EXPORTED_FOR_TESTS %(c_type)s %(getter_name)s ();" % locals())
+ setter_prototype = (
+ "RPY_EXPORTED_FOR_TESTS void %(setter_name)s (%(c_type)s v);" % locals())
c_getter = "%(c_type)s %(getter_name)s () { return %(name)s; }" % locals()
c_setter = "void %(setter_name)s (%(c_type)s v) { %(name)s = v; }" % locals()
@@ -641,7 +643,6 @@
new_eci = eci.merge(ExternalCompilationInfo(
separate_module_sources = sources,
post_include_bits = [getter_prototype, setter_prototype],
- export_symbols = [getter_name, setter_name],
))
getter = llexternal(getter_name, [], TYPE, compilation_info=new_eci,
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -199,8 +199,6 @@
except (AttributeError, KeyError):
pass
self.merge_eci(*all)
- #
- db.exported_symbols = set(self.eci.export_symbols)
def get_gcpolicyclass(self):
if self.gcpolicy is None:
diff --git a/rpython/translator/c/node.py b/rpython/translator/c/node.py
--- a/rpython/translator/c/node.py
+++ b/rpython/translator/c/node.py
@@ -828,12 +828,12 @@
return self.funcgens[0].allconstantvalues() #Assume identical for all funcgens
def forward_declaration(self):
+ callable = getattr(self.obj, '_callable', None)
+ is_exported = getattr(callable, 'exported_symbol', False)
for funcgen in self.funcgens:
- name = funcgen.name(self.name)
- is_exported = name in self.db.exported_symbols
yield '%s;' % (
forward_cdecl(self.implementationtypename,
- name, self.db.standalone,
+ funcgen.name(self.name), self.db.standalone,
is_exported=is_exported))
def implementation(self):
diff --git a/rpython/translator/c/src/g_prerequisite.h b/rpython/translator/c/src/g_prerequisite.h
--- a/rpython/translator/c/src/g_prerequisite.h
+++ b/rpython/translator/c/src/g_prerequisite.h
@@ -25,11 +25,4 @@
#endif
-#ifdef __GNUC__
-# define RPY_EXPORTED __attribute__((visibility("default")))
-#else
-# define RPY_EXPORTED __declspec(dllexport)
-#endif
-
-
#include "src/threadlocal.h"
diff --git a/rpython/translator/tool/cbuild.py b/rpython/translator/tool/cbuild.py
--- a/rpython/translator/tool/cbuild.py
+++ b/rpython/translator/tool/cbuild.py
@@ -10,7 +10,7 @@
_ATTRIBUTES = ['pre_include_bits', 'includes', 'include_dirs',
'post_include_bits', 'libraries', 'library_dirs',
'separate_module_sources', 'separate_module_files',
- 'export_symbols', 'compile_extra', 'link_extra',
+ 'compile_extra', 'link_extra',
'frameworks', 'link_files', 'testonly_libraries']
_DUPLICATES_OK = ['compile_extra', 'link_extra']
_EXTRA_ATTRIBUTES = ['use_cpp_linker', 'platform']
@@ -24,7 +24,6 @@
library_dirs = [],
separate_module_sources = [],
separate_module_files = [],
- export_symbols = [],
compile_extra = [],
link_extra = [],
frameworks = [],
@@ -59,8 +58,7 @@
separately and linked later on. (If an .h file is needed for
other .c files to access this, it can be put in includes.)
- export_symbols: list of names that should be exported by the final
- binary.
+ (export_symbols: killed, replaced by @rlib.entrypoint.export_symbol)
compile_extra: list of parameters which will be directly passed to
the compiler
@@ -293,11 +291,7 @@
if not [fn for fn in self.link_files if fn.endswith('.a')]:
ignore_a_files = False # there are none
if not self.separate_module_files and not ignore_a_files:
- if sys.platform != 'win32':
- return self
- if not self.export_symbols:
- return self
- basepath = udir.join('module_cache')
+ return self # xxx there was some condition about win32 here
else:
#basepath = py.path.local(self.separate_module_files[0]).dirpath()
basepath = udir.join('shared_cache')
@@ -312,11 +306,13 @@
basepath.ensure(dir=1)
outputfilename = str(pth.dirpath().join(pth.purebasename))
+ d = self._copy_attributes()
if ignore_a_files:
- d = self._copy_attributes()
d['link_files'] = [fn for fn in d['link_files']
if not fn.endswith('.a')]
- self = ExternalCompilationInfo(**d)
+ d['compile_extra'] = d['compile_extra'] + (
+ '-DRPY_EXPORTED_FOR_TESTS=RPY_EXPORTED',)
+ self = ExternalCompilationInfo(**d)
lib = str(host.compile([], self, outputfilename=outputfilename,
standalone=False))
@@ -365,4 +361,13 @@
#if !defined(RPY_ASSERT) && !defined(RPY_LL_ASSERT)
# define NDEBUG
#endif
+
+#ifdef __GNUC__
+# define RPY_EXPORTED __attribute__((visibility("default")))
+#else
+# define RPY_EXPORTED __declspec(dllexport)
+#endif
+#ifndef RPY_EXPORTED_FOR_TESTS
+# define RPY_EXPORTED_FOR_TESTS /* nothing */
+#endif
'''
diff --git a/rpython/translator/tool/test/test_cbuild.py b/rpython/translator/tool/test/test_cbuild.py
--- a/rpython/translator/tool/test/test_cbuild.py
+++ b/rpython/translator/tool/test/test_cbuild.py
@@ -74,7 +74,7 @@
def test_make_shared_lib(self):
eci = ExternalCompilationInfo(
separate_module_sources = ['''
- int get()
+ RPY_EXPORTED_FOR_TESTS int get()
{
return 42;
}
@@ -82,7 +82,6 @@
{
return 43;
}'''],
- export_symbols = ['get']
)
neweci = eci.compile_shared_lib()
assert len(neweci.libraries) == 1
More information about the pypy-commit
mailing list