diff --git a/CMake/BuildSECP256K1.cmake b/CMake/BuildSECP256K1.cmake index 05c8331ba..ac70b2559 100644 --- a/CMake/BuildSECP256K1.cmake +++ b/CMake/BuildSECP256K1.cmake @@ -19,14 +19,15 @@ if (NOT SECP256K1_LIBRARY) OUTPUT ${SECP256K1_LIBRARY} ) elseif (EMSCRIPTEN) - set(SECP256K1_LIBRARY ${SECP256K1_BINARY_DIR}/lib/libsecp256k1.a) + set(SECP256K1_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/secp256k1) + set(SECP256K1_LIBRARY ${SECP256K1_BINARY_DIR}/.libs/libsecp256k1.a) set(SECP256K1_INCLUDE_DIR ${SECP256K1_SOURCE_DIR}/include) add_custom_command( WORKING_DIRECTORY ${SECP256K1_SOURCE_DIR} COMMAND ./autogen.sh - COMMAND emconfigure ./configure --enable-module-recovery --enable-module-extrakeys --prefix ${SECP256K1_BINARY_DIR} + COMMAND emconfigure ./configure --enable-module-recovery --enable-module-extrakeys --disable-tests --disable-benchmark + COMMAND emmake make clean COMMAND emmake make - COMMAND emmake make install COMMENT "Build Secp256k1 with emscripten" DEPENDS ${SECP256K1_SOURCE_DIR} OUTPUT ${SECP256K1_LIBRARY} @@ -46,7 +47,6 @@ if (NOT SECP256K1_LIBRARY) ) endif() endif() - else() message(STATUS "Use Secp256k1: ${SECP256K1_LIBRARY}") endif() diff --git a/assembly/wasm/fift-func-wasm-build-ubuntu.sh b/assembly/wasm/fift-func-wasm-build-ubuntu.sh index f66a5f759..8c0069f37 100644 --- a/assembly/wasm/fift-func-wasm-build-ubuntu.sh +++ b/assembly/wasm/fift-func-wasm-build-ubuntu.sh @@ -27,12 +27,13 @@ export CCACHE_DISABLE=1 echo `pwd` if [ "$scratch_new" = true ]; then echo Compiling openssl zlib lz4 emsdk libsodium emsdk ton - rm -rf openssl zlib lz4 emsdk libsodium build + rm -rf openssl zlib lz4 emsdk libsodium build openssl_em fi if [ ! -d "openssl" ]; then git clone https://github.com/openssl/openssl.git + cp -r openssl openssl_em cd openssl git checkout openssl-3.1.4 ./config @@ -44,11 +45,6 @@ else echo Using compiled openssl at $OPENSSL_DIR fi -cd third-party/secp256k1 -make clean -rm -rf .libs lib build -cd ../.. - if [ ! -d "build" ]; then mkdir build cd build @@ -75,8 +71,8 @@ echo fi cd emsdk -./emsdk install 3.1.19 -./emsdk activate 3.1.19 +./emsdk install 3.1.40 +./emsdk activate 3.1.40 EMSDK_DIR=`pwd` . $EMSDK_DIR/emsdk_env.sh @@ -86,9 +82,8 @@ export CCACHE_DISABLE=1 cd .. -if [ ! -f "openssl/openssl_em" ]; then - cd openssl - make clean +if [ ! -f "openssl_em/openssl_em" ]; then + cd openssl_em emconfigure ./Configure linux-generic32 no-shared no-dso no-engine no-unit-test no-tests no-fuzz-afl no-fuzz-libfuzzer sed -i 's/CROSS_COMPILE=.*/CROSS_COMPILE=/g' Makefile sed -i 's/-ldl//g' Makefile @@ -96,10 +91,12 @@ if [ ! -f "openssl/openssl_em" ]; then emmake make depend emmake make -j16 test $? -eq 0 || { echo "Can't compile OpenSSL with emmake "; exit 1; } + OPENSSL_DIR=`pwd` touch openssl_em cd .. else - echo Using compiled openssl with emscripten + OPENSSL_DIR=`pwd`/openssl_em + echo Using compiled with empscripten openssl at $OPENSSL_DIR fi if [ ! -d "zlib" ]; then @@ -183,5 +180,3 @@ if [ "$with_artifacts" = true ]; then cp -R crypto/smartcont artifacts cp -R crypto/fift/lib artifacts fi - - diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index 526b3292d..92684849d 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -324,12 +324,13 @@ target_include_directories(ton_crypto PRIVATE ${BLST_INCLUDE_DIR}) target_link_libraries(ton_crypto PRIVATE ${BLST_LIB}) target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_INCLUDE_DIR}>) -target_link_libraries(ton_crypto_core PUBLIC ${SECP256K1_LIBRARY}) -target_link_libraries(ton_crypto PUBLIC ${SECP256K1_LIBRARY}) if (MSVC) find_package(Sodium REQUIRED) target_compile_definitions(ton_crypto PUBLIC SODIUM_STATIC) +elseif (EMSCRIPTEN) + target_link_libraries(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SECP256K1_LIBRARY}>) + target_link_libraries(ton_crypto PUBLIC $<BUILD_INTERFACE:${SECP256K1_LIBRARY}>) else() if (NOT SODIUM_FOUND) find_package(Sodium REQUIRED) @@ -337,6 +338,8 @@ else() message(STATUS "Using Sodium ${SODIUM_LIBRARY_RELEASE}") endif() target_compile_definitions(ton_crypto PUBLIC SODIUM_STATIC) + target_link_libraries(ton_crypto_core PUBLIC ${SECP256K1_LIBRARY}) + target_link_libraries(ton_crypto PUBLIC ${SECP256K1_LIBRARY}) endif() target_include_directories(ton_crypto_core PUBLIC $<BUILD_INTERFACE:${SODIUM_INCLUDE_DIR}>)