emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

emsdk/upstream/emscripten/cache/sysroot/include/compat/emmintrin.h is not lib/clang/19/include/**/emmintrin.h

Open gblikas opened this issue 7 months ago • 9 comments

I'm looking to narrow down a build issue. I am compiling opencv4 via

vcpkg install opencv4:wasm32-emscripten --editable

and have modified a bad header to #include <emmintrin.h> as it is a missed dependency. I did this because the documentation for Using SIMD with WebAssembly indicates that _mm_setr_epi64 should be available via #include <emmintrin.h>. Judging by my error's output:

/Users/gblikas/projects/vcpkg/buildtrees/opencv4/src/4.8.0-2bf495557d/modules/core/include/opencv2/core/hal/intrin_sse.hpp:252:15: error: use of undeclared identifier '_mm_setr_epi64'; did you mean '_mm_set_epi64'?
  252 |         val = _mm_setr_epi64((__m64)v0, (__m64)v1);
      |               ^~~~~~~~~~~~~~
      |               _mm_set_epi64
/Users/gblikas/projects/emsdk/upstream/emscripten/cache/sysroot/include/compat/emmintrin.h:1133:1: note: '_mm_set_epi64' declared here
 1133 | _mm_set_epi64(long long q1, long long q0)
      | ^

and

$ cat /Users/gblikas/projects/emsdk/upstream/emscripten/cache/sysroot/include/compat/emmintrin.h  | grep "_setr"
_mm_setr_pd(double __c0, double __c1)
_mm_setr_epi32(int i0, int i1, int i2, int i3)
_mm_setr_epi16(short w0, short w1, short w2, short w3, short w4, short w5, short w6, short w7)
_mm_setr_epi8(char b0, char b1, char b2, char b3, char b4, char b5, char b6, char b7, char b8, char b9, char b10, char b11, char b12, char b13, char b14, char b15)

it appears as if the included header emmintrin.h from **/upstream/emscripten/cache/sysroot/include/compat/emmintrin.h is not the same as any of the lib/clang/19/include/**/emmintrin.h headers.

I'm not sure what emscripten/cache/sysroot is, so this issue is most-likley user error. However,

$ grep -lR "_mm_setr_epi64" emsdk
emsdk/upstream/emscripten/test/sse/test_sse2.cpp
emsdk/upstream/emscripten/test/sse/benchmark_sse2.cpp
emsdk/upstream/lib/clang/19/include/emmintrin.h
emsdk/upstream/lib/clang/19/include/ppc_wrappers/emmintrin.h

does show that _mm_setr_epi64 should be found in emsdk/upstream/lib/clang/19/include/**/emmintrin.h. Is there a known work around for this?ng the

If this issue is better suited for the opencv repository, or vcpkg, I'll move the issue over there. However I believe this is an #include issue with emscripten-core.


Potentially Related issue

  • https://github.com/emscripten-core/emscripten/issues/9353

Version Info

$ emcc -v 
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.62 (34c1aa36052b1882058f22aa1916437ba0872690)
clang version 19.0.0git (https:/github.com/llvm/llvm-project c00ada070207979f092be9046a02fcfff8b9f9ce)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /Users/gblikas/projects/emsdk/upstream/bin

gblikas avatar Jul 12 '24 00:07 gblikas