我有一个简单的hello.c
文件,内容如下:
#include <emscripten.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
printf("hello wasm\n");
}
我正在尝试使用Emscripten .html
命令将其编译为emcc
,方法是:
emcc hello.c --emrun -o hello.html
但是我得到的输出是:
emcc: warning: LLVM version appears incorrect (seeing "10.0", expected "11.0") [-Wversion-check]
clang-10: error: unknown argument: '-fignore-exceptions'
emcc: error: '/usr/local/opt/llvm/bin/clang -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=18 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/usr/local/Cellar/emscripten/1.39.18/libexec/system/include/compat -Xclang -isystem/usr/local/Cellar/emscripten/1.39.18/libexec/system/include -Xclang -isystem/usr/local/Cellar/emscripten/1.39.18/libexec/system/include/libc -Xclang -isystem/usr/local/Cellar/emscripten/1.39.18/libexec/system/lib/libc/musl/arch/emscripten -Xclang -isystem/usr/local/Cellar/emscripten/1.39.18/libexec/system/local/include -Xclang -isystem/usr/local/Cellar/emscripten/1.39.18/libexec/system/include/SSE -Xclang -isystem/usr/local/Cellar/emscripten/1.39.18/libexec/cache/wasm/include -DEMSCRIPTEN -fignore-exceptions hello.c -Xclang -isystem/usr/local/Cellar/emscripten/1.39.18/libexec/system/include/SDL -c -o /var/folders/74/19dk0c293ps0fmfj5vsqld1w0000gn/T/emscripten_temp_xakv8jzi/hello_0.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)
我通过自制软件安装了脚本和依赖项。这些是我的.zshrc
中必需的出口商品:
export LLVM="/usr/local/opt/llvm/bin"
export BINARYEN="/usr/local/opt/binaryen/bin"
如何使它正常工作?
答案 0 :(得分:4)
emscripten需要llvm树的顶端(11)。它与LLVM 10或任何其他稳定版本不兼容。与兼容版本的llvm一起安装emscripten的最简单方法是使用emsdk进行安装,而不是自制软件。