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

cargo liquid 编译合约错误 #37

Open
jewelzms opened this issue Dec 28, 2022 · 2 comments
Open

cargo liquid 编译合约错误 #37

jewelzms opened this issue Dec 28, 2022 · 2 comments

Comments

@jewelzms
Copy link

根据说明文档 https://liquid-doc.readthedocs.io/zh_CN/latest/docs/quickstart/prerequisite.html 配置好环境之后。

尝试编译 HelloWorld 例子合约,开始遇到 proc-macro2 等一些依赖库报错,在修改 HelloWorld 示例合约部分依赖库版本之后继续编译,提示需要 edition2021 特性,编译出现如下错误:

[1/4] 🔍  Collecting crate metadata
[2/4] 🚚  Building cargo project
error: failed to parse manifest at `/tmp/cargo-xbuildqtQwtT/Cargo.toml`

Caused by:
  feature `edition2021` is required

  consider adding `cargo-features = ["edition2021"]` to the manifest
ERROR: Building with xargo

Caused by:
    `"/home/john/.rustup/toolchains/nightly-2021-06-23-x86_64-unknown-linux-gnu/bin/cargo" "rustc" "-p" "alloc" "--release" "--manifest-path" "/tmp/cargo-xbuildqtQwtT/Cargo.toml" "--target" "wasm32-unknown-unknown" "--" "-Z" "force-unstable-if-unmarked"` failed with exit code: Some(101)

根据提示修改 Cargo.toml,在文件顶部增加 cargo-features = ["edition2021"],报错如下:

[1/4] 🔍  Collecting crate metadata
[2/4] 🚚  Building cargo project
   Compiling core v0.0.0 (/home/john/.rustup/toolchains/nightly-2021-06-23-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling compiler_builtins v0.1.45
   Compiling rustc-std-workspace-core v1.99.0 (/home/john/.rustup/toolchains/nightly-2021-06-23-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/tmp/cargo-xbuildLJMsg2)
    Finished release [optimized] target(s) in 19.60s
error[E0463]: can't find crate for `std`
  |
  = note: the `wasm32-unknown-unknown` target may not support the standard library
  = note: `std` is required by `predicates_core` because it does not declare `#![no_std]`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error[E0463]: can't find crate for `std`
  |
  = note: the `wasm32-unknown-unknown` target may not support the standard library
  = note: `std` is required by `bumpalo` because it does not declare `#![no_std]`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error: could not compile `predicates-core`

To learn more, run the command again with --verbose.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: build failed
ERROR: xbuild failed with status exit status: 101

目前提供的编译链因为当时使用的版本老旧,很多库已升级(patch不兼容),使得编译链无法正常使用,似乎难以找到整套兼容的依赖。
官方有无好的解决方案,或是当时有无封装可用容器?

@bxq2011hust
Copy link
Collaborator

现在这个问题是liquid锁定的编译器版本过于老旧导致的,我们已经在着手解决这个问题了
按下述步骤尝试一下

  1. 重新安装最新版的caego-liquid
cargo install --git https://github.com/WeBankBlockchain/cargo-liquid --branch main --locked --force
  1. 更新合约项目中Cargo.toml的liquid,如下
liquid_lang = { git = "https://github.com/WeBankBlockchain/liquid", rev = "c678d9586b4335fc302a4c02a564d8ee6964be1d", package = "liquid_lang", default-features = false, features = ["contract"] }
liquid_primitives = { git = "https://github.com/WeBankBlockchain/liquid", rev = "c678d9586b4335fc302a4c02a564d8ee6964be1d", package = "liquid_primitives", default-features = false }
liquid_prelude = { git = "https://github.com/WeBankBlockchain/liquid", rev = "c678d9586b4335fc302a4c02a564d8ee6964be1d", package = "liquid_prelude", default-features = false }
liquid_macro = { git = "https://github.com/WeBankBlockchain/liquid", rev = "c678d9586b4335fc302a4c02a564d8ee6964be1d", package = "liquid_macro", default-features = false }
liquid_abi_gen = { git = "https://github.com/WeBankBlockchain/liquid", rev = "c678d9586b4335fc302a4c02a564d8ee6964be1d", package = "liquid_abi_gen", default-features = false, optional = true }
  1. 再次编译

@jewelzms
Copy link
Author

已看到最新版本对该问题的解决,非常感谢官方作者的艰苦付出,谢谢!

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

2 participants