Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1479 from EOSIO/binaryen_as_submod
Browse files Browse the repository at this point in the history
 Use eosio binaryen fork as a submodule
  • Loading branch information
b1bart authored Feb 27, 2018
2 parents f66d188 + 0760acd commit 116e5af
Show file tree
Hide file tree
Showing 11 changed files with 12 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/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory( binaryen )
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
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 116e5af

Please sign in to comment.