Skip to content

Commit

Permalink
Use eosio binaryen fork as a submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
spoonincode committed Feb 26, 2018
1 parent f66d188 commit bb2217c
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 117 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
31 changes: 2 additions & 29 deletions CMakeModules/wasm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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 $<TARGET_FILE:eosio-s2wasm> -o ${DESTINATION_FOLDER}/${target}.wast -s 4096 ${MAX_MEMORY_PARAM} ${target}.s
COMMENT "Generating WAST ${target}.wast"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
VERBATIM
Expand Down
4 changes: 1 addition & 3 deletions eosio_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions externals/binaryen
Submodule binaryen added at 0b980a
21 changes: 0 additions & 21 deletions scripts/eosio_build_amazon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 0 additions & 20 deletions scripts/eosio_build_darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 0 additions & 21 deletions scripts/eosio_build_fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 0 additions & 21 deletions scripts/eosio_build_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
45 changes: 45 additions & 0 deletions tests/chain_tests/proof_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,51 @@ bool proof_is_valid(const digest_type& digest, const vector<digest_type>& path,

BOOST_AUTO_TEST_SUITE(proof_tests)

static const char poo[] = R"=====(
(module
(table 0 anyfunc)
(memory $0 16)
(export "memory" (memory $0))
(export "apply" (func $apply))

(func $complex_stuff_and_return_a_bool (result i32)
(i32.const 0)
)

(func $apply (param $0 i64) (param $1 i64)
(br_if 0 (call $complex_stuff_and_return_a_bool))

(drop (i64.mul (i64.const 56) (i64.const 34)))
(drop (i64.mul (i64.const 12) (i64.const 55)))
(drop (i64.mul (i64.const 536) (i64.const 2333)))
(drop (i64.mul (i64.const 23) (i64.const 12)))
(drop (i64.mul (i64.const 543) (i64.const 76533)))
)
)
)=====";

BOOST_FIXTURE_TEST_CASE( big_memory, tester ) try {
produce_blocks(2);

create_accounts( {N(bigmem)} );
produce_block();

set_code(N(bigmem), poo);
produce_blocks(1);

signed_transaction trx;
action act;
act.account = N(bigmem);
act.name = N();
act.authorization = vector<permission_level>{{N(bigmem),config::active_name}};
trx.actions.push_back(act);

set_tapos(trx);
trx.sign(get_private_key( N(bigmem), "active" ), chain_id_type());
push_transaction(trx);

} FC_LOG_AND_RETHROW()

BOOST_FIXTURE_TEST_CASE( prove_block_in_chain, tester ) { try {
vector<block_id_type> known_blocks;
known_blocks.reserve(100);
Expand Down
4 changes: 2 additions & 2 deletions tools/eosiocpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb2217c

Please sign in to comment.