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

Failed to build caused by 'phactory-api' #972

Closed
pencoa opened this issue Sep 26, 2022 · 9 comments
Closed

Failed to build caused by 'phactory-api' #972

pencoa opened this issue Sep 26, 2022 · 9 comments

Comments

@pencoa
Copy link

pencoa commented Sep 26, 2022

Error message run 'cargo build --release' in root directory.

error: failed to run custom build command for `phactory-api v0.1.0 (/Users/xxx/phala-blockchain/crates/phactory/api)`

Caused by:
  process didn't exit successfully: `/Users/xxx/phala-blockchain/target/release/build/phactory-api-a284ecbac0d78291/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "protoc failed: Could not make proto path relative: pruntime_rpc.proto: No such file or directory\n" }', crates/phactory/api/build.rs:48:10
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/std/src/panicking.rs:584:5
     1: core::panicking::panic_fmt
               at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/panicking.rs:142:14
     2: core::result::unwrap_failed
               at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/result.rs:1785:5
     3: core::result::Result<T,E>::unwrap
     4: build_script_build::main
     5: core::ops::function::FnOnce::call_once

Error message run 'cargo test' in '/phala-blockchain/crates/phactory'

error: failed to run custom build command for `phactory-api v0.1.0 (/Users/xxx/phala-blockchain/crates/phactory/api)`

Caused by:
  process didn't exit successfully: `/Users/xxx/phala-blockchain/target/debug/build/phactory-api-cd77a965d7823081/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "protoc failed: Could not make proto path relative: pruntime_rpc.proto: No such file or directory\n" }', crates/phactory/api/build.rs:48:10
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/std/src/panicking.rs:584:5
     1: core::panicking::panic_fmt
               at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/panicking.rs:142:14
     2: core::result::unwrap_failed
               at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/result.rs:1785:5
     3: core::result::Result<T,E>::unwrap
               at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/result.rs:1107:23
     4: build_script_build::main
               at ./build.rs:46:5
     5: core::ops::function::FnOnce::call_once
               at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/ops/function.rs:248:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

System information

macOS Monterey
version 12.6(21G115)
chip Apple M2

Dependencies

LLVM

llvm-config --version
15.0.0

Submodule

git submodule update --init
sh ./scripts/init.sh

*** Initializing WASM build environment
info: syncing channel updates for 'nightly-aarch64-apple-darwin'

  nightly-aarch64-apple-darwin unchanged - rustc 1.66.0-nightly (f5193a9fc 2022-09-25)

info: checking for self-updates
info: syncing channel updates for 'stable-aarch64-apple-darwin'

  stable-aarch64-apple-darwin unchanged - rustc 1.64.0 (a55dd71d5 2022-09-19)

info: checking for self-updates
info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date

Rust

rustup update
info: syncing channel updates for 'stable-aarch64-apple-darwin'
info: syncing channel updates for 'nightly-aarch64-apple-darwin'
info: checking for self-updates

   stable-aarch64-apple-darwin unchanged - rustc 1.64.0 (a55dd71d5 2022-09-19)
  nightly-aarch64-apple-darwin unchanged - rustc 1.66.0-nightly (f5193a9fc 2022-09-25)

info: cleaning up downloads & tmp directories
@kvinwang
Copy link
Collaborator

Please follow here to install the proto compiler.
Sorry for the missing of documentation for this.

@pencoa
Copy link
Author

pencoa commented Sep 27, 2022

here

Thanks for reply. I follow your suggestion link to install protoc.

protoc --version
libprotoc 3.21.6

There still exist some errors during 'cargo build --release'
Error message

error: failed to run custom build command for `phactory-api v0.1.0 (/Users/xxx/Code/phala-blockchain/crates/phactory/api)`

Caused by:
  process didn't exit successfully: `/Users/xxx/Code/phala-blockchain/target/release/build/phactory-api-a284ecbac0d78291/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "protoc failed: Could not make proto path relative: pruntime_rpc.proto: No such file or directory\n" }', crates/phactory/api/build.rs:48:10
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/std/src/panicking.rs:584:5
     1: core::panicking::panic_fmt
               at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/panicking.rs:142:14
     2: core::result::unwrap_failed
               at /rustc/c2804e6ec2c29a5c7368600ea173b890e2655c3d/library/core/src/result.rs:1785:5
     3: core::result::Result<T,E>::unwrap
     4: build_script_build::main
     5: core::ops::function::FnOnce::call_once


error: failed to run custom build command for `phala-node-runtime v2.0.0 (/Users/xxx/Code/phala-blockchain/standalone/runtime)`

Caused by:
  process didn't exit successfully: `/Users/xxx/Code/phala-blockchain/target/release/build/phala-node-runtime-2bd601f6cfe81573/build-script-build` (exit status: 1)
  --- stdout

error: failed to build archive: section too large

error: could not compile `ring` due to previous error; 1 warning emitted

Information that should be included in a bug report.
  Executing build command: "/Users/xxx/.rustup/toolchains/nightly-2022-09-08-aarch64-apple-darwin/bin/cargo" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/Users/panzhaoming/Code/phala-blockchain/target/release/wbuild/phala-node-runtime/Cargo.toml" "--color=always" "--profile" "release"
  Using rustc version: rustc 1.65.0-nightly (c2804e6ec 2022-09-07)

Then I build using 'cargo +nightly build --release'
There occurs other errors

error: `sp_trie::recorder::Recorder<H>::as_trie_recorder::{opaque#0}<'_>` does not live long enough
   --> /Users/xxx/.cargo/git/checkouts/substrate-7e08433d4c370a21/3f70bce/primitives/state-machine/src/trie_backend_essence.rs:181:44
    |
181 |         let recorder = recorder.as_mut().map(|r| r as _);
    |                                                  ^

error: `sp_trie::recorder::Recorder<H>::as_trie_recorder::{opaque#0}<'_>` does not live long enough
   --> /Users/xxx/.cargo/git/checkouts/substrate-7e08433d4c370a21/3f70bce/primitives/state-machine/src/trie_backend_essence.rs:219:44
    |
219 |         let recorder = recorder.as_mut().map(|r| r as _);
    |                                                  ^

error: could not compile `sp-state-machine` due to 2 previous errors

I test my laptop via sucessfully build v0.9.28 Substrate-node-template.

@kvinwang
Copy link
Collaborator

Are there any protos files in /Users/xxx/Code/phala-blockchain/crates/phactory/api/proto/?

@pencoa
Copy link
Author

pencoa commented Sep 27, 2022

Are there any protos files in /Users/xxx/Code/phala-blockchain/crates/phactory/api/proto/?

Not yet.

@kvinwang
Copy link
Collaborator

Are there any protos files in /Users/xxx/Code/phala-blockchain/crates/phactory/api/proto/?

Not yet.

If you have run git submodule update --init without error. There should be two proto files in the proto directory.
please check the submodules status

@pencoa
Copy link
Author

pencoa commented Sep 28, 2022

I run git submodule update --init in one new repo.

Submodule 'crates/phactory/api/proto' (https://github.com/Phala-Network/prpc-protos.git) registered for path 'crates/phactory/api/proto'
Submodule 'standalone/prouter/i2pd' (https://github.com/Soptq/i2pd.git) registered for path 'standalone/prouter/i2pd'
Submodule 'subxt' (https://github.com/Phala-Network/substrate-subxt.git) registered for path 'subxt'
Cloning into '/Users/xxx/Code/phala-blockchain/crates/phactory/api/proto'...
fatal: unable to access 'https://github.com/Phala-Network/prpc-protos.git/': Empty reply from server
fatal: clone of 'https://github.com/Phala-Network/prpc-protos.git' into submodule path '/Users/xxx/Code/phala-blockchain/crates/phactory/api/proto' failed
Failed to clone 'crates/phactory/api/proto'. Retry scheduled
Cloning into '/Users/xxx/Code/phala-blockchain/standalone/prouter/i2pd'...
Cloning into '/Users/xxx/Code/phala-blockchain/subxt'...
Cloning into '/Users/xxx/Code/phala-blockchain/crates/phactory/api/proto'...
Submodule path 'crates/phactory/api/proto': checked out '0b2b328b5a261eeb4d8130d5c684dc838f16657f'
Submodule path 'standalone/prouter/i2pd': checked out '3900e9a04bda081349a479c440f2e5b7f32cc50a'
Submodule path 'subxt': checked out '513719fbf00ea5b650d328d74bcaa38ec182ab46'
Submodule path 'crates/phactory/api/proto': checked out '0b2b328b5a261eeb4d8130d5c684dc838f16657f'

There are prpc.proto pruntime_rpc.proto two proto files in the proto directory.

Then I build again. phactory-api v0.1.0 error is solved.

Errors remained

error: failed to run custom build command for `phala-node-runtime v2.0.0 (/Users/xxx/Code/phala-blockchain/standalone/runtime)`

Caused by:
  process didn't exit successfully: `/Users/xxx/Code/phala-blockchain/target/release/build/phala-node-runtime-2bd601f6cfe81573/build-script-build` (exit status: 1)
  --- stdout

error: failed to build archive: section too large

error: could not compile `ring` due to previous error; 1 warning emitted

@kvinwang
Copy link
Collaborator

This should be a bug of Apple LLVM. You can install a custom LLVM from homebrew.
@jasl Could you give some commands here?

@jasl
Copy link
Collaborator

jasl commented Sep 28, 2022

I run git submodule update --init in one new repo.

Submodule 'crates/phactory/api/proto' (https://github.com/Phala-Network/prpc-protos.git) registered for path 'crates/phactory/api/proto'
Submodule 'standalone/prouter/i2pd' (https://github.com/Soptq/i2pd.git) registered for path 'standalone/prouter/i2pd'
Submodule 'subxt' (https://github.com/Phala-Network/substrate-subxt.git) registered for path 'subxt'
Cloning into '/Users/xxx/Code/phala-blockchain/crates/phactory/api/proto'...
fatal: unable to access 'https://github.com/Phala-Network/prpc-protos.git/': Empty reply from server
fatal: clone of 'https://github.com/Phala-Network/prpc-protos.git' into submodule path '/Users/xxx/Code/phala-blockchain/crates/phactory/api/proto' failed
Failed to clone 'crates/phactory/api/proto'. Retry scheduled
Cloning into '/Users/xxx/Code/phala-blockchain/standalone/prouter/i2pd'...
Cloning into '/Users/xxx/Code/phala-blockchain/subxt'...
Cloning into '/Users/xxx/Code/phala-blockchain/crates/phactory/api/proto'...
Submodule path 'crates/phactory/api/proto': checked out '0b2b328b5a261eeb4d8130d5c684dc838f16657f'
Submodule path 'standalone/prouter/i2pd': checked out '3900e9a04bda081349a479c440f2e5b7f32cc50a'
Submodule path 'subxt': checked out '513719fbf00ea5b650d328d74bcaa38ec182ab46'
Submodule path 'crates/phactory/api/proto': checked out '0b2b328b5a261eeb4d8130d5c684dc838f16657f'

There are prpc.proto pruntime_rpc.proto two proto files in the proto directory.

Then I build again. phactory-api v0.1.0 error is solved.

Errors remained

error: failed to run custom build command for `phala-node-runtime v2.0.0 (/Users/xxx/Code/phala-blockchain/standalone/runtime)`

Caused by:
  process didn't exit successfully: `/Users/xxx/Code/phala-blockchain/target/release/build/phala-node-runtime-2bd601f6cfe81573/build-script-build` (exit status: 1)
  --- stdout

error: failed to build archive: section too large

error: could not compile `ring` due to previous error; 1 warning emitted

https://github.com/Phala-Network/khala-parachain#special-note-for-macos

@pencoa
Copy link
Author

pencoa commented Sep 28, 2022

Thank you for your instruction. It works.

brew info llvm

==> llvm: stable 15.0.1 (bottled), HEAD [keg-only]
Next-gen compiler infrastructure
https://llvm.org/
/opt/homebrew/Cellar/llvm/15.0.1 (6,409 files, 1.6GB)
  Poured from bottle on 2022-09-27 at 20:03:16
From: https://mirrors.ustc.edu.cn/homebrew-core.git/Formula/llvm.rb
License: Apache-2.0 with LLVM-exception
==> Dependencies
Build: cmake ✔, swig ✔
Required: python@3.10 ✔, six ✔, z3 ✔, zstd ✔
==> Options
--HEAD
	Install HEAD version
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
  LDFLAGS="-L/opt/homebrew/opt/llvm/lib/c++ -Wl,-rpath,/opt/homebrew/opt/llvm/lib/c++"

llvm is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have llvm first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc

For compilers to find llvm you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"

Run three comands

echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"

Make alias for ar and ranlib

cd /opt/homebrew/opt/llvm/bin
ln -s llvm-ar ar
ln -s llvm-ar ranlib

Delete the target directory and build again.
A warm hug to @kvinwang and @jasl

@pencoa pencoa closed this as completed Sep 28, 2022
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