There are no tests against the multivalue ABI, the sysroot does not build separately etc. Despite this, there seem to be quite few functions in libc and other system libraries whose ABI is different between multivalue and normal. Multivalue ABI can allow substantially simpler JS FFI in certain cases so it would be nice if it were a real thing with real support. Especially because it seems to work in surprisingly many cases in practice.
If it is not intended to work, it might be nice to get an actual link error rather than just doing something completely weird. Surprisingly, I have no example of a program that links and then behaves incorrectly (though I could probably get one from Claude quite easily). The closest is the example I have included below, which prints a warning at link time but actually works correctly at runtime for some reason.
Now that wasm-bindgen has migrated off of it perhaps nobody intends to support the multivalue abi in llvm but it's a bit of a shame because it seems clearly useful.
If Emscripten does want to support it, one problem seems to be that object files do not record what ABI they were linked with. We would either need to fix that or pass -sMULTIVALUE to both compiler and linker.
Example:
#include "math.h"
int
f(float x) {
if (isfinite(x)) {
return 1;
}
return 0;
}
int main() {
return f(0.0);
}
$ emcc a.c -mmultivalue -Xclang -target-abi -Xclang experimental-mv
wasm-ld: warning: function signature mismatch: __extendsftf2
>>> defined as (f32) -> i64 in /tmp/emscripten_temp_3smyz6xa/a.o
>>> defined as (i32, f32) -> void in /home/hood/Documents/programming/pyodide/emsdk/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libcompiler_rt.a(extendsftf2.o)
Version of emscripten/emsdk:
I checked that it reproduces on Emscripten 3.1.58, 5.0.3, and 6.0.3
There are no tests against the multivalue ABI, the sysroot does not build separately etc. Despite this, there seem to be quite few functions in libc and other system libraries whose ABI is different between multivalue and normal. Multivalue ABI can allow substantially simpler JS FFI in certain cases so it would be nice if it were a real thing with real support. Especially because it seems to work in surprisingly many cases in practice.
If it is not intended to work, it might be nice to get an actual link error rather than just doing something completely weird. Surprisingly, I have no example of a program that links and then behaves incorrectly (though I could probably get one from Claude quite easily). The closest is the example I have included below, which prints a warning at link time but actually works correctly at runtime for some reason.
Now that wasm-bindgen has migrated off of it perhaps nobody intends to support the multivalue abi in llvm but it's a bit of a shame because it seems clearly useful.
If Emscripten does want to support it, one problem seems to be that object files do not record what ABI they were linked with. We would either need to fix that or pass
-sMULTIVALUEto both compiler and linker.Example:
Version of emscripten/emsdk:
I checked that it reproduces on Emscripten 3.1.58, 5.0.3, and 6.0.3