diff --git a/.gitmodules b/.gitmodules index daa6a58c2dc..e25104d077a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -17,3 +17,6 @@ path = contracts/libc++/upstream url = https://github.com/EOSIO/libcxx.git branch = eosio +[submodule "externals/binaryen"] + path = externals/binaryen + url = https://github.com/EOSIO/binaryen diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bde96a85f2..2e8a7dc75e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,6 +164,8 @@ if(ENABLE_COVERAGE_TESTING) find_program( GENHTML_PATH NAMES genhtml) endif() +add_subdirectory( externals ) + include(wasm) if(WASM_TOOLCHAIN) message(STATUS "Using WASM clang => " ${WASM_CLANG}) diff --git a/CMakeModules/wasm.cmake b/CMakeModules/wasm.cmake index 464d1748066..337ad37b367 100644 --- a/CMakeModules/wasm.cmake +++ b/CMakeModules/wasm.cmake @@ -26,35 +26,8 @@ else() set(WASM_LLVM_LINK $ENV{WASM_LLVM_LINK}) endif() -if( NOT ("${WASM_CLANG}" STREQUAL "" OR "${WASM_LLC}" STREQUAL "" OR "${WASM_LLVM_LINK}" STREQUAL "") ) - if( NOT "${BINARYEN_ROOT}" STREQUAL "" ) - - if(EXISTS "${BINARYEN_ROOT}/bin/s2wasm") - - set(BINARYEN_BIN ${BINARYEN_ROOT}/bin) - - endif() - - else() - - message(STATUS "BINARYEN_BIN not defined looking in PATH") - find_path(BINARYEN_BIN - NAMES s2wasm - ENV PATH ) - if (BINARYEN_BIN AND NOT EXISTS ${BINARYEN_ROOT}/s2wasm) - - unset(BINARYEN_BIN) - - endif() - - endif() - - message(STATUS "BINARYEN_BIN => " ${BINARYEN_BIN}) - -endif() - # TODO: Check if compiler is able to generate wasm32 -if( NOT ("${WASM_CLANG}" STREQUAL "" OR "${WASM_LLC}" STREQUAL "" OR "${WASM_LLVM_LINK}" STREQUAL "" OR NOT BINARYEN_BIN) ) +if( NOT ("${WASM_CLANG}" STREQUAL "" OR "${WASM_LLC}" STREQUAL "" OR "${WASM_LLVM_LINK}" STREQUAL "") ) set(WASM_TOOLCHAIN TRUE) endif() @@ -199,7 +172,7 @@ macro(add_wast_executable) add_custom_command(OUTPUT ${DESTINATION_FOLDER}/${target}.wast DEPENDS ${target}.s - COMMAND ${BINARYEN_BIN}/s2wasm -o ${DESTINATION_FOLDER}/${target}.wast -s 4096 ${MAX_MEMORY_PARAM} ${target}.s + COMMAND $ -o ${DESTINATION_FOLDER}/${target}.wast -s 4096 ${MAX_MEMORY_PARAM} ${target}.s COMMENT "Generating WAST ${target}.wast" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM diff --git a/eosio_build.sh b/eosio_build.sh index 8c62bbaea5c..e0406cd6fdc 100755 --- a/eosio_build.sh +++ b/eosio_build.sh @@ -81,7 +81,6 @@ esac export BOOST_ROOT=${HOME}/opt/boost_1_66_0 - export BINARYEN_BIN=${HOME}/opt/binaryen/bin export OPENSSL_ROOT_DIR=/usr/include/openssl export OPENSSL_LIBRARIES=/usr/include/openssl export WASM_LLVM_CONFIG=${HOME}/opt/wasm/bin/llvm-config @@ -93,7 +92,6 @@ if [ $ARCH == "Darwin" ]; then OPENSSL_ROOT_DIR=/usr/local/opt/openssl OPENSSL_LIBRARIES=/usr/local/opt/openssl/lib - BINARYEN_BIN=/usr/local/binaryen/bin/ WASM_LLVM_CONFIG=/usr/local/wasm/bin/llvm-config CXX_COMPILER=clang++ C_COMPILER=clang @@ -122,7 +120,7 @@ # Build EOS $CMAKE -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} \ -DCMAKE_C_COMPILER=${C_COMPILER} -DWASM_LLVM_CONFIG=${WASM_LLVM_CONFIG} \ - -DBINARYEN_BIN=${BINARYEN_BIN} -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} \ + -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} \ -DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES} .. if [ $? -ne 0 ]; then printf "\n\t>>>>>>>>>>>>>>>>>>>> CMAKE building EOSIO has exited with the above error.\n\n" diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt new file mode 100644 index 00000000000..4fac3528746 --- /dev/null +++ b/externals/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory( binaryen ) diff --git a/externals/binaryen b/externals/binaryen new file mode 160000 index 00000000000..0b980a9e877 --- /dev/null +++ b/externals/binaryen @@ -0,0 +1 @@ +Subproject commit 0b980a9e87740db4d657ee38b2668da35752264e diff --git a/scripts/eosio_build_amazon.sh b/scripts/eosio_build_amazon.sh index b2e51cfba02..efa49cf05e2 100644 --- a/scripts/eosio_build_amazon.sh +++ b/scripts/eosio_build_amazon.sh @@ -172,27 +172,6 @@ printf "\tsecp256k1 found\n" fi - printf "\n\tChecking for binaryen\n" - if [ ! -d ${HOME}/opt/binaryen ]; then - # Install binaryen v1.37.14: - printf "\tInstalling binaryen v1.37.14:\n" - cd ${TEMP_DIR} - git clone https://github.com/WebAssembly/binaryen - cd binaryen - git checkout tags/1.37.14 - $CMAKE . && make -j${CPU_CORE} - if [ $? -ne 0 ]; then - printf "\tError compiling binaryen.\n" - printf "\tExiting now.\n\n" - exit; - fi - mkdir -p ${HOME}/opt/binaryen/ 2>/dev/null - mv ${TEMP_DIR}/binaryen/bin ${HOME}/opt/binaryen/ - rm -rf ${TEMP_DIR}/binaryen - else - printf "\tBinaryen found at ${HOME}/opt/binaryen\n" - fi - printf "\n\tChecking for LLVM with WASM support.\n" if [ ! -d ${HOME}/opt/wasm/bin ]; then # Build LLVM and clang with EXPERIMENTAL WASM support: diff --git a/scripts/eosio_build_darwin.sh b/scripts/eosio_build_darwin.sh index 5242462687b..ab253023ed2 100644 --- a/scripts/eosio_build_darwin.sh +++ b/scripts/eosio_build_darwin.sh @@ -181,26 +181,6 @@ printf "\tsecp256k1 found at /usr/local/lib/\n" fi - printf "\n\tChecking for binaryen\n" - if [ ! -e /usr/local/binaryen/bin/binaryen.js ]; then - cd ${TEMP_DIR} - git clone https://github.com/WebAssembly/binaryen - cd binaryen - git checkout tags/1.37.14 - cmake . && make -j${CPU_CORE} - if [ $? -ne 0 ]; then - printf "\tError compiling binaryen.\n" - printf "\tExiting now.\n\n" - exit; - fi - sudo mkdir /usr/local/binaryen - sudo mv ${TEMP_DIR}/binaryen/bin /usr/local/binaryen - sudo ln -s /usr/local/binaryen/bin/* /usr/local - sudo rm -rf ${TEMP_DIR}/binaryen - else - printf "\tBinaryen found at /usr/local/binaryen/bin/\n" - fi - printf "\n\tChecking for WASM\n" if [ ! -d /usr/local/wasm/bin ]; then # Build LLVM and clang for WASM: diff --git a/scripts/eosio_build_fedora.sh b/scripts/eosio_build_fedora.sh index 94a83e93854..159fb37d34d 100644 --- a/scripts/eosio_build_fedora.sh +++ b/scripts/eosio_build_fedora.sh @@ -145,27 +145,6 @@ printf "\tsecp256k1 found\n" fi - printf "\n\tChecking for binaryen\n" - if [ ! -d ${HOME}/opt/binaryen ]; then - # Install binaryen v1.37.14: - printf "\tInstalling binaryen v1.37.14:\n" - cd ${TEMP_DIR} - git clone https://github.com/WebAssembly/binaryen - cd binaryen - git checkout tags/1.37.14 - cmake . && make -j${CPU_CORE} - if [ $? -ne 0 ]; then - printf "\tError compiling binaryen.\n" - printf "\tExiting now.\n\n" - exit; - fi - mkdir -p ${HOME}/opt/binaryen/ 2>/dev/null - mv ${TEMP_DIR}/binaryen/bin ${HOME}/opt/binaryen/ - rm -rf ${TEMP_DIR}/binaryen - else - printf "\tBinaryen found at ${HOME}/opt/binaryen\n" - fi - printf "\n\tChecking for LLVM with WASM support.\n" if [ ! -d ${HOME}/opt/wasm/bin ]; then # Build LLVM and clang with EXPERIMENTAL WASM support: diff --git a/scripts/eosio_build_ubuntu.sh b/scripts/eosio_build_ubuntu.sh index 6c3926ea26a..c394167d561 100644 --- a/scripts/eosio_build_ubuntu.sh +++ b/scripts/eosio_build_ubuntu.sh @@ -127,27 +127,6 @@ printf "\tsecp256k1 found\n" fi - printf "\n\tChecking for binaryen\n" - if [ ! -d ${HOME}/opt/binaryen ]; then - # Install binaryen v1.37.14: - printf "\tInstalling binaryen v1.37.14:\n" - cd ${TEMP_DIR} - git clone https://github.com/WebAssembly/binaryen - cd binaryen - git checkout tags/1.37.14 - cmake . && make -j${CPU_CORE} - if [ $? -ne 0 ]; then - printf "\tError compiling binaryen.\n" - printf "\tExiting now.\n\n" - exit; - fi - mkdir -p ${HOME}/opt/binaryen/ 2>/dev/null - mv ${TEMP_DIR}/binaryen/bin ${HOME}/opt/binaryen/ - rm -rf ${TEMP_DIR}/binaryen - else - printf "\tBinaryen found at ${HOME}/opt/binaryen\n" - fi - printf "\n\tChecking for LLVM with WASM support.\n" if [ ! -d ${HOME}/opt/wasm/bin ]; then # Build LLVM and clang for WASM: diff --git a/tools/eosiocpp.in b/tools/eosiocpp.in index 4664ecfc0fd..8a55ed0c034 100755 --- a/tools/eosiocpp.in +++ b/tools/eosiocpp.in @@ -40,8 +40,8 @@ function build_contract { @WASM_LLVM_LINK@ -o $workdir/linked.bc $workdir/built/* # echo @WASM_LLC@ --asm-verbose=false -o $workdir/assembly.s $workdir/linked.bc @WASM_LLC@ --asm-verbose=false -o $workdir/assembly.s $workdir/linked.bc -# echo @BINARYEN_BIN@/s2wasm -o $outname -s 16384 $workdir/assembly.s - @BINARYEN_BIN@/s2wasm -o $outname -s 16384 $workdir/assembly.s +# echo ${EOSIO_INSTALL_DIR}/bin/eosio-s2wasm -o $outname -s 16384 $workdir/assembly.s + ${EOSIO_INSTALL_DIR}/bin/eosio-s2wasm -o $outname -s 16384 $workdir/assembly.s # echo rm -rf $workdir rm -rf $workdir