0

这是这篇文章将 .cpp 文件转换为 .wasm 文件的后续问题

我正在尝试在 linux 上使用 emscripten 将我的 c++ 文件转换为 .wasm。我遇到了这个错误:

/home/maria/emsdk/upstream/lib/clang/10.0.0/include/ia32intrin.h:188:10: error: use of undeclared identifier '__builtin_ia32_readeflags_u32'
  return __builtin_ia32_readeflags_u32();
         ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/ia32intrin.h:194:3: error: use of undeclared identifier '__builtin_ia32_writeeflags_u32'
  __builtin_ia32_writeeflags_u32(__f);
  ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/ia32intrin.h:284:10: error: use of undeclared identifier '__builtin_ia32_crc32qi'
  return __builtin_ia32_crc32qi(__C, __D);
         ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/ia32intrin.h:305:10: error: use of undeclared identifier '__builtin_ia32_crc32hi'
  return __builtin_ia32_crc32hi(__C, __D);
         ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/ia32intrin.h:326:10: error: use of undeclared identifier '__builtin_ia32_crc32si'
  return __builtin_ia32_crc32si(__C, __D);
         ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/ia32intrin.h:354:10: error: use of undeclared identifier '__builtin_ia32_rdpmc'
  return __builtin_ia32_rdpmc(__A);
         ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/ia32intrin.h:360:10: error: use of undeclared identifier '__builtin_ia32_rdtscp'
  return __builtin_ia32_rdtscp(__A);
         ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/ia32intrin.h:369:3: error: use of undeclared identifier '__builtin_ia32_wbinvd'
  __builtin_ia32_wbinvd();
  ^
In file included from sealdemo.cpp:1:
In file included from SEAL/native/src/seal/seal.h:6:
In file included from SEAL/native/src/seal/biguint.h:9:
In file included from SEAL/native/src/seal/memorymanager.h:10:
In file included from SEAL/native/src/seal/util/defines.h:62:
In file included from SEAL/native/src/seal/util/clang.h:18:
In file included from /home/maria/emsdk/upstream/lib/clang/10.0.0/include/x86intrin.h:15:
In file included from /home/maria/emsdk/upstream/lib/clang/10.0.0/include/immintrin.h:14:
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:33:5: error: use of undeclared identifier '__builtin_ia32_emms'; did you mean '__builtin_isless'?
    __builtin_ia32_emms();
    ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:33:5: note: '__builtin_isless' declared here
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:33:25: error: too few arguments to function call, expected 2, have 0
    __builtin_ia32_emms();
                        ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:50:19: error: use of undeclared identifier '__builtin_ia32_vec_init_v2si'
    return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
                  ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:67:12: error: use of undeclared identifier '__builtin_ia32_vec_ext_v2si'
    return __builtin_ia32_vec_ext_v2si((__v2si)__m, 0);
           ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:129:19: error: use of undeclared identifier '__builtin_ia32_packsswb'
    return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);
                  ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:159:19: error: use of undeclared identifier '__builtin_ia32_packssdw'
    return (__m64)__builtin_ia32_packssdw((__v2si)__m1, (__v2si)__m2);
                  ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:189:19: error: use of undeclared identifier '__builtin_ia32_packuswb'
    return (__m64)__builtin_ia32_packuswb((__v4hi)__m1, (__v4hi)__m2);
                  ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:216:19: error: use of undeclared identifier '__builtin_ia32_punpckhbw'
    return (__m64)__builtin_ia32_punpckhbw((__v8qi)__m1, (__v8qi)__m2);
                  ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:239:19: error: use of undeclared identifier '__builtin_ia32_punpckhwd'
    return (__m64)__builtin_ia32_punpckhwd((__v4hi)__m1, (__v4hi)__m2);
                  ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:260:19: error: use of undeclared identifier '__builtin_ia32_punpckhdq'
    return (__m64)__builtin_ia32_punpckhdq((__v2si)__m1, (__v2si)__m2);
                  ^
/home/maria/emsdk/upstream/lib/clang/10.0.0/include/mmintrin.h:287:19: error: use of undeclared identifier '__builtin_ia32_punpcklbw'
    return (__m64)__builtin_ia32_punpcklbw((__v8qi)__m1, (__v8qi)__m2);
                  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
shared:ERROR: '/home/maria/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscrip

有人可以帮忙吗

4

2 回答 2

0

我已经能够使用带有内在函数 ( #include <wasm_simd128.h>) 的 emscripten 将 Microsoft SEAL 库编译为 WebAssembly,但这是可选的。

就其本身而言,工具链从来没有给我这个特定的错误,因为该emcmake步骤总是无法找到必要的头文件并且在没有优化的情况下编译。

听起来您可能没有使用适当的emcmakeem++参数。此外,如果你想使用内在函数,你需要在 gcc.h 和 clang.h(位于 SEAL/native/src/seal/util/)中使用一些条件来使用wasm_simd128.hoverx86intrin.h

随意检查我的实现和/或构建在 Mac 和 Linux (Ubuntu) 上编译的脚本: https ://github.com/morfix-io/node-seal

如果您只想要一个工作库,或者下载 npm 包: https ://www.npmjs.com/package/node-seal

于 2019-11-30T07:43:40.320 回答
0

x86intrin.h在为 WebAssembly 构建时不能/不应该包括在内。看起来你需要在没有的情况下构建SEAL_USE_INTRINhttps ://github.com/microsoft/SEAL/blob/master/native/src/seal/util/clang.h#L18

于 2019-11-12T17:52:02.607 回答