liquid icon indicating copy to clipboard operation
liquid copied to clipboard

cargo liquid 编译合约错误

Open jewelzms opened this issue 3 years ago • 2 comments

根据说明文档 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不兼容),使得编译链无法正常使用,似乎难以找到整套兼容的依赖。 官方有无好的解决方案,或是当时有无封装可用容器?

jewelzms avatar Dec 28 '22 08:12 jewelzms

现在这个问题是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. 再次编译

bxq2011hust avatar Jan 06 '23 10:01 bxq2011hust

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

jewelzms avatar Jan 15 '23 08:01 jewelzms