alexslade

alexslade

Is there a supported way to compile + cache a rust dependency?

Hi folks,

On of my team’s projects has a rust dependency, via a library that uses rustler to wrap a rust function. It hasn’t changed in a while, and it’s a pain to have an entire rust runtime dependency for this single lib.

We’re trying to find a way to remove the runtime from our deploy pipeline, and I’m wondering if there is a way to locally compile the dependency ahead of time and just include some kind of version-fixed binary.

Grateful for any suggestions, thanks.

Most Liked

josevalim

josevalim

Creator of Elixir

We are working on a package for precompiling Rustler. It should be available within the next two weeks or so. :slight_smile:

28
Post #2
josevalim

josevalim

Creator of Elixir

Here is the library, very alpha version, likely some rough edges and changes incoming, but if you can’t wait you can already give it a try: GitHub - philss/rustler_precompiled: Use precompiled NIFs from trusted sources in your Elixir code

josevalim

josevalim

Creator of Elixir

There is a proof of concept in the html5ever project that is being ported to a stand-alone library.

OvermindDL1

OvermindDL1

What I would find really fascinating is embedding a wasm engine, like wasmer or so, and expose the BEAM API to it (perhaps with a bit of massaging), and then you could easily compile native apps to WASM and load them in that instead. Something like wasmer could run it either fully interpreted, cranelift JIT compiled, or even LLVM native compiled for near native speed, without needing to compile it for each individual platform and beam bindings needed, especially if a more version independent API were exposed to it… This is an interesting idea… You’d probably want to precompile the wasm engine library for NIF access for each combination of beam VM and arch but that’s only one thing you’d need to do instead of every single possible library… Hmm…

Standalone process communicated via Ports or something similar is doable as well and honestly probably fine for many libraries, but most things made for NIF’s are because they want that speed, and WASM could probably get that close enough (at the very least for dev)…

sorentwo

sorentwo

Oban Core Team

If anybody else is curious, here is the package: GitHub - rusterlium/html5ever_elixir: NIF wrapper of html5ever using Rustler

Where Next?

Popular in Questions Top

LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
Fl4m3Ph03n1x
Background Let’s assume I have a typical GenServer that receives messages as requests, does some operation in a DB and returns responses....
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement