将 libsoxr 构建到 Webassembly 会导致函数签名不匹配错误
Building libsoxr to Webassembly leads to function signature mismatch error
我正在尝试使用 emscripten 将 libsoxr 构建到 WebAssembly。在调用 soxr_create
函数时,我尝试的所有操作都会导致 RuntimeError: function signature mismatch
错误。我正在使用 emscripten 的 latest
标签。我也试过提供的例子,行为是一样的。我尝试使用 NodeJS 和 Chromium。
重现方法如下:
git clone https://git.code.sf.net/p/soxr/code
cd soxr
emcmake cmake -DBUILD_EXAMPLES=ON .
emmake make
node examples/2-stream.js
堆栈跟踪是:
exception thrown: RuntimeError: function signature mismatch,RuntimeError: function signature mismatch
at wasm-function[50]:0xf72e
at wasm-function[49]:0xe90d
at wasm-function[60]:0x1057f
at wasm-function[14]:0xcac
at wasm-function[13]:0xb53
at wasm-function[11]:0x699
...
当仅使用 main
函数调用 soxr_create
并使用 -g --profiling
构建文件时,这是我得到的堆栈跟踪:
exception thrown: RuntimeError: function signature mismatch,RuntimeError: function signature mismatch
at dft_stage_init (wasm-function[68]:0x1b8e2)
at _soxr_init (wasm-function[66]:0x190be)
at rate_create (wasm-function[88]:0x1f8fa)
at initialise (wasm-function[124]:0x43c90)
at soxr_set_io_ratio (wasm-function[122]:0x4373f)
at soxr_create (wasm-function[119]:0x43213)
at __original_main (wasm-function[135]:0x45646)
at main (wasm-function[136]:0x45684)
at /home/geekuillaume/code/wasm-audio-resampler/soxr_wasm.js:1635:22
at callMain (/home/geekuillaume/code/wasm-audio-resampler/soxr_wasm.js:2377:15)
我试过使用 emscripten sanitizer,但它没有任何作用。
找到问题了。 Soxr 库错误地转换了一个函数指针。 pointed 函数不需要任何参数,但被强制转换为接收一个 int 作为参数的函数。我写了一个补丁来解决这个问题,一切正常! Emscripten documentation.
中有更多相关信息
我正在尝试使用 emscripten 将 libsoxr 构建到 WebAssembly。在调用 soxr_create
函数时,我尝试的所有操作都会导致 RuntimeError: function signature mismatch
错误。我正在使用 emscripten 的 latest
标签。我也试过提供的例子,行为是一样的。我尝试使用 NodeJS 和 Chromium。
重现方法如下:
git clone https://git.code.sf.net/p/soxr/code
cd soxr
emcmake cmake -DBUILD_EXAMPLES=ON .
emmake make
node examples/2-stream.js
堆栈跟踪是:
exception thrown: RuntimeError: function signature mismatch,RuntimeError: function signature mismatch
at wasm-function[50]:0xf72e
at wasm-function[49]:0xe90d
at wasm-function[60]:0x1057f
at wasm-function[14]:0xcac
at wasm-function[13]:0xb53
at wasm-function[11]:0x699
...
当仅使用 main
函数调用 soxr_create
并使用 -g --profiling
构建文件时,这是我得到的堆栈跟踪:
exception thrown: RuntimeError: function signature mismatch,RuntimeError: function signature mismatch
at dft_stage_init (wasm-function[68]:0x1b8e2)
at _soxr_init (wasm-function[66]:0x190be)
at rate_create (wasm-function[88]:0x1f8fa)
at initialise (wasm-function[124]:0x43c90)
at soxr_set_io_ratio (wasm-function[122]:0x4373f)
at soxr_create (wasm-function[119]:0x43213)
at __original_main (wasm-function[135]:0x45646)
at main (wasm-function[136]:0x45684)
at /home/geekuillaume/code/wasm-audio-resampler/soxr_wasm.js:1635:22
at callMain (/home/geekuillaume/code/wasm-audio-resampler/soxr_wasm.js:2377:15)
我试过使用 emscripten sanitizer,但它没有任何作用。
找到问题了。 Soxr 库错误地转换了一个函数指针。 pointed 函数不需要任何参数,但被强制转换为接收一个 int 作为参数的函数。我写了一个补丁来解决这个问题,一切正常! Emscripten documentation.
中有更多相关信息