translator/c/test/test_genc.py::test_exportstruct
def test_exportstruct():
from rpython.translator.tool.cbuild import ExternalCompilationInfo
from rpython.rlib.exports import export_struct
def f():
return 42
FOO = Struct("FOO", ("field1", Signed))
foo = malloc(FOO, flavor="raw")
foo.field1 = 43
export_struct("BarStruct", foo._obj)
t = Translation(f, [], backend="c")
t.annotate()
> t.compile_c()
translator\c\test\test_genc.py:536:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
translator\interactive.py:123: in compile_c
self.driver.compile_c()
translator\driver.py:108: in proc
return self.proceed(backend_goal)
translator\driver.py:569: in proceed
result = self._execute(goals, task_skip = self._maybe_skip())
translator\tool\taskengine.py:114: in _execute
res = self._do(goal, taskcallable, *args, **kwds)
translator\driver.py:278: in _do
res = func()
translator\driver.py:536: in task_compile_c
cbuilder.compile(**kwds)
translator\c\dlltool.py:37: in compile
outputfilename=oname)
translator\platform\__init__.py:57: in compile
ofiles = self._compile_o_files(cfiles, eci, standalone)
translator\platform\__init__.py:79: in _compile_o_files
ofiles.append(self._compile_c_file(self.cc, cfile, compile_args))
translator\platform\windows.py:290: in _compile_c_file
self._execute_c_compiler(cc, args, oname)
translator\platform\__init__.py:143: in _execute_c_compiler
self._handle_error(returncode, stdout, stderr, outname)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <MsvcPlatform cc=cl.exe>, returncode = 3221225477, stdout = ''
stderr = ''
outname = local('d:\\systemtemp\\pytest\\usession-main-1148\\testing_22\\rpython_memory_gctransform.obj')
def _handle_error(self, returncode, stdout, stderr, outname):
if returncode != 0:
# Microsoft compilers write compilation errors to stdout
stderr = stdout + stderr
errorfile = outname.new(ext='errors')
errorfile.write(stderr, mode='wb')
if self.log_errors:
stderrlines = stderr.splitlines()
for line in stderrlines:
log.Error(line)
# ^^^ don't use ERROR, because it might actually be fine.
# Also, ERROR confuses lib-python/conftest.py.
> raise CompilationError(stdout, stderr)
E CompilationError: CompilationError(out="""
E """)
translator\platform\windows.py:319: CompilationError
---------- Captured stderr call ----------
[platform:msg] Updated environment with vsver 160, using x64 True
[flowgraph] (rpython.translator.c.test.test_genc:528)f
[translation:info] Annotating&simplifying...
[c5edc25742ddc00] {translation-task
starting annotate
[translation:info] with policy: rpython.annotator.policy.AnnotatorPolicy
[c5edc257444bf80] translation-task}
[translation:info] usession directory: d:\systemtemp\pytest\usession-main-1148
[translation:info] already done: Annotating&simplifying
[translation:info] RTyping...
[c5edc25744c6080] {translation-task
starting rtype_lltype
[flowgraph] (rpython.rtyper.rclass:1170)ll_runtime_type_info
[rtyper] -=- specialized 4 blocks -=-
[flowgraph] (rpython.rtyper.rclass:1133)ll_issubclass
[flowgraph] (rpython.rtyper.rclass:1130)ll_type
[rtyper] -=- specialized 4 more blocks -=-
[c5edc2574a7ee00] translation-task}
[translation:info] lltype back-end optimisations...
[c5edc2574a7ee00] {translation-task
starting backendopt_lltype
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] inlined 0 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 0 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[c5edc2574bed100] translation-task}
[translation:info] inserting stack checks...
[c5edc2574bed100] {translation-task
starting stackcheckinsertion_lltype
[flowgraph] (rpython.rlib.rstack:42)stack_check
[flowgraph] (rpython.rlib.rstack:67)stack_check_slowpath
[rtyper] -=- specialized 8 more blocks -=-
[translation:info] inserted 0 stack checks.
[c5edc2575576800] translation-task}
[translation:info] Creating database for generating c source...
[c5edc2575576800] {translation-task
starting database_c
[flowgraph] (rpython.translator.exceptiontransform:100)rpyexc_occurred
[flowgraph] (rpython.translator.exceptiontransform:104)rpyexc_fetch_type
[flowgraph] (rpython.translator.exceptiontransform:107)rpyexc_fetch_value
[flowgraph] (rpython.translator.exceptiontransform:110)rpyexc_clear
[flowgraph] (rpython.translator.exceptiontransform:114)rpyexc_raise
[flowgraph] (rpython.translator.exceptiontransform:128)rpyexc_reraise
[flowgraph] (rpython.translator.exceptiontransform:133)rpyexc_fetch_exception
[flowgraph] (rpython.translator.exceptiontransform:138)rpyexc_restore_exception
[flowgraph] (rpython.translator.exceptiontransform:539)rpyexc_get_exception_addr
[flowgraph] (rpython.translator.exceptiontransform:543)rpyexc_get_exc_value_addr
[flowgraph] (rpython.rtyper.rclass:1173)ll_inst_type
[rtyper] -=- specialized 25 more blocks -=-
[flowgraph] (rpython.memory.gctransform.transform:447)_ll_malloc_fixedsize
[flowgraph] (rpython.memory.gctransform.transform:454)_ll_malloc_fixedsize_zero
[flowgraph] (rpython.memory.gctransform.transform:470)_ll_malloc_varsize_no_length
[flowgraph] (rpython.memory.gctransform.transform:487)ll_malloc_varsize
[flowgraph] (rpython.memory.gctransform.transform:493)_ll_malloc_varsize_no_length_zero
[flowgraph] (rpython.memory.gctransform.refcounting:34)ll_incref
[flowgraph] (rpython.memory.gctransform.refcounting:38)ll_decref
[flowgraph] (rpython.memory.gctransform.refcounting:45)ll_decref_simple
[flowgraph] (rpython.memory.gctransform.refcounting:53)ll_no_pointer_dealloc
[flowgraph] (rpython.memory.gctransform.refcounting:58)ll_malloc_fixedsize
[flowgraph] (rpython.memory.gctransform.refcounting:64)ll_malloc_varsize_no_length
[flowgraph] (rpython.memory.gctransform.transform:487)ll_malloc_varsize
[flowgraph] (rpython.memory.gctransform.refcounting:78)ll_identityhash
[flowgraph] (rpython.memory.gctransform.transform:447)_ll_malloc_fixedsize
[flowgraph] (rpython.memory.gctransform.transform:461)_ll_compute_size
[rtyper] specializing: 100 / 101 blocks (99%)
[rtyper] -=- specialized 60 more blocks -=-
[backendopt:removecasts] removed 1 cast_pointers in _ll_malloc_fixedsize__Signed
[backendopt:removecasts] removed 1 cast_pointers in _ll_malloc_fixedsize_zero__Signed
[backendopt:removecasts] removed 1 cast_pointers in _ll_malloc_varsize_no_length__Signed_Signed_Signed
[backendopt:removecasts] removed 1 cast_pointers in _ll_malloc_varsize_no_length_zero__Signed_Signed_Signed
[backendopt:removecasts] removed 1 cast_pointers in ll_malloc_varsize_no_length__Signed_Signed_Signed
[backendopt:removecasts] removed 1 cast_pointers in _ll_malloc_fixedsize__Signed
[backendopt:removecasts] removed 1 cast_pointers in _ll_compute_size__Signed_Signed_Signed
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] 0.00 _ll_compute_size__Signed_Signed_Signed
[backendopt:inlining] 9.00 _ll_malloc_fixedsize__Signed
[backendopt:inlining] 16.50 _ll_malloc_varsize_no_length__Signed_Signed_Signed
[backendopt:inlining] 20.75 ll_malloc_varsize_no_length__Signed_Signed_Signed
[backendopt:inlining] inlined 6 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 0 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[flowgraph] (rpython.memory.gctransform.refcounting:264)ll_dealloc
[rtyper] -=- specialized 0 more blocks -=-
[flowgraph] (?:1)ll_deallocator
[flowgraph] (?:1)ll_deallocator
[flowgraph] (?:1)ll_deallocator
[rtyper] -=- specialized 8 more blocks -=-
[backendopt:inlining] phase with threshold factor: 32.4
[backendopt:inlining] heuristic: rpython.translator.backendopt.inline.inlining_heuristic
[backendopt:inlining] 4.00 ll_runtime_type_info__objectPtr
[backendopt:inlining] 15.50 ll_decref_simple__Address
[backendopt:inlining] inlined 7 callsites.
[backendopt:malloc] starting malloc removal
[backendopt:malloc] removed 0 simple mallocs in total
[backendopt:mergeifblocks] starting to merge if blocks
[backendopt:malloc] removed 0 simple mallocs in total
[c:database] GC transformer: finished helpers
[c:database] GC transformer: finished tables
[c:database] Inlining GC helpers and postprocessing
[c] 217 nodes [ array: 16 func: 15 refcnt rtti: 16 struct: 170 ]
[c:database] Completed
[translation:info] database for generating C source was created
[c5edc257dce2700] translation-task}
[translation:info] Generating c source...
[c5edc257dd5c800] {translation-task
starting source_c
[c:writing] structdef.h
[c:writing] forwarddecl.h
[c:writing] preimpl.h
[c:writing] data_rpython_translator.c
[c:writing] nonfuncnodes.c
[c:writing] implement.c
[c:writing] rpython_memory_gctransform.c
[c:writing] rpython_rtyper.c
[c:writing] rpython_translator.c
[c:writing] rpython_translator_c_test.c
[translation:info] written: d:\systemtemp\pytest\usession-main-1148\testing_22\testing_22.c
[c5edc2581bd3b80] translation-task}
[translation:info] Compiling c source...
[c5edc2581bd3b80] {translation-task
starting compile_c
[c5edc26588de880] translation-task}
builder: rpython-win-x86-64 build #438+
test: translator/c/test/test_genc.py::test_exportstruct