Error converting C code to web assembly

I have successfully installed Emscripten and run it on a Ubuntu 16.04 virtual machine . I also successfully converted the helloworld.c file to a web assembly. I am currently trying to convert python to a web assembly with emscripten. The problem is that emscripten does not support python at the moment, so when I work, I tried to convert Python code to C with Cython, which I successfully made. Although I am trying to convert a cython c file to a Web assembly. Here is the console log:

$emcc pony_gp.c -o pony_gp.html

In file included from pony_gp.c:11:
In file included from /usr/include/python2.7/Python.h:58:
/usr/include/python2.7/pyport.h:886:2: error: "LONG_BIT definition appears 
wrong for platform (bad gcc/glibc config?)."
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting

According to pyport.h, this error occurs because on some 32-bit systems, LONG_BIT is incorrectly defined as 64 when it should be 32. I tried to comment on this line, but this only allowed the program to work quietly in the end without creating any code web builds, html and javascript only.

I read here that the problem is that "cmake picks up one version of python dylib and a separate version of python for headers." This makes sense since I recently abandoned Python 2.7.13-1 to Python 2.7.11-1 because Python 2.7.13-1 was not compatible with python-dev packages. Although, I do not know how to fix it.

Does anyone have an idea what to do?

+4
1

, pony_gp.c LLVM (.ll), clang, clang, Emscripten, :

source ~/emsdk/emsdk_env.sh
cython hello.py
clang `python2-config --cflags` -S -emit-llvm hello.c

.ll Emscripten.

Python → WebAssembly , , Python - , emcc, - LLVM (.bc), emsdk/emscripten/incoming/tests/python/python.bc.

, : https://github.com/dgym/cpython-emscripten

+2

Source: https://habr.com/ru/post/1680527/


All Articles