2016-01-23 22 views
1

我正在将CPython移植到Emscripten,并且它的构建成功。然而,当我尝试运行Node.js的通过将python.asm.js,我得到的Py_InitializeEx(0)电话里面一个很奇怪的错误:Emscripten交叉编译CPython中的奇怪导入错误

Traceback (most recent call last): 
    File "/lib/python2.7/site.py", line 62, in <module> 
    import os 
    File "/lib/python2.7/os.py", line 44, in <module> 
    from posix import * 
TypeError: 'NotImplementedType' object does not support indexing 

PySequence_GetItemObjects/abstract.c产生的错误,但我不了解如何执行到那里。如果在导致错误的行之前执行import posix,则import posix语句将成功完成,并且我可以调用posix模块中的函数。因此,该错误与from <module> import *一行有关。 PySequence_GetItem如何与from <module> import *声明相关,以及错误的原因是什么?

如果要重现该问题,我released the code on GitHub

回答

0

在调查什么错误,我关掉了优化(编译和链接-O0)。得到的JS可执行也失败了,但有一个不同的错误:

Invalid function pointer '495' called with signature 'iii'. Perhaps this is 
an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? 
Or calling a function with an incorrect type, which will fail? (it is worth 
building your source files with -Werror (warnings are errors), as warnings can 
indicate undefined behavior which can cause this) 
This pointer might make sense in another type signature: 
    ii: _dict_keys iiii: 0 i: undefined iiiii: 0 viii: 0 vii: 0 vi: 0 v: 0 
495 
495 

我看遍了Emscripten的settings.js的相关函数指针选项,并发现其EMULATE_FUNCTION_POINTER_CASTS解决了这一问题。