我將使用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'都是減少佔位面積的可能步驟。 –