Bonfida / dex-v4

Orderbook-based on-chain SPL token swap market
101 stars 32 forks source link

BPF build of the program error #105

Closed mihneacalugaru closed 1 year ago

mihneacalugaru commented 1 year ago

Hello,

I am trying to produce a .so file that can be deployed on the devnet in order for me to experiment with the code.

Reading the documentation, I understood that I should use the cargo build-bpf to produce the .so file by giving as parameters the path to the .toml file (the manifest path) and an output directory for the result.

After some tries, I am getting this: image

Can you help me figure out why I get this?

Also, if you can walk me through the steps to produce a .so deployable from the program in this repo I would greatly appreciate it!

Thanks a lot!

L.E.: After a cargo update in program I get: image

dr497 commented 1 year ago

Have you modified your Cargo.lock?

mihneacalugaru commented 1 year ago

@dr497 , no.

The following screenshot will show the steps to reproduce since cloning the repo:

image

ellttBen commented 1 year ago

@mihneacalugaru Can you try and cd into the program directory before running cargo build-bpf? My suspicion is that it's looking for a Cargo.lock in your current directory, and tries to build it itself.

mihneacalugaru commented 1 year ago

Hi @ellttBen,

Tried with no luck:

image

ellttBen commented 1 year ago

Hey @mihneacalugaru, do you also get this issue on the alpha branch?

mihneacalugaru commented 1 year ago

@ellttBen, I have a quick question: you said here (https://github.com/Bonfida/dex-v4/issues/98#issuecomment-1387694661) that you have deployed the program.

I assume you built the program with cargo build-bpf, got the .so file and deployed it using solana program deploy with the path to that .so. Is this right?

How did you manage to make it build? Am I missing something? Can you help me with the steps to build this program and deploy it? I would appreciate a lot!

ellttBen commented 1 year ago

At the time I just ran cargo build-bpf in the program folder and didn't run into any issue. Currently the main branch is broken, probably due to a dependency update in a past commit (we tested the bindings but not building the program itself, ie the bpf target). This issue is currently fixed in the alpha branch. However, even on the main branch, I can't reproduce the error you're seeing. What is really confusing to me is that your error indicates that cargo is attempting to resolve the dependency versions itself instead of using the existing Cargo.lock. Can you try switching to the alpha branch and then, in the program folder, running cargo build-bpf without any arguments? If this fails can you try cargo build-bpf --frozen?

ellttBen commented 1 year ago

Also, your screenshot indicates that you are running a pretty old version of the Solana tool suite, an upgrade might be a good step forward towards solving the issue

mihneacalugaru commented 1 year ago

@ellttBen, ok, so I did the following: (also, note that I am on a Windows machine)

  1. Updated the Solana Tool Suite

image

I am at 1.15.2.

Also, these are my rustc and rustup versions, also updated:

image

  1. I ran cargo-build-bpf in the alpha branch and now I get:

image image

  1. if I run cargo-build-**sbf**, which is supposed to replace the deprecated cargo-build-bpf I get:

image

So, still that issue with blake3 v1.3.3, but also those other 2 errors above it.

  1. I don't understand why I can't use cargo build-bpf (the version without the - between cargo and build)

image

I am only able to run the version with dashes all around (cargo-build-bpf or cargo-build-sbf), which I believe gets actually called by cargo build-bpf/sbf that I can't access.

I uninstalled rust and installed it again and I also brought the Solana Tool Suite to the latest version.

Any ideas? :(

ellttBen commented 1 year ago

From what I can gather it seems your dev/build environment is completely broken. There are a few possible issues here, but ultimately I think you're just going have to tinker. I personally don't have any experience making the toolchain work with Windows, so it might be easier to switch to a Linux vm. A couple ideas to look into in the mean time :

mihneacalugaru commented 1 year ago

@ellttBen, I ran it on my WSL (Windows Subsystem for Linux) with a clean environment and it worked.

Might be something with my Windows environment. It seems that it tries to use the Visual Studio installed MASM to target the x64 code and that one doesn't execute successfully.

Anyway, it works on a clean Linux env. Will close it.

Thanks!