我将使用Duktape进行ARM 32/64平台的JavaScript评估。 我只想为特定平台&构建Duktape,而不是针对所有范围。针对特定平台构建Duktape(ARM 32/ARM 64)
看来,我能成功建立它:
python tools/configure.py \
--source-directory src-input \
--platform linux \
--architecture arm32 \
--config-metadata config/ \
--option-file arm32_config.yaml \
--output-directory /tmp/arm32
arm32_config.yaml:
DUK_USE_32BIT_PTRS: true
DUK_USE_64BIT_OPS: false
DUK_USE_FATAL_HANDLER: false
构建通usually.That的伟大!
在树莓派(使用它只是为了测试):
我有一个hello.c的:
#include "duktape.h"
int main(int argc, char *argv[]) {
duk_context *ctx = duk_create_heap_default();
duk_eval_string(ctx, "print('Hello world!');");
duk_destroy_heap(ctx);
return 0;
}
和Makefile.hello文件:
DUKTAPE_SOURCES = src/arm32/duktape.c
# Compiler options are quite flexible. GCC versions have a significant impact
# on the size of -Os code, e.g. gcc-4.6 is much worse than gcc-4.5.
CC = gcc
CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer
CCOPTS += -I./src/arm32 # for combined sources
CCLIBS = -lm
CCOPTS += -DUK_USE_32BIT_PTRS
CCOPTS += -DUK_USE_64BIT_OPS
CCOPTS += -DUK_USE_FATAL_HANDLER
# For debugging, use -O0 -g -ggdb, and don't add -fomit-frame-pointer
hello: $(DUKTAPE_SOURCES) hello.c
$(CC) -o [email protected] $(DEFINES) $(CCOPTS) $(DUKTAPE_SOURCES) hello.c $(CCLIBS)
它也有效!
但是,当我试图启动程序./hello我一直recived: 分段故障
能否请您对我的错误,指出有什么我错过了什么? 提前谢谢!
PS:gcc版本4.9.2(Raspbian 4.9.2-10)
非常感谢您的详细澄清! –
如果我需要优化duktape低内存设备该怎么办?我以为我需要在'config.yaml'的编译步骤中完成它。 ' DUK_USE_JX:假 DUK_USE_DEBUG_BUFSIZE:1024 .... ' 是否仍然有效? –
有很多低内存选项,在https://github.com/svaarala/duktape/blob/master/doc/low-memory.rst中描述(太多以在此列出)。低内存选项通常会取舍某些东西(性能或功能)以获得足迹,因此最佳选择取决于特定的目标应用程序。使用例如'DUK_USE_LIGHTFUNC_BUILTINS:false','DUK_USE_JX:false'都是减少占位面积的可能步骤。 –