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

how can i build aleo on riscv64? #3364

Open
leexusheng opened this issue Jul 15, 2024 · 5 comments
Open

how can i build aleo on riscv64? #3364

leexusheng opened this issue Jul 15, 2024 · 5 comments
Labels
bug Incorrect or unexpected behavior

Comments

@leexusheng
Copy link

leexusheng commented Jul 15, 2024

🐛 Bug Report

rustc 1.76.0 (07dca489a 2024-02-04)

when i build aleo on riscv64

error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/ubuntu/.rustup/toolchains/1.76.0-riscv64gc-unknown-linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/bin:/home/ubuntu/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" VSLANG="1033" "cc" "/tmp/rustcd2junN/symbols.o" "/home/ubuntu/Aleo/snarkOS/target/release/deps/c0ea0895dd8-cgu.0.rcgu.o.rcgu.o" "/home/ubuntu/Aleo/snarkOS/target/release/deps/snarkos-5f61e3a1b9b6b2ca.base64-OS/target/release/deps/snarkos-5f61e3a1b9b6b2ca.crc32fast-92a3f85c61d0c4a8.crc32fast.84d95adc3748ca93-cgu.0.rcgu.o.rcgu.o" "/home/ubuntu/Aleo/snarkOS/target/release/deps/snarkos-5f61e3a1b9b6b2ca.crossbeam_deque-4003d5aa5ad09577.crossbeam_deque.5d7935b0095e1dcc-cgu.0.rcgu.o.rcgu.o" "/home/ubuntu/Aleo/snarkOS/target/release/deps/snarkos-5f61e3a1b9b6b2ca.crossbeam_epoch-3d4c1cf725cad1b9.crossbeam_epoch.7df41b53d4945ad9-cgu.0.rcgu.o.rcgu.o" "/home/b344a1b6-cgu.07.rcgu.o.rcgu.o" "/home/ubuntu/Aleo/snarkOS/target/release/deps/snarkos-5f61e3a1b9b6b2ca.headers-1a519786a3955cbc.headers.cb3ea06eb344a1b6-cgu.08.rcgu.o.rcgu.o" "/home/ubuntu/Aleo/snarkOS/target/release/deps/snarkos-5f61e3a1b9b6b2ca.headers-1a519786a3955cbc.headers.cb3ea06eb344a1b6-cgu.09.rcgu.o.rcgu.o" "/home/ubuntu/Aleo/snarkOS/target/release/deps/snarkos-5f61e3a1b9b6b2ca.hyper-a04b629e833ecb2f.hyper.a2d904570220572d-cgu.10.rcgu.o.rcgu.o" "/home/ubuntu/Aleo/snarkOS/target/release/deps/snarkos-5f61e3a1b9b6b2ca.hyper-a04b629e833ecb2f.hyper.a2d904570220572d-cgu.11.rcgu.o.rcgu.o" "/home/ubuntu/Aleo/snarkOS/linux-gnu/lib/rustlib/riscv64gc-unknown-linux-gnu/lib" "-o" "/home/ubuntu/Aleo/snarkOS/target/release/deps/snarkos-5f61e3a1b9b6b2ca" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs"
  = note: /usr/bin/ld: /tmp/rustcd2junN/liblibrocksdb_sys-2db33b5d50f7cb8b.rlib(34500ee411ddd5f5-memtable.o): in function `.L1998':
          memtable.cc:(.text._ZN7rocksdb8MemTable22ApproximateMemoryUsageEv+0x60): undefined reference to `__atomic_compare_exchange_1'
          /usr/bin/ld: /tmp/rustcd2junN/liblibrocksdb_sys-2db33b5d50f7cb8b.rlib(34500ee411ddd5f5-memtable.o): in function `.L3574':
          memtable.cc:(.text._ZN7rocksdb15ConcurrentArena15AllocateAlignedEmmPNS_6LoggerE[_ZN7rocksdb15ConcurrentArena15AllocateAlignedEmmPNS_6LoggerE]+0x88): undefined reference to `__atomic_compare_exchange_1'
          /usr/bin/ld: /tmp/rustcd2junN/liblibrocksdb_sys-2db33b5d50f7cb8b.rlib(34500ee411ddd5f5-memtable.o): in function `.L3581':
          memtable.cc:(.text._ZN7rocksdb15ConcurrentArena15AllocateAlignedEmmPNS_6LoggerE[_ZN7rocksdb15ConcurrentArena15AllocateAlignedEmmPNS_6LoggerE]+0x1ac): undefined reference to `__atomic_compare_exchange_1'
          /usr/bin/ld: /tmp/rustcd2junN/liblibrocksdb_sys-2db33b5d50f7cb8b.rlib(34500ee411ddd5f5-memtable.o): in function `.L3583':
          memtable.cc:(.text._ZN7rocksdb15ConcurrentArena15AllocateAlignedEmmPNS_6LoggerE[_ZN7rocksdb15ConcurrentArena15AllocateAlignedEmmPNS_6LoggerE]+0x1fe): undefined reference to `__atomic_compare_exchange_1'
          /usr/bin/ld: /tmp/rustcd2junN/liblibrocksdb_sys-2db33b5d50f7cb8b.rlib(34500ee411ddd5f5-memtable.o): in function `.L3580':
          memtable.cc:(.text._ZN7rocksdb15ConcurrentArena15AllocateAlignedEmmPNS_6LoggerE[_ZN7rocksdb15ConcurrentArena15AllocateAlignedEmmPNS_6LoggerE]+0x2dc): undefined reference to `__atomic_compare_exchange_1'
          /usr/bin/ld: /tmp/rustcd2junN/liblibrocksdb_sys-2db33b5d50f7cb8b.rlib(34500ee411ddd5f5-memtable.o):memtable.cc:(.text._ZN7rocksdb15ConcurrentArena15AllocateAlignedEmmPNS_6LoggerE[_ZN7rocksdb15ConcurrentArena15AllocateAlignedEmmPNS_6LoggerE]+0x342): more undefined references to `__atomic_compare_exchange_1' follow
          collect2: error: ld returned 1 exit status
          
  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
@leexusheng leexusheng added the bug Incorrect or unexpected behavior label Jul 15, 2024
@ljedrz
Copy link
Collaborator

ljedrz commented Jul 15, 2024

It is not officially supported; as you can see, the rocksdb dependency may not work on that architecture.

You may try building with the Cargo.toml file modified to not use the rocks feature from snarkvm, but that will mean that your storage will be in-memory only.

@leexusheng
Copy link
Author

thanks to your reply, but if i try to delete the feature "rocks" in the Cargo.toml file
node/bft/storage-service/src/persistent.rs:22:17 rocksdb::{
| ^^^^^^^ could not find rocksdb in helpers
how can i do .thx

@ljedrz
Copy link
Collaborator

ljedrz commented Jul 15, 2024

It seems that the node is currently hardcoded to use the persistent storage for both client and validator nodes; however, you could try introducing the following changes to go memory-only:

diff --git a/Cargo.toml b/Cargo.toml
index 6898e5400..183ae2b87 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -48,7 +48,7 @@ default-features = false
 git = "https://github.com/AleoNet/snarkVM.git"
 rev = "d170a9f" # If this is updated, the rev in `node/rest/Cargo.toml` must be updated as well.
 #version = "=0.16.18"
-features = [ "circuit", "console", "rocks" ]
+features = [ "circuit", "console" ]

 [[bin]]
 name = "snarkos"
diff --git a/node/consensus/Cargo.toml b/node/consensus/Cargo.toml
index 81fdcd867..f5baa6af0 100644
--- a/node/consensus/Cargo.toml
+++ b/node/consensus/Cargo.toml
@@ -66,7 +66,7 @@ features = [ "ledger", "ledger-write" ]
 path = "../bft/storage-service"
 version = "=2.2.7"
 default-features = false
-features = [ "persistent" ]
+features = [ "memory" ]

 [dependencies.snarkvm]
 workspace = true
diff --git a/node/consensus/src/lib.rs b/node/consensus/src/lib.rs
index fdf247dfd..43c0778ee 100644
--- a/node/consensus/src/lib.rs
+++ b/node/consensus/src/lib.rs
@@ -32,7 +32,7 @@ use snarkos_node_bft::{
     BFT,
 };
 use snarkos_node_bft_ledger_service::LedgerService;
-use snarkos_node_bft_storage_service::BFTPersistentStorage;
+use snarkos_node_bft_storage_service::BFTMemoryService;
 use snarkvm::{
     ledger::{
         block::Transaction,
@@ -122,7 +122,7 @@ impl<N: Network> Consensus<N> {
             StorageMode::Production | StorageMode::Custom(..) => None,
         };
         // Initialize the Narwhal transmissions.
-        let transmissions = Arc::new(BFTPersistentStorage::open(storage_mode)?);
+        let transmissions = Arc::new(BFTMemoryService::new());
         // Initialize the Narwhal storage.
         let storage = NarwhalStorage::new(ledger.clone(), transmissions, BatchHeader::<N>::MAX_GC_ROUNDS as u64);
         // Initialize the BFT.
diff --git a/node/src/node.rs b/node/src/node.rs
index f5fe6d2fa..a3b481643 100644
--- a/node/src/node.rs
+++ b/node/src/node.rs
@@ -17,7 +17,7 @@ use snarkos_account::Account;
 use snarkos_node_router::messages::NodeType;
 use snarkvm::prelude::{
     block::Block,
-    store::helpers::{memory::ConsensusMemory, rocksdb::ConsensusDB},
+    store::helpers::memory::ConsensusMemory,
     Address,
     Network,
     PrivateKey,
@@ -33,11 +33,11 @@ use std::{

 pub enum Node<N: Network> {
     /// A validator is a full node, capable of validating blocks.
-    Validator(Arc<Validator<N, ConsensusDB<N>>>),
+    Validator(Arc<Validator<N, ConsensusMemory<N>>>),
     /// A prover is a light node, capable of producing proofs for consensus.
     Prover(Arc<Prover<N, ConsensusMemory<N>>>),
     /// A client node is a full node, capable of querying with the network.
-    Client(Arc<Client<N, ConsensusDB<N>>>),
+    Client(Arc<Client<N, ConsensusMemory<N>>>),
 }

 impl<N: Network> Node<N> {

(you can hand-pick these changes or save this snippet and git apply it)

@leexusheng
Copy link
Author

Thank you for your reply, I tried to modify the code with the method you provided, but it still can't be installed on riscv, cloud you tell me whichmalloc (jemalloc or glibc or tcmalloc) is needed for this program on RISC v. I've tried export LD_PRELOAD= RISC v version of these libraries, but I still get the error,Thanks again!!!!

@ljedrz
Copy link
Collaborator

ljedrz commented Jul 22, 2024

You may use any allocator that RISC-V supports. The OS allocator should be used by default; I'm not sure why it wouldn't work, but you're free to use a different one that does.

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

No branches or pull requests

2 participants