freenet-core
freenet-core copied to clipboard
Building requires llvm
LLVM must be installed prior to cargo build:
$ sudo apt install llvm
Can this dependency be made explicit in Cargo.toml so that the user gets a useful warning?
As I see such command might not help. For example I installed llvm on my mac m1(brew install llvm) and the project wasn't compiled. It wasn't compiled since in cargo tree there is a package which requires llvm@12, but basic llvm installation installs the latest llvm version, which is 14 as I see. So I needed remove llvm latest and install llvm@12
Also for my case I needed explicitly specify a path to llvm: export LLVM_SYS_120_PREFIX="/opt/homebrew/opt/llvm@12". llvm-sys asked for that.
I think we can also shift from that problem by providing wasmtime additionally to wasmer via feature flags for example. Wasmtime developed by people who initially developed rust lang. Additionally having multiple runtimes is a good for benchmarking, testing, more conf flexibility, etc.
Also dockerized dev env can be helpful I think.
If the problem is to avoid llvm altogether is as simple as disabling llvm as backend for wasmer and fallback to cranelift instead. It doesn't matter as much if we are not running on headless mode anyway, as the user will have to compile wasm on it's own, it doesn't matter as much which backend are we using since we are not compiling the contracts at the node callsite.
wasmtime is kind of superseded by wasmer, a lot of the people who worked in the former and I don't see any clear advantage over adding the complexity of maintaining different backend runtimes right now, is just easier to disable llvm for wasmer and just use cranelift.
Seems like a good idea to remove the llvm dependency, we want the developer experience to be as frictionless as possible.
Hmm, this issue claims that CraneLift is intel only - if true that could be a problem if we are relying on it.
Tbh I would prefer to make llvm work, even if we have to embeed the sys dependency somehow per platform llvm has better support and is overall faster. And the idea of using llvm initially was to use it in headless mode, which is faster at loading modules (which we will be doing a lot, loading and unloading contracts).
I don't think there is anything technically stopping us to make things easier when installing the node, is just we haven't got to that point yet.
Possibly the documentation should be updated to have instructions on how to install the proper version of LLVM for various operating systems. The build error messages are very cryptic and not helpful.
On Ubuntu 22.04, the llvm-12 and clang-12 packages must be installed, I just figured it by guessing
The quickest thing we can do right now is specify that is required as a dependency. I am including it in the guide already, but we can add it in the readme if necessary too. Distributed versions won't run into this issues as they will be precompiled, and we have more control over that. It can also be embedded as a dependency probably too, when installing it, on the rust build script, that's probably the most friction less we can do to install it from source. I will look into that.
In #411 we are removing LLVM as an implicit dependency and defaulting to cranelift. The rationale is that for development we don't need to use LLVM, and when we package precompiled node binaries we can use LLVM then.
This will solve all related problems to building with LLVM, hopefully. The docs must be updated to reflect this (remove explciit mentions of having to install it etc). We can likewise remove any dependencies from the container.
If someone can do that I would be greatful, otherwise I will get to it when I have some bandwidth. leaving the issue open until that's done (and #411 is merged, which takes care of this).
@sanity FYI
Version 0.0.3 released which removes LLVM as a hard dependency, reflected on docs too. Upon PR merge this will be closed.