首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用emscripten编译stockfish 10 wasm时出现内存错误

使用emscripten编译stockfish 10 wasm时出现内存错误
EN

Stack Overflow用户
提问于 2019-12-03 19:13:18
回答 1查看 167关注 0票数 0

我在编译过程中遇到了一个内存问题:“致命的:无法应用sbrk-val,因为内存不可展平”(更多信息如下所示)。实际上,我只是想编译Stockfish js Wasm,但是用以下代码替换了原始的Makefile:custom makefile

我的目标是尽可能多地避免nodejs依赖,这样我就可以在React Native中使用它。

这是控制台输出

代码语言:javascript
复制
$> make all                                                                                                                                                        2 ↵
em++ -std=c++11 -c bitbase.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c bitboard.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c endgame.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c evaluate.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c main.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c material.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c misc.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c movegen.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c movepick.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c pawns.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c position.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c psqt.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c search.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c thread.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c timeman.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c tt.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c uci.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -c ucioption.cpp -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM
em++ -std=c++11 -o stockfish.wasm bitbase.o bitboard.o endgame.o evaluate.o main.o material.o misc.o movegen.o movepick.o pawns.o position.o psqt.o search.o thread.o timeman.o tt.o uci.o ucioption.o -Oz -DNDEBUG -s WASM=1 -fPIC -s EVAL_CTORS=0 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN_ASYNC_COMPILATION=1 -s TOTAL_MEMORY=33554432 -s NO_FILESYSTEM=1 -s STANDALONE_WASM -s SIDE_MODULE=1
Fatal: cannot apply sbrk-val since memory is not flattenable

Traceback (most recent call last):
  File "/home/laurent-bernabe/Documents/Programmation/ProjetsExterieurs/emsdk/upstream/emscripten/emcc.py", line 3681, in <module>
    sys.exit(run(sys.argv))
  File "/home/laurent-bernabe/Documents/Programmation/ProjetsExterieurs/emsdk/upstream/emscripten/emcc.py", line 2514, in run
    optimizer)
  File "/home/laurent-bernabe/Documents/Programmation/ProjetsExterieurs/emsdk/upstream/emscripten/emcc.py", line 3028, in do_binaryen
    debug=intermediate_debug_info)
  File "/home/laurent-bernabe/Documents/Programmation/ProjetsExterieurs/emsdk/upstream/emscripten/tools/shared.py", line 2903, in run_wasm_opt
    return Building.run_binaryen_command('wasm-opt', *args, **kwargs)
  File "/home/laurent-bernabe/Documents/Programmation/ProjetsExterieurs/emsdk/upstream/emscripten/tools/shared.py", line 2899, in run_binaryen_command
    run_process(cmd)
  File "/home/laurent-bernabe/Documents/Programmation/ProjetsExterieurs/emsdk/upstream/emscripten/tools/shared.py", line 188, in run_process
    result.check_returncode()
  File "/home/laurent-bernabe/Documents/Programmation/ProjetsExterieurs/emsdk/upstream/emscripten/tools/shared.py", line 168, in check_returncode
    raise Py2CalledProcessError(returncode=self.returncode, cmd=self.args, output=self.stdout, stderr=self.stderr)
tools.shared.Py2CalledProcessError: Command '['/home/laurent-bernabe/Documents/Programmation/ProjetsExterieurs/emsdk/upstream/bin/wasm-opt', '--post-emscripten', '--no-exit-runtime', '-Oz', '--low-memory-unused', '--strip-debug', '--strip-producers', '--pass-arg=emscripten-sbrk-ptr@-1', '--pass-arg=emscripten-sbrk-val@-1', 'stockfish.wasm', '-o', 'stockfish.wasm', '--mvp-features']' returned non-zero exit status 1
make: *** [Makefile:16: stockfish.wasm] Error 1

有没有人能告诉我为什么会这样?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-12-03 21:39:06

我发现我需要更改的是:标志-s TOTAL_MEMORY=33554432修复了内存,编译器拒绝了这个过程。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59155817

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档