From c4a147d8b2116da095c5d876b0cceca08a1a0035 Mon Sep 17 00:00:00 2001 From: Xuejie Xiao Date: Mon, 23 Sep 2024 09:59:14 +0800 Subject: [PATCH] Disable RISC-V A extension by default (#17) * Disable RISC-V A extension by default While there is experimental support for A extension in CKB-VM, no CKB versions enable A extension for now. This commit fixes makefile so we are not generating any instruction from A extension by default, which would be a benefit for developers(since they don't have to do this by themselves) * Add notes to document affected changes --- README.md | 11 +++++++++++ contract/Makefile | 2 +- stack-reorder-contract/Makefile | 2 +- standalone-contract/Makefile | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8e71eaf..7ed3262 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,17 @@ This repository keeps a series of CKB script templates that can be inflated via [cargo-generate](https://github.com/cargo-generate/cargo-generate). Those templates enable a native development flow on mainstream Linux, macOS and Windows machines using stock version of latest stable Rust & clang C compiler. +## Noticeable Changes + +### Molecule uses bytes crates + + [molecule](https://github.com/nervosnetwork/molecule) starting from 0.8.0, switches to [bytes](https://crates.io/crates/bytes) instead of `Vec` internally to keep data in `no_std` environment. However, bytes would require atomic builtins so as to function, this could lead to unsupported CKB-VM instructions (RISC-V A extension instructions to be precise) being generated. There are 2 ways to solve this issue: + +* Enable `dummy-atomic` feature in `ckb-std` crate, also use make sure `FULL_RUSTFLAGS` in the contract makefile is updated so `-a` is included, for example: `FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS)`. Or see [this PR](https://github.com/cryptape/ckb-script-templates/pull/17) for how to change `RUSTFLAGS`. +* Enable `bytes_vec` feature in `molecule` crate + +[ckb-gen-types](https://crates.io/crates/ckb-gen-types) starting from 0.117.0 is also affected, since `ckb-gen-types` has upgraded to `molecule` 0.8.0 in this version. + ## Usage ### Dependencies diff --git a/contract/Makefile b/contract/Makefile index 579f431..b8bc7f6 100644 --- a/contract/Makefile +++ b/contract/Makefile @@ -9,7 +9,7 @@ TOP := $(cur_dir) CUSTOM_RUSTFLAGS := --cfg debug_assertions # RUSTFLAGS that are less likely to be tweaked by developers. Most likely # one would want to keep the default values here. -FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs $(CUSTOM_RUSTFLAGS) +FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) # Additional cargo args to append here. For example, one can use # make test CARGO_ARGS="-- --nocapture" so as to inspect data emitted to # stdout in unit tests diff --git a/stack-reorder-contract/Makefile b/stack-reorder-contract/Makefile index 5368bd5..6510f51 100644 --- a/stack-reorder-contract/Makefile +++ b/stack-reorder-contract/Makefile @@ -9,7 +9,7 @@ TOP := $(cur_dir) CUSTOM_RUSTFLAGS := --cfg debug_assertions # RUSTFLAGS that are less likely to be tweaked by developers. Most likely # one would want to keep the default values here. -FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs $(CUSTOM_RUSTFLAGS) \ +FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) \ -C link-arg=-T$(cur_dir)ld_interface.ld # Additional cargo args to append here. For example, one can use # make test CARGO_ARGS="-- --nocapture" so as to inspect data emitted to diff --git a/standalone-contract/Makefile b/standalone-contract/Makefile index 016083b..8914ed0 100644 --- a/standalone-contract/Makefile +++ b/standalone-contract/Makefile @@ -9,7 +9,7 @@ TOP := $(cur_dir) CUSTOM_RUSTFLAGS := --cfg debug_assertions # RUSTFLAGS that are less likely to be tweaked by developers. Most likely # one would want to keep the default values here. -FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs $(CUSTOM_RUSTFLAGS) +FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) # Additional cargo args to append here. For example, one can use # make test CARGO_ARGS="-- --nocapture" so as to inspect data emitted to # stdout in unit tests