Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to build with emscripten #306

Merged
merged 4 commits into from
Mar 23, 2021
Merged

Add support to build with emscripten #306

merged 4 commits into from
Mar 23, 2021

Conversation

s0l0ist
Copy link
Contributor

@s0l0ist s0l0ist commented Mar 18, 2021

This PR adds support to build SEAL out of the box with emscripten.

There are a few small changes:

  • CMake changes so that ar is replaced with emscripten's emar.
  • Intrinsics support also uses the appropriate WASM headers provided by emscripten's toolchain for both gcc and clang.
  • defines.h needs to have an entry to build on a unix-like system.

Things not included:

  • JS Bindings

Building with emscripten will now compile without any errors, but it will not build anything useful due to lack of JS bindings. This PR will not include any JS bindings. Users are free to add their own ad-hoc changes for JavaScript bindings to use SEAL in their WASM or JS applications without committing to a standard. This allows flexible builds to minimize bundle size.

Example build instructions for WASM:

  1. Download/clone and setup emsdk by following their instructions.

  2. Source the environment:
    source ./emsdk_env.sh

  3. Navigate to the SEAL root directory and run emcmake:

emcmake cmake \
 -DSEAL_USE_CXX17=ON \
 -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG -flto -O3" \
 -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG -flto -O3" \
 -DSEAL_USE_INTRIN=OFF \
 -DSEAL_USE_ZLIB=ON \
 -DSEAL_USE_MSGSL=OFF \
 -DSEAL_BUILD_EXAMPLES=OFF \
 -DSEAL_BUILD_TESTS=OFF \
 -DBUILD_SHARED_LIBS=OFF \
 -DSEAL_THROW_ON_TRANSPARENT_CIPHERTEXT=ON \
 -DCMAKE_BUILD_TYPE=Release \
 .
  1. Make the static library:
    emmake make -j

  2. Build a WASM module:

emcc \
-Wall \
-flto \
-O3 \
lib/libseal-3.6.a \
--bind \
-o "seal_wasm.js" \
-s WASM=1 \
-s ALLOW_MEMORY_GROWTH=1

Generated output files. Note they're extremely small because there are no JS bindings:

  • seal_wasm.js
  • seal_wasm.wasm

@s0l0ist s0l0ist mentioned this pull request Mar 18, 2021
@WeiDaiWD
Copy link
Contributor

Thanks, Nick! This is a pretty neat PR.

Two questions:

  1. Does it work on Windows at all?
  2. I see that you have turned off SEAL_USE_INTRIN. Even when I turn it on, I don't see any intrinsic being used. What's the point of #include <wasm_simd128.h>?

Two comments:

  1. Could you please add seal_wasm.js and sael_wasm.wasm to git ignore?
  2. Could you also add your instructions on SEAL_WASM to a new section Building Microsoft SEAL Manually --> Building C++ Components --> Building for WebAssembly after Building for Android and iOS in README.md? So it appears as your commit. I can take care of decorating later if needed.

@s0l0ist
Copy link
Contributor Author

s0l0ist commented Mar 20, 2021

Does it work on Windows at all?

Unfortunately, I'm not able to test.

I see that you have turned off SEAL_USE_INTRIN. Even when I turn it on, I don't see any intrinsic being used. What's the point of #include <wasm_simd128.h>?

I've turned off intrinsics as enabling it will reduce performance by ~40-60%. I think this is caused by the #defines that are lowered to WASM instructions that are suboptimal in the files where x86intrin.h are included.

To keep the same semantics for turning on/off intrinsics, I've included the wasm_simd128.h header in the same files that the other intrinsics are located. It needs a conditional to at least omit x86intrin.h otherwise it will complain. Today, including the header does nothing; however, I believe it is the correct place to experiment with WASM SIMD instructions. It can be removed with no harm, but any attempts to play with Wasm SIMD instructions will have to put this back inside anyway.

Could you please add seal_wasm.js and sael_wasm.wasm to git ignore?

This is dependent on the emcc command arguments, I'll think about the best place to output the WASM builds and ignore that directory instead of putting it in the top level folder. I think we should use the bin/ directory for the outputs.

Could you also add your instructions on SEAL_WASM to a new section Building Microsoft SEAL Manually --> Building C++ Components --> Building for WebAssembly after Building for Android and iOS in README.md? So it appears as your commit. I can take care of decorating later if needed.

Yes! I'll do some more house keeping.

@lielfr
Copy link

lielfr commented Mar 20, 2021

If this helps, I can test it on my Windows machine. However, I'm not sure what exactly should be tested - Should just I test the WASM build and make sure it works?

@s0l0ist
Copy link
Contributor Author

s0l0ist commented Mar 20, 2021

If this helps, I can test it on my Windows machine. However, I'm not sure what exactly should be tested - Should just I test the WASM build and make sure it works?

It would certainly help to see if the steps produce the WASM artifacts work on Windows. We may need to further modify the emscripten configuration changes to work with MSVC. Including the intrinsics changes.

@lielfr
Copy link

lielfr commented Mar 21, 2021

Okay, it seems like it builds just fine using the latest emscripten sdk on my Windows 10 machine. Here is the complete build log:

E:\Dev\C++\SEAL>emcmake cmake -DSEAL_USE_CXX17=ON -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG -flto -O3" -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG -flto -O3" -DSEAL_USE_INTRIN=OFF -DSEAL_USE_ZLIB=ON -DSEAL_USE_MSGSL=OFF -DSEAL_BUILD_EXAMPLES=OFF -DSEAL_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DSEAL_THROW_ON_TRANSPARENT_CIPHERTEXT=ON -DCMAKE_BUILD_TYPE=Release .
configure: cmake -DSEAL_USE_CXX17=ON "-DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -flto -O3" "-DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -flto -O3" -DSEAL_USE_INTRIN=OFF -DSEAL_USE_ZLIB=ON -DSEAL_USE_MSGSL=OFF -DSEAL_BUILD_EXAMPLES=OFF -DSEAL_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF -DSEAL_THROW_ON_TRANSPARENT_CIPHERTEXT=ON -DCMAKE_BUILD_TYPE=Release . -DCMAKE_TOOLCHAIN_FILE=E:\Dev\C++\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR="E:/Dev/C++/emsdk/node/14.15.5_64bit/bin/node.exe" -G "MinGW Makefiles"
-- Build type (CMAKE_BUILD_TYPE): Release
-- Microsoft SEAL debug mode: OFF
-- ZLIB: download ...
CMake Deprecation Warning at thirdparty/zlib-src/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Zstandard: download ...
CMake Deprecation Warning at thirdparty/zstd-src/build/cmake/CMakeLists.txt:10 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- ZSTD VERSION: 1.4.5
-- Performing Test CXX_FLAG_STD_CPLUSPLUS11
-- Performing Test CXX_FLAG_STD_CPLUSPLUS11 - Success
-- Performing Test C_FLAG_STD_C99
-- Performing Test C_FLAG_STD_C99 - Success
-- Performing Test C_FLAG_WALL
-- Performing Test C_FLAG_WALL - Success
-- Performing Test CXX_FLAG_WALL
-- Performing Test CXX_FLAG_WALL - Success
-- Performing Test C_FLAG_WEXTRA
-- Performing Test C_FLAG_WEXTRA - Success
-- Performing Test CXX_FLAG_WEXTRA
-- Performing Test CXX_FLAG_WEXTRA - Success
-- Performing Test C_FLAG_WUNDEF
-- Performing Test C_FLAG_WUNDEF - Success
-- Performing Test CXX_FLAG_WUNDEF
-- Performing Test CXX_FLAG_WUNDEF - Success
-- Performing Test C_FLAG_WSHADOW
-- Performing Test C_FLAG_WSHADOW - Success
-- Performing Test CXX_FLAG_WSHADOW
-- Performing Test CXX_FLAG_WSHADOW - Success
-- Performing Test C_FLAG_WCAST_ALIGN
-- Performing Test C_FLAG_WCAST_ALIGN - Success
-- Performing Test CXX_FLAG_WCAST_ALIGN
-- Performing Test CXX_FLAG_WCAST_ALIGN - Success
-- Performing Test C_FLAG_WCAST_QUAL
-- Performing Test C_FLAG_WCAST_QUAL - Success
-- Performing Test CXX_FLAG_WCAST_QUAL
-- Performing Test CXX_FLAG_WCAST_QUAL - Success
-- Performing Test C_FLAG_WSTRICT_PROTOTYPES
-- Performing Test C_FLAG_WSTRICT_PROTOTYPES - Success
-- CMAKE_INSTALL_PREFIX: C:/Program Files (x86)/SEAL
-- CMAKE_INSTALL_LIBDIR: lib
-- ZSTD_LEGACY_SUPPORT not defined!
-- ZSTD_MULTITHREAD_SUPPORT is disabled
-- Performing Test SEAL_MEMSET_S_FOUND
-- Performing Test SEAL_MEMSET_S_FOUND - Failed
-- Looking for explicit_bzero
-- Looking for explicit_bzero - not found
-- Looking for explicit_memset
-- Looking for explicit_memset - not found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: E:/Dev/C++/SEAL

E:\Dev\C++\SEAL>emmake make -j
make: C:\MinGW\bin\mingw32-make.exe -j
Scanning dependencies of target zlibstatic
Scanning dependencies of target libzstd_static
[  1%] Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/adler32.o
[  2%] Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/compress.o
[  3%] Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/crc32.o
[  5%] Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/deflate.o
[  6%] Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/gzclose.o
[  7%] Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/gzlib.o
[  8%] Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/infback.o[ 10%]
Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/inflate.o
[ 11%] Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/gzread.o
[ 11%] Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/gzwrite.o
[ 12%] Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/inftrees.o
[ 13%] [ 15%] Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/trees.o
Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/inffast.o
[ 16%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/common/debug.c.o[ 17%]
Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/uncompr.o[ 18%] [ 17%]
[ 20%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/comoBuilding C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/common/threading.c.o
Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/common/fse_decompress.c.o
[ 21%]
Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/common/entropy_common.c.o[ 24%] [ 22%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/common/pool.c.o[ 25%]
Building C object thirdparty/zlib-src/CMakeFiles/zlibstatic.dir/zutil.o[ 26%] [ 27%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/zstd_compress_sequences.c.o[ 27%]
[ 29%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/huf_compress.c.o

Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/common/zstd_common.c.o[ 30%] [ 31%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/common/xxhash.c.oBuilding C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/zstd_compress.c.o


Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/hist.c.o
Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/zstd_compress_literals.c.o

[ 32%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/fse_compress.c.o
[ 34%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/zstd_fast.c.o[ 35%]
[ 36%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/zstd_compress_superblock.c.oBuilding C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/zstd_double_fast.c.o

[ 37%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/zstd_lazy.c.o
[ 39%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/coms.c.o
[ 40%] [ 40%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/zstd_opt.c.o
Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/compress/zstd_ldm.c.o[ 41%]
Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/decompress/zstd_decompress.c.o
[ 43%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/decompress/zstd_ddict.c.o
[ 43%] [ 46%] [ 45%] [ 48%] [ 44%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/dictBuilder/fastcover.c.o[ 49%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/decompress/huf_decompress.c.oBuilding C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/dictBuilder/cover.c.oBuilding C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/dictBuilder/divsufsort.c.o
Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/decmpress_block.c.oo
[ 50%]


[ 51%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/dictBuilder/zdict.c.oBuilding C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/deprecated/zbuff_common.c.oBuilding C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/deprecated/zbuff_compress.c.o


[ 53%] Building C object thirdparty/zstd-src/build/cmake/lib/CMakeFiles/libzstd_static.dir/__/__/__/lib/deprecated/zbuff_decompress.c.o
[ 54%] Linking C static library ..\..\lib\libz.a
[ 54%] Built target zlibstatic
[ 55%] Linking C static library ..\..\..\..\..\lib\libzstd.a
[ 55%] Built target libzstd_static
Scanning dependencies of target seal
[ 56%] Building CXX object CMakeFiles/seal.dir/native/src/seal/batchencoder.cpp.o
[ 58%] Building CXX object CMakeFiles/seal.dir/native/src/seal/ciphertext.cpp.o
[ 59%] Building CXX object CMakeFiles/seal.dir/native/src/seal/ckks.cpp.o
[ 60%] Building CXX object CMakeFiles/seal.dir/native/src/seal/context.cpp.o
[ 62%] Building CXX object CMakeFiles/seal.dir/native/src/seal/decryptor.cpp.o
[ 62%] [ 63%] Building CXX object CMakeFiles/seal.dir/native/src/seal/encryptor.cpp.oBuilding CXX object CMakeFiles/seal.dir/native/src/seal/encryptionparams.cpp.o

[ 64%] [ 65%] Building CXX object CMakeFiles/seal.dir/native/src/seal/memorymanager.cpp.o
Building CXX object CMakeFiles/seal.dir/native/src/seal/keygenerator.cpp.o
[ 67%] Building CXX object CMakeFiles/seal.dir/native/src/seal/modulus.cpp.o[ 68%]
[ 69%] Building CXX object CMakeFiles/seal.dir/native/src/seal/plaintext.cpp.o
Building CXX object CMakeFiles/seal.dir/native/src/seal/evaluator.cpp.o
[ 70%] [ 72%] Building CXX object CMakeFiles/seal.dir/native/src/seal/kswitchkeys.cpp.o[ 73%]
[ 74%] Building CXX object CMakeFiles/seal.dir/native/src/seal/serialization.cpp.oBuilding C object CMakeFiles/seal.dir/native/src/seal/util/blake2b.c.o[ 74%]
Building CXX object CMakeFiles/seal.dir/native/src/seal/randomgen.cpp.o
Building CXX object CMakeFiles/seal.dir/native/src/seal/valcheck.cpp.o

[ 75%] [ 77%] Building C object CMakeFiles/seal.dir/native/src/seal/util/blake2xb.c.o[ 78%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/croots.cpp.o

Building C object CMakeFiles/seal.dir/native/src/seal/util/fips202.c.o
[ 79%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/common.cpp.o[ 79%]
[ 79%] [ 81%] [ 82%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/globals.cpp.o
Building CXX object CMakeFiles/seal.dir/native/src/seal/util/galois.cpp.oBuilding CXX object CMakeFiles/seal.dir/native/src/seal/util/scalingvariant.cpp.o
Building CXX object CMakeFiles/seal.dir/native/src/seal/util/rlwe.cpp.o
[ 83%] [ 84%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/clipnormal.cpp.o

[ 86%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/mempool.cpp.o
Building CXX object CMakeFiles/seal.dir/native/src/seal/util/numth.cpp.o[ 87%] [ 88%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/polyarithsmallmod.cpp.o

Building CXX object CMakeFiles/seal.dir/native/src/seal/util/iterator.cpp.o[ 89%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/hash.cpp.o

[ 91%] [ 93%] [ 92%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/rns.cpp.oBuilding CXX object CMakeFiles/seal.dir/native/src/seal/util/ntt.cpp.o
[ 94%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/uintarithmod.cpp.o
Building CXX object CMakeFiles/seal.dir/native/src/seal/util/uintarith.cpp.o

[ 96%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/streambuf.cpp.o
[ 97%] Building CXX object CMakeFiles/seal.dir/native/src/seal/util/uintarithsmallmod.cpp.o[100%] [100%]
Building CXX object CMakeFiles/seal.dir/native/src/seal/util/uintcore.cpp.oBuilding CXX object CMakeFiles/seal.dir/native/src/seal/util/ztools.cpp.o

[100%] Linking CXX static library lib\libseal-3.6.a
[100%] Built target seal

E:\Dev\C++\SEAL>emcc -Wall -flto -O3 lib\libseal-3.6.a --bind -o "seal_wasm.js" -s WASM=1 -s ALLOW_MEMORY_GROWTH=1
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libembind-rtti.a... (this will be cached in "E:\Dev\C++\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libembind-rtti.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libgl.a... (this will be cached in "E:\Dev\C++\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libgl.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libal.a... (this will be cached in "E:\Dev\C++\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libal.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libhtml5.a... (this will be cached in "E:\Dev\C++\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libhtml5.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libc.a... (this will be cached in "E:\Dev\C++\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libc.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libcompiler_rt.a... (this will be cached in "E:\Dev\C++\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libcompiler_rt.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libc++-noexcept.a... (this will be cached in "E:\Dev\C++\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libc++-noexcept.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libc++abi-noexcept.a... (this will be cached in "E:\Dev\C++\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libc++abi-noexcept.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libdlmalloc.a... (this will be cached in "E:\Dev\C++\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libdlmalloc.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libc_rt_wasm.a... (this will be cached in "E:\Dev\C++\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libc_rt_wasm.a" for subsequent builds)
cache:INFO:  - ok
cache:INFO: generating system library: sysroot\lib\wasm32-emscripten\lto\libsockets.a... (this will be cached in "E:\Dev\C++\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten\lto\libsockets.a" for subsequent builds)
cache:INFO:  - ok

Here (inside the zip) are the two files you mentioned, which I got from the build.
SEAL_wasm.zip

@s0l0ist
Copy link
Contributor Author

s0l0ist commented Mar 21, 2021

Great! Does it work if you enable intrinsics?

@lielfr
Copy link

lielfr commented Mar 21, 2021

Seems like it is. The emcc command does not give any output, but I guess this is because of some sort of caching mechanism. The two files are created nevertheless.

@WeiDaiWD
Copy link
Contributor

@lielfr Did you use MinGW as generator?

@WeiDaiWD
Copy link
Contributor

I have not successfully built it on Windows yet. First, cmake must be added to PATH on Windows, which I'll add to the description. Then, I'm stuck at a "Could NOT find Threads". I'll find a solution before approving the PR. Everything else looks good now. If you have any clue to my problem, please let me know. Thanks!

@lielfr
Copy link

lielfr commented Mar 22, 2021

@WeiDaiWD No, I didn't need to. All I had to do is make sure I have Python >3.6 and git, then I followed the installation instructions for Emscripten (I used emsdk and followed the instructions using cmd). The other stuff are pretty much like @s0l0ist described, except the source ./emsdk_env.sh, which was replaced according to the instructions I found in the Emscripten website.

@s0l0ist
Copy link
Contributor Author

s0l0ist commented Mar 23, 2021

I installed a win 10 VM, installed CMake and the installation package had an option to add it to my path. It was not the default option.

My path to cmake:

C:/Program Files/CMake/share/cmake-3.20/

I've been able to run emcmake cmake ..., but I also face the same pthreads issue:

-- Looking for pthread_create in pthread - not found
CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Threads (missing: Threads_FOUND)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.20/Modules/FindThreads.cmake:238 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  cmake/SEALMacros.cmake:55 (find_package)
  CMakeLists.txt:334 (seal_link_threads)


-- Configuring incomplete, errors occurred!

@WeiDaiWD
Copy link
Contributor

I've found the issue. emcmake does not work with "Visual Studio 16 2019" generator. Either "Ninja" or "MinGW Makefiles" should be chosen. I'll approve this PR and add some extra description for Windows. This is be released soon in 3.6.3. Thank you both for contributing!

@WeiDaiWD WeiDaiWD merged commit 8d18498 into microsoft:contrib Mar 23, 2021
@s0l0ist
Copy link
Contributor Author

s0l0ist commented Mar 23, 2021

Yep I was using the Visual Studio 16 2019 generator.

@WeiDaiWD
Copy link
Contributor

Yep I was using the Visual Studio 16 2019 generator.

It's straightforward if you run emcmake cmake ... from visual studio's developer command prompt (x64). It uses Ninja by default. And cmake is already in the path.

@s0l0ist s0l0ist deleted the add-emscripten-build-changes branch March 23, 2021 00:36
@lielfr
Copy link

lielfr commented Mar 23, 2021

Yeah, hadn't realized that it used Ninja by default. Thanks again! Hopefully I'll be able to put it to good use.

kimlaine pushed a commit that referenced this pull request Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants