使用emscripten生成python.cc.js

3
我正在阅读这里的emscripten教程-https://github.com/kripken/emscripten/wiki/Tutorial,并在本地机器上检查一些源代码中的演示项目。

到目前为止,我已经下载了源代码并设置了我的.emscripten设置文件。

我正在寻找一个参考来找出:需要哪些emcc命令序列,以便创建/输出“python.cc.js”和“python.html”?非常感谢之前尝试过emscripten的开发者提供的任何提示。

这是我的.emscripten文件:

EMSCRIPTEN_ROOT = os.path.expanduser('~/Dev/emscripten') # this helps projects using emscripten find it

# LLVM_ROOT = os.path.expanduser('~/Dev/llvm-3.0/cbuild/bin')
LLVM_ROOT = os.path.expanduser('/opt/local/bin')

# See below for notes on which JS engine(s) you need
NODE_JS = 'node'
SPIDERMONKEY_ENGINE = [os.path.expanduser('~/Dev/mozilla-central/js/src/js'), '-m', '-n']
V8_ENGINE = os.path.expanduser('~/Dev/v8/d8')

CLOSURE_COMPILER = os.path.expanduser('~/work/closure-compiler/compiler.jar') # optional (needed for the benchmarks)

TEMP_DIR = '/tmp'


########################################################################################################


# Pick the JS engine to use for running the compiler. This engine must exist, or
# nothing can be compiled.
#
# Recommendation: If you already have node installed, use that. Otherwise, build v8 or
#                 spidermonkey from source. Any of these three is fine, as long as it's
#                 a recent version (especially for v8 and spidermonkey).

COMPILER_ENGINE = NODE_JS
#COMPILER_ENGINE = V8_ENGINE
#COMPILER_ENGINE = SPIDERMONKEY_ENGINE


# All JS engines to use when running the automatic tests. Not all the engines in this list
# must exist (if they don't, they will be skipped in the test runner).
#
# Recommendation: If you already have node installed, use that. If you can, also build
#                 spidermonkey from source as well to get more test coverage (node can't
#                 run all the tests due to node issue 1669). v8 is currently not recommended
#                 here because of v8 issue 1822.

JS_ENGINES = [NODE_JS, SPIDERMONKEY_ENGINE]

这里是我正在运行的emconfigure ./configure命令:

calvins-MacBook ttys000 Sun Feb 05 11:47:32 |~/community/Python-2.7.2|
calvin$ emconfigure ./configure
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... darwin
checking EXTRAPLATDIR... $(PLATMACDIRS)
checking machine type as reported by uname -m... x86_64
checking for --without-gcc... no
checking for gcc... /Users/calvin/work/emscripten/emcc
checking whether the C compiler works... no
configure: error: in `/Users/calvin/community/Python-2.7.2':
configure: error: C compiler cannot create executables
See `config.log' for more details

这是生成的config.log文件:
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by python configure 2.7, which was
generated by GNU Autoconf 2.68.  Invocation command line was

  $ ./configure 

## --------- ##
## Platform. ##
## --------- ##

hostname = calvins-MacBook.local
uname -m = x86_64
uname -r = 11.2.0
uname -s = Darwin
uname -v = Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64

/usr/bin/uname -p = i386
/bin/uname -X     = unknown

/bin/arch              = unknown
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = Mach kernel version:
     Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64
Kernel configured for up to 2 processors.
2 processors are physically available.
2 processors are logically available.
Processor type: i486 (Intel 80486)
Processors active: 0 1
Primary memory available: 4.00 gigabytes
Default processor set: 146 tasks, 635 threads, 2 processors
Load average: 1.21, Mach factor: 0.99
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: ~/work/emscripten
PATH: ~/node_modules/.bin
PATH: /opt/local/apache2/bin
PATH: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin
PATH: /opt/local/lib/postgresql90/bin
PATH: /opt/local/bin
PATH: /usr/bin
PATH: ~/node_modules/.bin
PATH: /opt/local/apache2/bin
PATH: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin
PATH: /opt/local/lib/postgresql90/bin
PATH: /opt/local/bin
PATH: /usr/bin
PATH: /opt/local/bin
PATH: /opt/local/sbin
PATH: /usr/local/bin
PATH: /usr/bin
PATH: /bin
PATH: /usr/sbin
PATH: /sbin
PATH: /usr/X11/bin


## ----------- ##
## Core tests. ##
## ----------- ##

configure:2764: checking for --enable-universalsdk
configure:2805: result: no
configure:2814: checking for --with-universal-archs
configure:2831: result: 32-bit
configure:2988: checking MACHDEP
configure:3136: result: darwin
configure:3142: checking EXTRAPLATDIR
configure:3157: result: $(PLATMACDIRS)
configure:3168: checking machine type as reported by uname -m
configure:3171: result: x86_64
configure:3184: checking for --without-gcc
configure:3228: result: no
configure:3289: checking for gcc
configure:3316: result: /Users/calvin/work/emscripten/emcc
configure:3545: checking for C compiler version
configure:3554: /Users/calvin/work/emscripten/emcc --version >&5
emcc (Emscripten GCC-like replacement) 2.0
Copyright (C) 2011 the Emscripten authors.
This is free and open source software under the MIT license.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:3565: $? = 0
configure:3554: /Users/calvin/work/emscripten/emcc -v >&5
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix
clang: warning: argument unused during compilation: '-nostdinc'
clang: warning: argument unused during compilation: '-nostdinc++'
clang: warning: argument unused during compilation: '-Xclang -nobuiltininc'
clang: warning: argument unused during compilation: '-Xclang -nostdinc++'
clang: warning: argument unused during compilation: '-Xclang -nostdsysteminc'
clang: warning: argument unused during compilation: '-Xclang -isystem/Users/calvin/work/emscripten/system/include'
clang: warning: argument unused during compilation: '-Xclang -isystem/Users/calvin/work/emscripten/system/include/bsd'
... rest of stderr output deleted ...
configure:3565: $? = 0
configure:3554: /Users/calvin/work/emscripten/emcc -V >&5
clang: error: argument to '-V' is missing (expected 1 value)
clang: error: no input files
configure:3565: $? = 1
configure:3554: /Users/calvin/work/emscripten/emcc -qversion >&5
clang: error: no input files
configure:3565: $? = 1
configure:3585: checking whether the C compiler works
configure:3607: /Users/calvin/work/emscripten/emcc    conftest.c  >&5
error: unknown argument: '-nostdsysteminc'
configure:3611: $? = 1
configure:3649: result: no
configure: failed program was:
| /* confdefs.h */
| #define _GNU_SOURCE 1
| #define _NETBSD_SOURCE 1
| #define __BSD_VISIBLE 1
| #define _BSD_TYPES 1
| #define _DARWIN_C_SOURCE 1
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:3654: error: in `/Users/calvin/community/Python-2.7.2':
configure:3656: error: C compiler cannot create executables
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_env_CC_set=set
ac_cv_env_CC_value=/Users/calvin/work/emscripten/emcc
ac_cv_env_CFLAGS_set=set
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_prog_ac_ct_CC=/Users/calvin/work/emscripten/emcc

## ----------------- ##
## Output variables. ##
## ----------------- ##

AR='/Users/calvin/work/emscripten/emar'
ARCH_RUN_32BIT=''
ARFLAGS=''
BASECFLAGS=''
BLDLIBRARY=''
BLDSHARED=''
BUILDEXEEXT=''
CC='/Users/calvin/work/emscripten/emcc'
CCSHARED=''
CFLAGS=''
CFLAGSFORSHARED=''
CONFIGURE_MACOSX_DEPLOYMENT_TARGET=''
CONFIG_ARGS=' '\''CC=/Users/calvin/work/emscripten/emcc'\'' '\''CFLAGS='\'''
CPP=''
CPPFLAGS=''
CXX='/Users/calvin/work/emscripten/em++'
DEFS=''
DLINCLDIR=''
DLLLIBRARY=''
DYNLOADFILE=''
ECHO_C='\c'
ECHO_N=''
ECHO_T=''
EGREP=''
EXEEXT=''
EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
EXTRAMACHDEPPATH='$(PLATMACPATH)'
EXTRAPLATDIR='$(PLATMACDIRS)'
FRAMEWORKALTINSTALLFIRST=''
FRAMEWORKALTINSTALLLAST=''
FRAMEWORKINSTALLAPPSPREFIX=''
FRAMEWORKINSTALLFIRST=''
FRAMEWORKINSTALLLAST=''
FRAMEWORKUNIXTOOLSPREFIX='/usr/local'
GNULD=''
GREP=''
HAS_HG=''
HAVE_GETHOSTBYNAME=''
HAVE_GETHOSTBYNAME_R=''
HAVE_GETHOSTBYNAME_R_3_ARG=''
HAVE_GETHOSTBYNAME_R_5_ARG=''
HAVE_GETHOSTBYNAME_R_6_ARG=''
HGBRANCH=''
HGTAG=''
HGVERSION=''
INSTALL_DATA=''
INSTALL_PROGRAM=''
INSTALL_SCRIPT=''
INSTSONAME=''
LDCXXSHARED=''
LDFLAGS=''
LDLAST=''
LDLIBRARY=''
LDLIBRARYDIR=''
LDSHARED=''
LIBC=''
LIBFFI_INCLUDEDIR=''
LIBM=''
LIBOBJS=''
LIBRARY=''
LIBS=''
LIBTOOL_CRUFT=''
LINKCC=''
LINKFORSHARED=''
LIPO_32BIT_FLAGS=''
LN=''
LTLIBOBJS=''
MACHDEP='darwin'
MACHDEP_OBJS=''
MAINCC=''
OBJEXT=''
OPT=''
OTHER_LIBTOOL_OPT=''
PACKAGE_BUGREPORT='http://bugs.python.org/'
PACKAGE_NAME='python'
PACKAGE_STRING='python 2.7'
PACKAGE_TARNAME='python'
PACKAGE_URL=''
PACKAGE_VERSION='2.7'
PATH_SEPARATOR=':'
PKG_CONFIG=''
PYTHONFRAMEWORK=''
PYTHONFRAMEWORKDIR='no-framework'
PYTHONFRAMEWORKIDENTIFIER='org.python.python'
PYTHONFRAMEWORKINSTALLDIR=''
PYTHONFRAMEWORKPREFIX=''
RANLIB='/Users/calvin/work/emscripten/emranlib'
RUNSHARED=''
SGI_ABI=''
SHELL='/bin/sh'
SHLIBS=''
SIGNAL_OBJS=''
SO=''
SOVERSION='1.0'
SRCDIRS=''
SVNVERSION=''
THREADHEADERS=''
THREADOBJ=''
TRUE=''
UNICODE_OBJS=''
UNIVERSALSDK=''
UNIVERSAL_ARCH_FLAGS=''
USE_SIGNAL_MODULE=''
USE_THREAD_MODULE=''
VERSION='2.7'
ac_ct_CC='/Users/calvin/work/emscripten/emcc'
bindir='${exec_prefix}/bin'
build_alias=''
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
exec_prefix='NONE'
host_alias=''
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
libdir='${exec_prefix}/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='NONE'
program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define _GNU_SOURCE 1
#define _NETBSD_SOURCE 1
#define __BSD_VISIBLE 1
#define _BSD_TYPES 1
#define _DARWIN_C_SOURCE 1

configure: exit 77

看起来你正在使用OS X操作系统。Emscripten在Mac上效果不太好,你可能需要切换到Linux。 - jterrace
好的,我会在我的 Arch Linux 实例上尝试并看看是否可行。谢谢。 - Calvin Cheng
@CalvinCheng - 这个在Linux系统上可行吗? - ragulka
请帮忙 - 我找不到.emscription文件 :-/ 它在哪里? - Rune Jeppesen
1个回答

5

欢迎来到 SO,Alon!如果您想订阅它,我已经添加了 emscripten 标签。 - jterrace
@Alon:感谢您提供的两个链接!我可以澄清一下在命令emcc [-Ox] project.bc -o project.js中的project.bc是什么吗?我知道它是“项目位码”,但在尝试将我的“Python解释器”转换为“python.cc.js” Python JS解释器的上下文中,这意味着什么? - Calvin Cheng
1
@CalvinCheng “.bc” 是 LLVM bitcode。LLVM 可以有两种形式:“.ll” 和 “.bc”。基本流程是 “.c -> .bc/.ll -> .js”。 - jterrace
谢谢。现在更有意义了...正在尝试。 - Calvin Cheng
所以我试图运行 emconfigure ./configure,但是我收到了一个 configure: error: C compiler cannot create executables 的错误信息。详细信息已在上面更新。 - Calvin Cheng

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接