gpt4 book ai didi

c - Emscripten:我怎样才能编译一个带有像 immintrin.h 这样的内部头文件的 c 文件?

转载 作者:行者123 更新时间:2023-12-05 04:51:27 27 4
gpt4 key购买 nike

我正在尝试使用 emscripten(C 到 WASM)编译 CLBG 基准测试。但是,它们中的大多数都包含内部 header (如 ),这给了我很多错误(让我们以 nbody.c 为例),如下所示:

nbody.c:137:20: 错误:使用未声明的标识符 '__m128d' static alignas(__m128d) double

我已经尝试使用这些标志进行编译

emcc nbody.c -o nbody.js -O2 -s WASM=1 -msse2 -msimd128

然后编译。但是,当我尝试使用 nodejs 运行 nbody.js 时,它不起作用。我也尝试用

运行 nodejs

--experimental-wasm-simd

像这样git告诉,但它也不起作用。它说:

failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): Compiling function #4:"main" failed: invalid value type 'Simd128', enable with --experimental-wasm-simd @+422
CompileError: WebAssembly.instantiate(): Compiling function #4:"main" failed: invalid value type 'Simd128', enable with --experimental-wasm-simd @+422
RuntimeError: abort(CompileError: WebAssembly.instantiate(): Compiling function #4:"main" failed: invalid value type 'Simd128', enable with --experimental-wasm-simd @+422).
Build with -s ASSERTIONS=1 for more info.

谁能帮帮我?我不明白这是否已经可以做到。

最佳答案

将这些编译标志添加到 C 和 CXX 标志

-fPIC -Wno-implicit-function-declaration -msse2 -msimd128 -experimental-wasm-simd

关于c - Emscripten:我怎样才能编译一个带有像 immintrin.h 这样的内部头文件的 c 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66908027/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com