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

Issue while Compiling Node for macOS #1087

Closed
nakul1010 opened this issue Jun 15, 2023 · 3 comments
Closed

Issue while Compiling Node for macOS #1087

nakul1010 opened this issue Jun 15, 2023 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@nakul1010
Copy link
Member

Problem

Compiling the InterBtc repository on macOS requires specific dependencies to be installed correctly. The readme file provides multiple options for obtaining these dependencies. However, it is essential to follow the recommended steps in the correct order, especially for first-time macOS node compilation.

@nakul1010 nakul1010 added the documentation Improvements or additions to documentation label Jun 15, 2023
@nakul1010 nakul1010 self-assigned this Jun 15, 2023
@nakul1010
Copy link
Member Author

Solution

Follow the steps below to compile the InterBtc node on macOS:

  1. Install Rust

    Execute the following command in the terminal to install Rust:

    curl <https://sh.rustup.rs> -sSf | sh
    
    
  2. Install OpenSSL

    Install OpenSSL by running the following command:

    brew install openssl
    
    
  3. Update Current Shell

    Update the current shell by executing the following command:

    source ~/.cargo/env
    
    
  4. Install Cmake

    brew install cmake
    
  5. Install Clang via OpenSSL (not brew)

    Install Clang by running the command:

    xcode-select --install
    
    
  6. Verify Correct Paths

    Ensure that the following paths are correct:

    which llvm-ar
    /opt/homebrew/opt/llvm/bin/llvm-ar
    
    which clang
    /opt/homebrew/opt/llvm/bin/clang
    
    
  7. Check GCC Version

    Verify that the GCC version is greater than 10:

    gcc --version
    Apple clang version 14.0.0 (clang-1400.0.29.202)
    Target: arm64-apple-darwin22.2.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin
    
    
  8. Run Cargo Commands and Link LLVM and Clang

    Execute the following commands to build and link LLVM and Clang:

    cargo clean
    
    AR=/opt/homebrew/opt/llvm/bin/llvm-ar CC=/opt/homebrew/opt/llvm/bin/clang cargo build
    
    

Important Consideration

  • Do not include any empty spaces between paths, as it may cause Jemalloc to panic. :)

By following these steps carefully, you should be able to successfully compile the InterBtc node on macOS.

References

@nakul1010 nakul1010 changed the title Compiling Node for macOS Issue while Compiling Node for macOS Jun 15, 2023
@nud3l
Copy link
Member

nud3l commented Jul 18, 2023

On a new mac, it's also required to install llvm brew install llvm.

@baidang201
Copy link

cargo run --release --bin interbtc-parachain -- --dev
report

error: failed to run custom build command for `secp256k1-sys v0.4.2`

  running: "clang" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-I" "wasm-sysroot" "-Wall" "-Wextra" "-DSECP256K1_API=" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-DENABLE_MODULE_EXTRAKEYS=1" "-DUSE_NUM_NONE=1" "-DUSE_FIELD_INV_BUILTIN=1" "-DUSE_SCALAR_INV_BUILTIN=1" "-DECMULT_GEN_PREC_BITS=4" "-DECMULT_WINDOW_SIZE=15" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-DENABLE_MODULE_RECOVERY=1" "-o" "/Users/bread/Workspace/playground/wasm-pack-test/target/wasm32-unknown-unknown/release/build/secp256k1-sys-923268476155554b/out/depend/secp256k1/contrib/lax_der_parsing.o" "-c" "depend/secp256k1/contrib/lax_der_parsing.c"
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1

fixed by

1 Install llvm via homebrew, brew install llvm
2 Add the LLVM to your path PATH="/opt/homebrew/opt/llvm/bin:$PATH" (could be in your profile, .zshrc or equivalent)
3 Ensure you have the AR and CLANG environment vars exported, CC=/opt/homebrew/opt/llvm/bin/clang & AR=/opt/homebrew/opt/llvm/bin/llvm-ar
4 Run your command and hope for the best...

https://substrate.stackexchange.com/questions/1098/how-to-use-sp-core-in-libraries-that-target-wasm-for-the-web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Archived in project
Development

No branches or pull requests

3 participants