Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译liquid合约出错 #20

Open
hongfish opened this issue Oct 28, 2022 · 3 comments
Open

编译liquid合约出错 #20

hongfish opened this issue Oct 28, 2022 · 3 comments

Comments

@hongfish
Copy link

hongfish commented Oct 28, 2022

使用的rust配置:
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"

replace-with = 'ustc' # 如:tuna、sjtu、ustc,或者 rustcc

[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

[source.rustcc]
registry = "https://code.aliyun.com/rustcc/crates.io-index.git"

1、执行 cargo test 时,出现以下错误:
error[E0635]: unknown feature proc_macro_span_shrink
--> /root/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/proc-macro2-1.0.47/src/lib.rs:92:30
|
92 | feature(proc_macro_span, proc_macro_span_shrink)
| ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try rustc --explain E0635.
error: could not compile proc-macro2

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
111

2、使用清华大学的源
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

执行cargo liquid build时,出现以下错误:
[1/4] 🔍 Collecting crate metadata
ERROR: Error invoking cargo metadata

Caused by:
Error during execution of cargo metadata: Updating https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git index
Updating git repository https://gitee.com/WeBankBlockchain/liquid
Downloading crates ...
error: failed to download once_cell v1.15.0

Caused by:
  unable to get packages from source

Caused by:
  failed to download replaced source registry `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to parse manifest at `/root/.cargo/registry/src/mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd/once_cell-1.15.0/Cargo.toml`

Caused by:
  feature `edition2021` is required

  consider adding `cargo-features = ["edition2021"]` to the manifest

222

3、使用中国科学技术大学的源
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

执行cargo liquid build时,出现以下错误:
[1/4] 🔍 Collecting crate metadata
ERROR: Error invoking cargo metadata

Caused by:
Error during execution of cargo metadata: Updating git://mirrors.ustc.edu.cn/crates.io-index index
Updating git repository https://gitee.com/WeBankBlockchain/liquid
Downloading crates ...
error: failed to download bumpalo v3.11.1

Caused by:
  unable to get packages from source

Caused by:
  failed to download replaced source registry `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to parse manifest at `/root/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/bumpalo-3.11.1/Cargo.toml`

Caused by:
  feature `edition2021` is required

  consider adding `cargo-features = ["edition2021"]` to the manifest

333

个人建议,这个编译liquid合约的环境很难配置且容易出错,是否可以提供个docker组件,用户只需要将liquid合约上传到docker容器中,在容器里编译、构建,然后将构建好的Wasm 格式字节码及 ABI拷贝出来使用。

@bxq2011hust
Copy link
Collaborator

bxq2011hust commented Nov 18, 2022

这个编译出错的原因是liquid当前使用的编译器版本有点旧,而rust发布了新的语言版本2021,有一些依赖库升级语言版本只升级版本号的patch,导致编译报错。
有两种解决办法1. 降低报错的依赖库的版本,到其要求edition2021之前,2. 升级liquid语言使用的rustc版本,需要liquid适配。
我们正在规划升级liquid使用的编译器版本以彻底的解决问题,目前请先尝试降低报错的依赖库版本解决问题

@ethan75
Copy link

ethan75 commented Nov 21, 2022

同样遇到此问题,定位是proc-macro2更新后引起的(https://github.com/dtolnay/proc-macro2);
查看合约项目中引用proc-macro2的地方都是其他crate,降低proc-macro2的版本好像是可以的,可能要修改多个地方,直接在当前项目指定proc-macro2的版本会导致其他错误;
对比不同版本的proc-macro2,去掉本地库中proc-macro2-1.0.47中proc_macro_span_shrink代码,编译通过,主要修改地方如下(注释掉下面的代码):
./build.rs:116: && feature_allowed("proc_macro_span_shrink")
./src/lib.rs:92: feature(proc_macro_span, proc_macro_span_shrink)

@ethan75
Copy link

ethan75 commented Nov 21, 2022

希望官方的cargo-liquid和liquid项目能早日适配edition2021,可能那天其他引用的crate更新了,又会导致类似错误。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants