Skip to content

Commit

Permalink
check llvm version >= 7 and install automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaipanda committed May 1, 2020
1 parent 12b1ad1 commit 9509dd7
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 28 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
message(FATAL_ERROR "Clang version must be at least 6.0!")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
message(FATAL_ERROR "Clang version must be at least 7.0!")
endif()
endif()

Expand Down
16 changes: 8 additions & 8 deletions eosio_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
fi
START_MAKE=true
TIME_BEGIN=$( date -u +%s )
VERSION=1.2
VERSION=3.0.7

txtbld=$(tput bold)
bldred=${txtbld}$(tput setaf 1)
Expand Down Expand Up @@ -174,7 +174,7 @@
MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
export CMAKE=${HOME}/opt/cmake/bin/cmake
export PATH=${HOME}/opt/mongodb/bin:$PATH
export PATH=${HOME}/opt/mongodb/bin:${HOME}/opt/wasm/bin:$PATH
;;
"CentOS Linux")
FILE="${SOURCE_DIR}/scripts/eosio_build_centos.sh"
Expand All @@ -183,14 +183,14 @@
MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
export LLVM_DIR=${HOME}/opt/wasm/lib/cmake/llvm
export CMAKE=${HOME}/opt/cmake/bin/cmake
export PATH=${HOME}/opt/mongodb/bin:$PATH
export PATH=${HOME}/opt/mongodb/bin:${HOME}/opt/wasm/bin:$PATH
;;
"elementary OS")
FILE="${SOURCE_DIR}/scripts/eosio_build_ubuntu.sh"
CXX_COMPILER=clang++
C_COMPILER=clang
MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
export PATH=${HOME}/opt/mongodb/bin:$PATH
export PATH=${HOME}/opt/mongodb/bin:${HOME}/opt/wasm/bin:$PATH
;;
"Fedora")
FILE="${SOURCE_DIR}/scripts/eosio_build_fedora.sh"
Expand All @@ -204,21 +204,21 @@
CXX_COMPILER=clang++
C_COMPILER=clang
MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
export PATH=${HOME}/opt/mongodb/bin:$PATH
export PATH=${HOME}/opt/mongodb/bin:${HOME}/opt/wasm/bin:$PATH
;;
"Ubuntu")
FILE="${SOURCE_DIR}/scripts/eosio_build_ubuntu.sh"
CXX_COMPILER=clang++
C_COMPILER=clang
MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
export PATH=${HOME}/opt/mongodb/bin:$PATH
export PATH=${HOME}/opt/mongodb/bin:${HOME}/opt/wasm/bin:$PATH
;;
"Debian GNU/Linux")
FILE=${SOURCE_DIR}/scripts/eosio_build_ubuntu.sh
CXX_COMPILER=clang++
C_COMPILER=clang
MONGOD_CONF=${HOME}/opt/mongodb/mongod.conf
export PATH=${HOME}/opt/mongodb/bin:$PATH
export PATH=${HOME}/opt/mongodb/bin:${HOME}/opt/wasm/bin:$PATH
;;
*)
printf "\\n\\tUnsupported Linux Distribution. Exiting now.\\n\\n"
Expand Down Expand Up @@ -274,7 +274,7 @@
-DENABLE_COVERAGE_TESTING="${ENABLE_COVERAGE_TESTING}" -DBUILD_DOXYGEN="${DOXYGEN}" \
-DCMAKE_CXX_STANDARD_LIBRARIES="-lpthread" \
-DCMAKE_INSTALL_PREFIX="/usr/local/eosio" ${LOCAL_CMAKE_FLAGS} "${SOURCE_DIR}" \
-DENABLE_TOOLS=OFF
-DENABLE_TOOLS=OFF
then
printf "\\n\\t>>>>>>>>>>>>>>>>>>>> CMAKE building BOSCore has exited with the above error.\\n\\n"
exit -1
Expand Down
20 changes: 16 additions & 4 deletions scripts/eosio_build_amazon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,20 @@ fi
printf "\\tMongo C++ driver found at /usr/local/lib64/libmongocxx-static.a.\\n"
fi

printf "\\n\\tChecking LLVM with WASM support.\\n"
if [ ! -d "${HOME}/opt/wasm/bin" ]; then
printf "\\n\\tChecking for LLVM with WASM support.\\n"
CLANG_INSTALL=false
if ! type clang > /dev/null ; then
CLANG_INSTALL=true
echo "Failed to find clang, it will install automatically."
else
CLANG_V=$(clang --version | grep version 2>/dev/null | sed 's/[^0-9]*//g' | head -c1)
if [ "${CLANG_V}" -lt 7 ] ; then
echo "BOSCore need clange version high than v7, current install $CLANG_V, it will install automatically."
CLANG_INSTALL=true
fi
fi

if [ $CLANG_INSTALL == true ]; then
printf "\\tInstalling LLVM & WASM.\\n"
if ! cd "${TEMP_DIR}"
then
Expand All @@ -556,7 +568,7 @@ fi
printf "\\n\\tExiting now.\\n"
exit 1;
fi
if ! git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git
if ! git clone --depth 1 --single-branch --branch release_90 https://github.com/llvm-mirror/llvm.git
then
printf "\\tUnable to clone llvm repo @ https://github.com/llvm-mirror/llvm.git.\\n"
printf "\\tExiting now.\\n\\n"
Expand All @@ -568,7 +580,7 @@ fi
printf "\\n\\tExiting now.\\n"
exit 1;
fi
if ! git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git
if ! git clone --depth 1 --single-branch --branch release_90 https://github.com/llvm-mirror/clang.git
then
printf "\\tUnable to clone clang repo @ https://github.com/llvm-mirror/clang.git.\\n"
printf "\\tExiting now.\\n\\n"
Expand Down
22 changes: 17 additions & 5 deletions scripts/eosio_build_centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,20 @@ mongodconf

printf "\\n"

printf "\\tChecking LLVM with WASM support installation...\\n"
if [ ! -d "${HOME}/opt/wasm/bin" ]; then
printf "\\n\\tChecking for LLVM with WASM support.\\n"
CLANG_INSTALL=false
if ! type clang > /dev/null ; then
CLANG_INSTALL=true
echo "Failed to find clang, it will install automatically."
else
CLANG_V=$(clang --version | grep version 2>/dev/null | sed 's/[^0-9]*//g' | head -c1)
if [ "${CLANG_V}" -lt 7 ] ; then
echo "BOSCore need clange version high than v7, current install $CLANG_V, it will install automatically."
CLANG_INSTALL=true
fi
fi

if [ $CLANG_INSTALL == true ]; then
printf "\\tInstalling LLVM with WASM...\\n"
if ! cd "${TEMP_DIR}"; then
printf "\\t!! Unable to enter directory %s !!\\n" "${TEMP_DIR}"
Expand All @@ -629,7 +641,7 @@ mongodconf
exit 1;
fi
LLVMURL="https://github.com/llvm-mirror/llvm.git"
if ! git clone --depth 1 --single-branch --branch release_40 "${LLVMURL}"; then
if ! git clone --depth 1 --single-branch --branch release_90 "${LLVMURL}"; then
printf "\\t!! Unable to clone llvm repo from ${LLVMURL} !!\\n"
printf "\\tExiting now.\\n"
exit 1;
Expand All @@ -641,7 +653,7 @@ mongodconf
exit 1;
fi
CLANGURL="https://github.com/llvm-mirror/clang.git"
if ! git clone --depth 1 --single-branch --branch release_40 "${CLANGURL}"; then
if ! git clone --depth 1 --single-branch --branch release_90 "${CLANGURL}"; then
printf "\\t!! Unable to clone clang repo from ${CLANGURL} !!\\n"
printf "\\tExiting now.\\n"
exit 1;
Expand All @@ -663,7 +675,7 @@ mongodconf
exit 1;
fi
if ! "${CMAKE}" -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${HOME}/opt/wasm" \
-DLLVM_TARGETS_TO_BUILD="host" -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="WebAssembly" \
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="WebAssembly" \
-DLLVM_ENABLE_RTTI=1 -DCMAKE_BUILD_TYPE="Release" ..; then
printf "\\t!! CMake has exited with the above error !!\\n"
printf "\\tExiting now.\\n"
Expand Down
20 changes: 16 additions & 4 deletions scripts/eosio_build_fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,20 @@
printf "\\tMongo C++ driver found at /usr/local/lib64/libmongocxx-static.a.\\n"
fi

printf "\\n\\tChecking LLVM with WASM support installation.\\n"
if [ ! -d "${HOME}/opt/wasm/bin" ]; then
printf "\\n\\tChecking for LLVM with WASM support.\\n"
CLANG_INSTALL=false
if ! type clang > /dev/null ; then
CLANG_INSTALL=true
echo "Failed to find clang, it will install automatically."
else
CLANG_V=$(clang --version | grep version 2>/dev/null | sed 's/[^0-9]*//g' | head -c1)
if [ "${CLANG_V}" -lt 7 ] ; then
echo "BOSCore need clange version high than v7, current install $CLANG_V, it will install automatically."
CLANG_INSTALL=true
fi
fi

if [ $CLANG_INSTALL == true ]; then
printf "\\tInstalling LLVM & WASM\\n"
if ! cd "${TEMP_DIR}"
then
Expand All @@ -415,7 +427,7 @@
printf "\\n\\tExiting now.\\n"
exit 1;
fi
if ! git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git
if ! git clone --depth 1 --single-branch --branch release_90 https://github.com/llvm-mirror/llvm.git
then
printf "\\tUnable to clone llvm repo @ https://github.com/llvm-mirror/llvm.git.\\n"
printf "\\n\\tExiting now.\\n"
Expand All @@ -439,7 +451,7 @@
printf "\\n\\tExiting now.\\n"
exit 1;
fi
if ! git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git
if ! git clone --depth 1 --single-branch --branch release_90 https://github.com/llvm-mirror/clang.git
then
printf "\\tUnable to clone clang repo @ https://github.com/llvm-mirror/clang.git.\\n"
printf "\\n\\tExiting now.\\n"
Expand Down
23 changes: 18 additions & 5 deletions scripts/eosio_build_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -421,19 +421,31 @@ mongodconf
else
printf "\\tMongo C++ driver found at /usr/local/lib/libmongocxx-static.a.\\n"
fi

printf "\\n\\tChecking for LLVM with WASM support.\\n"
if [ ! -d "${HOME}/opt/wasm/bin" ]; then
CLANG_INSTALL=false
if ! type clang > /dev/null ; then
CLANG_INSTALL=true
echo "Failed to find clang, it will install automatically."
else
CLANG_V=$(clang --version | grep version 2>/dev/null | sed 's/[^0-9]*//g' | head -c1)
if [ "${CLANG_V}" -lt 7 ] ; then
echo "BOSCore need clange version high than v7, current install $CLANG_V, it will install automatically."
CLANG_INSTALL=true
fi
fi

if [ $CLANG_INSTALL == true ]; then
# Build LLVM and clang with WASM support:
printf "\\tInstalling LLVM with WASM\\n"
if ! cd "${TEMP_DIR}"
then
then
printf "\\n\\tUnable to cd into directory %s.\\n" "${TEMP_DIR}"
printf "\\n\\tExiting now.\\n"
exit 1;
fi
if ! mkdir "${TEMP_DIR}/llvm-compiler" 2>/dev/null
then
then
printf "\\n\\tUnable to create directory %s/llvm-compiler.\\n" "${TEMP_DIR}"
printf "\\n\\tExiting now.\\n"
exit 1;
Expand Down Expand Up @@ -480,7 +492,8 @@ mongodconf
printf "\\n\\tExiting now.\\n"
exit 1;
fi
if ! cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${HOME}/opt/wasm" -DLLVM_TARGETS_TO_BUILD= \
# Refer : https://llvm.org/docs/CMake.html
if ! cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="${HOME}/opt/wasm" -DLLVM_ENABLE_RTTI=1 \
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release ../
then
printf "\\tError compiling LLVM and clang with EXPERIMENTAL WASM support.0\\n"
Expand Down

0 comments on commit 9509dd7

Please sign in to comment.