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 #29 from EOSIO/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
larryk85 authored Aug 1, 2018
2 parents 4a8eb03 + d220a0b commit 34ea771
Show file tree
Hide file tree
Showing 58 changed files with 6,095 additions and 551 deletions.
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

build/*
61 changes: 22 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
cmake_minimum_required(VERSION 3.5)
project(eosio_wasm_sdk VERSION 1.0.0)
project(eosio_wasm_sdk)

include(GNUInstallDirs)
set(VERSION_MAJOR 1)
set(VERSION_MINOR 1)
set(VERSION_PATCH 0)

set(SDK_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/eosio.wasmsdk)

if(NOT ${NO_WASM_COMPILER} STREQUAL "")
string(TOLOWER ${NO_WASM_COMPILER} no_wasm_comp)
if(NOT ${no_wasm_comp} STREQUAL "true")
### include eosio clang 7 as external project
include(ClangExternalProject.txt)
else(NOT ${no_wasm_comp} STREQUAL "true")
add_custom_target(EosioClang)
endif()
else(NOT ${NO_WASM_COMPILER} STREQUAL "")
set(no_wasm_comp "false")
include(ClangExternalProject.txt)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message(WARNING "CMAKE_INSTALL_PREFIX is set to default path of ${CMAKE_INSTALL_PREFIX}, resetting to ${CMAKE_INSTALL_PREFIX}/eosio.wasmsdk")
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/eosio.wasmsdk")
elseif ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local")
message(WARNING "CMAKE_INSTALL_PREFIX is explicitly set to /usr/local. This is not recommended.")
endif()
#include(ToolingExternalProject.txt)

include(GNUInstallDirs)

include(ClangExternalProject.txt)

add_subdirectory(external)

set(WASM_SDK_BUILD true)

configure_file(${CMAKE_SOURCE_DIR}/eosio.imports.in ${CMAKE_BINARY_DIR}/eosio.imports)
configure_file(${CMAKE_SOURCE_DIR}/modules/EosioWasmToolchainBuild.cmake.in ${CMAKE_BINARY_DIR}/lib/cmake/EosioWasmToolchain.cmake @ONLY)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}/lib/cmake")
include(EosioWasmToolchain)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules")
include(EosioWasmToolchainBuild)

if ("${CORE_SYMBOL_NAME}" STREQUAL "")
set( CORE_SYMBOL_NAME "SYS" )
Expand All @@ -41,30 +40,14 @@ endif()

add_subdirectory(libraries)

if ( ${no_wasm_comp} STREQUAL "false" )
include(InstallClang.txt)
endif()
include(InstallClang.txt)

message( STATUS "Using '${CORE_SYMBOL_NAME}' as CORE symbol name" )

# install examples
install(DIRECTORY examples DESTINATION "${SDK_INSTALL_PREFIX}")

install(EXPORT EosioLib DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)

set(INCLUDE_INSTALL_DIR ${SDK_INSTALL_PREFIX}/include)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(EosioLibConfigVersion.cmake
COMPATIBILITY SameMajorVersion)

configure_package_config_file(${CMAKE_SOURCE_DIR}/modules/EosioLibConfig.cmake.in EosioLibConfig.cmake
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/"
PATH_VARS INCLUDE_INSTALL_DIR)
#install(DIRECTORY examples DESTINATION "${CMAKE_INSTALL_PREFIX}")

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EosioLibConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EosioLibConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
configure_file(${CMAKE_SOURCE_DIR}/modules/EosioWasmToolchain.cmake.in ${CMAKE_BINARY_DIR}/modules/EosioWasmToolchain.cmake @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/modules/EosioWasmToolchain.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
install(FILES ${CMAKE_BINARY_DIR}/eosio.imports DESTINATION ${SDK_INSTALL_PREFIX})
install(FILES ${CMAKE_BINARY_DIR}/modules/EosioWasmToolchain.cmake DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake)
configure_file(${CMAKE_SOURCE_DIR}/eosio.imports.in ${CMAKE_BINARY_DIR}/eosio.imports COPYONLY)
install(FILES ${CMAKE_BINARY_DIR}/eosio.imports DESTINATION ${CMAKE_INSTALL_PREFIX})
3 changes: 2 additions & 1 deletion ClangExternalProject.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ include(GNUInstallDirs)

ExternalProject_Add(
EosioClang
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${SDK_INSTALL_PREFIX}/llvm -DBOOST_ROOT=${BOOST_ROOT} -DEOSIO_INSTALL=${SDK_INSTALL_PREFIX}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/llvm -DCMAKE_BUILD_TYPE=Release -DBOOST_ROOT=${BOOST_ROOT} -DSDK_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DEOSIO_VER_MAJOR=${VERSION_MAJOR} -DEOSIO_VER_MINOR=${VERSION_MINOR} -DEOSIO_VER_REVISION=${VERSION_PATCH} -DEOSIO_STACK_SIZE=8192

SOURCE_DIR "${CMAKE_SOURCE_DIR}/eosio_llvm"
UPDATE_COMMAND ""
PATCH_COMMAND ""
TEST_COMMAND ""
INSTALL_COMMAND ""
BUILD_ALWAYS 1
)
60 changes: 21 additions & 39 deletions InstallClang.txt
Original file line number Diff line number Diff line change
@@ -1,78 +1,60 @@
macro(install_symlink from to)
install(CODE
"execute_process(COMMAND mkdir -p ${SDK_INSTALL_PREFIX}/bin)
execute_process(COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/bin)
execute_process(COMMAND ln -sf ${SDK_INSTALL_PREFIX}/bin/${from} ${CMAKE_INSTALL_PREFIX}/bin/${to})")
endmacro()

install_symlink(llvm-ranlib eosio.ranlib)

# install clang and llvm
set(CLANG_BIN_DIR ${CMAKE_BINARY_DIR}/EosioClang-prefix/src/EosioClang-build/bin)
install(FILES ${CLANG_BIN_DIR}/llvm-ranlib
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-ar
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-nm
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-objcopy
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-readobj
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-objdump
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-readelf
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/opt
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llc
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/lld
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/llvm-strip
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/clang-7
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/wasm-ld
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/eosio-cc
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/eosio-cpp
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/eosio-ld
DESTINATION ${SDK_INSTALL_PREFIX}/bin
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install(FILES ${CLANG_BIN_DIR}/../lib/LLVMEosioApply${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${SDK_INSTALL_PREFIX}/bin)

install_symlink(llvm-ranlib eosio-ranlib)
install_symlink(llvm-ar eosio-ar)
install_symlink(llvm-objdump eosio-objdump)
install_symlink(llvm-readelf eosio-readelf)
install_symlink(eosio-cc eosio-cc)
install_symlink(eosio-cpp eosio-cpp)
install_symlink(eosio-ld eosio-ld)

DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
install(CODE "
execute_process(COMMAND ln -sf
${SDK_INSTALL_PREFIX}/bin/clang-7
${SDK_INSTALL_PREFIX}/bin/clang)")
${CMAKE_INSTALL_FULL_BINDIR}/clang-7
${CMAKE_INSTALL_FULL_BINDIR}/clang)")
install(CODE "
execute_process(COMMAND ln -sf
${SDK_INSTALL_PREFIX}/bin/clang-7
${SDK_INSTALL_PREFIX}/bin/clang++)")
${CMAKE_INSTALL_FULL_BINDIR}/clang-7
${CMAKE_INSTALL_FULL_BINDIR}/clang++)")
12 changes: 6 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018, Respective Authors all rights reserved.

Copyright (c) 2018 EOSIO
The MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -9,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
36 changes: 5 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# WasmSDK
## Version : 1.0.0
## Version : 1.1.0

WasmSDK is a toolchain for WebAssembly (WASM). In addition to being a general purpose WebAssembly toolchain, [EOSIO](https://github.com/eosio/eos) specific optimizations are available to support building EOSIO smart contracts. This new toolchain is built around [Clang 7](https://github.com/eosio/llvm), which means that the SDK has the most currently available optimizations and analyses from LLVM, but as the WASM target is still considered experimental, some optimizations are not available or incomplete.

Expand Down Expand Up @@ -30,43 +30,15 @@ $ ./build.sh <CORE_SYMBOL>
Finally, install the build
*This install will install the core to ```/usr/local/eosio.wasmsdk``` and symlinks to the top level tools (compiler, ld, etc.) to ```/usr/local/bin```
```sh
$ cd build
$ sudo make install
```

### Manual Installation
`WasmSDK requires CMake v3.5+ and Boost 1.67.0 to run.`

First clone the repo and create a build directory

```sh
$ git clone --recursive https://github.com/eosio/wasmsdk
$ cd wasmsdk
$ mkdir build && cd build
```

Then configure with cmake to install to ```/usr/local/eosio.wasmsdk```

```sh
$ cmake ..
```

or configure cmake to install to a specific path
```sh
$ cmake -DCMAKE_INSTALL_PREFIX=<install path> ..
```

Then to install, simply
```sh
$ make && make install
$ sudo ./install.sh
```

### Installed Tools
---
* [eosio-cpp](#eosio-cpp)
* [eosio-cc](#eosio-cc)
* [eosio-ld](#eosio-ld)
* eosio-pp (only strips all zeroed initialized data segments for now, currently runs automatically with cpp/cc and ld)
* eosio-pp (post processing pass for WASM, automatically runs with eosio-cpp and eosio-ld)
* eosio-ranlib
* eosio-ar
* eosio-objdump
Expand Down Expand Up @@ -179,6 +151,8 @@ eosio.ld options:
-L=<string> - Add directory to library search path
-fno-cfl-aa - Disable CFL Alias Analysis
-fno-lto - Disable LTO
-fno-post-pass - Don't run post processing pass
-fno-stack-first - Don't set the stack first in memory
-l=<string> - Root name of library to link
-lto-opt=<string> - LTO Optimization level (O0-O3)
-o=<string> - Write output to <file>
Expand Down
37 changes: 35 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ printf "\t=========== Building eosio.wasmsdk ===========\n\n"

RED='\033[0;31m'
NC='\033[0m'
txtbld=$(tput bold)
bldred=${txtbld}$(tput setaf 1)
txtrst=$(tput sgr0)

export DISK_MIN=10
export TEMP_DIR="/tmp"
Expand Down Expand Up @@ -55,11 +58,41 @@ if [ $# -ge 1 ]; then
CORE_SYMBOL=$1
fi

if [[ `uname` == 'Darwin' ]]; then
FREE_MEM=`vm_stat | grep "Pages free:"`
read -ra FREE_MEM <<< "$FREE_MEM"
FREE_MEM=$((${FREE_MEM[2]%?}*(4096))) # free pages * page size
else
FREE_MEM=`free | grep "Mem:" | awk '{print $4}'`
fi

CORES_AVAIL=`getconf _NPROCESSORS_ONLN`
MEM_CORES=$(( ${FREE_MEM}/4000000 )) # 4 gigabytes per core
CORES=$(( $CORES_AVAIL < $MEM_CORES ? $CORES_AVAIL : $MEM_CORES ))

CORES=`getconf _NPROCESSORS_ONLN`
mkdir -p build
pushd build &> /dev/null
cmake -DBOOST_ROOT="${BOOST}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL}" ../
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/eosio.wasmsdk -DBOOST_ROOT="${BOOST}" -DCORE_SYMBOL_NAME="${CORE_SYMBOL}" ../
if [ $? -ne 0 ]; then
exit -1;
fi
make -j${CORES}
if [ $? -ne 0 ]; then
exit -1;
fi
popd &> /dev/null

printf "\n${bldred}\t ___ ___ ___ ___\n"
printf "\t / /\\ / /\\ / /\\ ___ / /\\ \n"
printf "\t / /:/_ / /::\\ / /:/_ / /\\ / /::\\ \n"
printf "\t / /:/ /\\ / /:/\\:\\ / /:/ /\\ / /:/ / /:/\\:\\ \n"
printf "\t / /:/ /:/_ / /:/ \\:\\ / /:/ /::\\ /__/::\\ / /:/ \\:\\ \n"
printf "\t /__/:/ /:/ /\\ /__/:/ \\__\\:\\ /__/:/ /:/\\:\\ \\__\\/\\:\\__ /__/:/ \\__\\:\\ \n"
printf "\t \\ \\:\\/:/ /:/ \\ \\:\\ / /:/ \\ \\:\\/:/~/:/ \\ \\:\\/\\ \\ \\:\\ / /:/ \n"
printf "\t \\ \\::/ /:/ \\ \\:\\ /:/ \\ \\::/ /:/ \\__\\::/ \\ \\:\\ /:/ \n"
printf "\t \\ \\:\\/:/ \\ \\:\\/:/ \\__\\/ /:/ /__/:/ \\ \\:\\/:/ \n"
printf "\t \\ \\::/ \\ \\::/ /__/:/ \\__\\/ \\ \\::/ \n"
printf "\t \\__\\/ \\__\\/ \\__\\/ \\__\\/ \n${txtrst}"

printf "\\tFor more information:\\n"
printf "\\tEOSIO website: https://eos.io\\n"
2 changes: 1 addition & 1 deletion eosio_llvm
Submodule eosio_llvm updated 1 files
+1 −1 tools/clang
Loading

0 comments on commit 34ea771

Please sign in to comment.