Skip to content

Commit c4a147d

Browse files
authored
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
1 parent 13ec6fa commit c4a147d

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
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.
44

5+
## Noticeable Changes
6+
7+
### Molecule uses bytes crates
8+
9+
[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:
10+
11+
* 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`.
12+
* Enable `bytes_vec` feature in `molecule` crate
13+
14+
[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.
15+
516
## Usage
617

718
### Dependencies

contract/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TOP := $(cur_dir)
99
CUSTOM_RUSTFLAGS := --cfg debug_assertions
1010
# RUSTFLAGS that are less likely to be tweaked by developers. Most likely
1111
# one would want to keep the default values here.
12-
FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs $(CUSTOM_RUSTFLAGS)
12+
FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS)
1313
# Additional cargo args to append here. For example, one can use
1414
# make test CARGO_ARGS="-- --nocapture" so as to inspect data emitted to
1515
# stdout in unit tests

stack-reorder-contract/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TOP := $(cur_dir)
99
CUSTOM_RUSTFLAGS := --cfg debug_assertions
1010
# RUSTFLAGS that are less likely to be tweaked by developers. Most likely
1111
# one would want to keep the default values here.
12-
FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs $(CUSTOM_RUSTFLAGS) \
12+
FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS) \
1313
-C link-arg=-T$(cur_dir)ld_interface.ld
1414
# Additional cargo args to append here. For example, one can use
1515
# make test CARGO_ARGS="-- --nocapture" so as to inspect data emitted to

standalone-contract/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TOP := $(cur_dir)
99
CUSTOM_RUSTFLAGS := --cfg debug_assertions
1010
# RUSTFLAGS that are less likely to be tweaked by developers. Most likely
1111
# one would want to keep the default values here.
12-
FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs $(CUSTOM_RUSTFLAGS)
12+
FULL_RUSTFLAGS := -C target-feature=+zba,+zbb,+zbc,+zbs,-a $(CUSTOM_RUSTFLAGS)
1313
# Additional cargo args to append here. For example, one can use
1414
# make test CARGO_ARGS="-- --nocapture" so as to inspect data emitted to
1515
# stdout in unit tests

0 commit comments

Comments
 (0)