Blanc v0.10: Rewrite the stars

Jeeyong Um
Turnpike
Published in
3 min readSep 7, 2021

--

Rewrite the stars from the movie “The Greatest Showman”

Rewrite the sta… no, smart contracts!

Blanc is a toolchain for wasm-based Blockchain smart contracts such as EOSIO and CosmWasm. It is forked from eosio.cdt provided officially by block.one, but its internal behaviors are changed a lot. Blanc takes RERO (Release Early, Release Often) strategy to achieve adoption of state-of-the-art technology, better compatibility and quick bug fixes.

https://github.com/turnpike/blanc/releases/tag/0.10.1

In this version, the code for tools is completely rewritten, so it comes to handle compiler or linker options by llvm::opt like real clang or lld does rather than catch command-line options by llvm::cl and regenerate from the limited set of supported options. The original way is a bit more flexible for custom options, but it broke IDE support like CLion. Now you can use CLion to develop EOSIO smart contract with auto-completion support by Blanc v0.10.

User-inserted clang options will be forwarded to compiler backend directly, so you can use almost all of them in most cases, but the options provided by eosio.cdt can be removed or changed their behaviors. Available options are listed in the following section.

Featured changes

  • CLion support
  • Libc++ 12
  • eosio.cdt v1.8 compatibility

CLion support

We need to pass CMake compiler identification to make CLion recognize blanc as clang. You can do this in two ways.

Way 1: find_package(blanc) and include(EosioWasmToolchain)

Way 2: Add dummy clang/clang++ to toolchain

Add dummy clang/clang++ to Setting-Build,Execution,Deployment-Toolchains. The paths for dummy clang are:

  • Linux: /usr/opt/blanc/0.10.1/bin
  • MacOS: /usr/local/opt/blanc/opt/blanc/bin

These paths will be changed in the next version. (It follows the same path of eosio.cdt, but not conventional.)

  • Set toolchain to Blanc in Settings-Build,Execution,Deployment-CMake .
  • Set your CMakeLists.txt like this:

Libc++ 12

Since v0.9, Blanc uses llvm-12 as its backend, but the standard libraries still stayed at libcxx-11. libcxx-12 is shipped together with Blanc v0.10 and you can get better C++20 support.

Now -std=c++20 is set by default unless you specified c++ standard version.

eosio.cdt v1.8 compatibility

eosio.cdt v1.8 provides many new features that are not applied to EOS mainnet yet such as action return value, kv store or read-only action.

Blanc v0.10 supports the features of eosio.cdt v1.8.1, but generated ABI has the version of eosio::abi/1.1 by default. If you want ABI v1.2, add the option --abi-version=1.2.

Supported eosio.cdt options

Following options are supported, but setting them in CMakeLists.txt breaks compiler identification and makes auto-completion disabled. You can use alternative definition macros.

Installation

Ubuntu 20.04

sudo add-apt-repository ppa:conr2d/blanc
sudo apt install blanc clang-12 lld-12 binaryen

Clang-12 is backported in Ubuntu 20.04, so launchpad PPA support is restored.

MacOS Big Sur

brew tap turnpike/blanc
brew install blanc llvm@12 binaryen

In the next version, it is planned to support Apple silicon, but currently the prebuild binary for Intel x86_64 is provided only.

Disclaimer

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.

--

--