Issue #15759 has been updated by duerst (Martin D=FCrst).

Status changed from Open to Third Party's Issue

Ruby includes rubygems, but this is imported, see e.g. https://svn.ruby-lan=
g.org/cgi-bin/viewvc.cgi?view=3Drevision&revision=3D67415. So improvements =
to rubygems should be proposed and discussed upstreams.

----------------------------------------
Feature #15759: Support Rust/Cargo in Gem::Ext::Builder
https://bugs.ruby-lang.org/issues/15759#change-77568

* Author: ianks (Ian Ker-Seymer)
* Status: Third Party's Issue
* Priority: Normal
* Assignee: =

* Target version: =

----------------------------------------
Over the past few years, Rust has proven to be an incredibly stable and acc=
essible option for those wishing to write native extensions for Ruby. Rust =
is particularly well-suited for Ruby for a few reasons: =


1. Integration is straight-forward, since it is easy to expose a C compatib=
le API using `extern C`
2. Rust is a bit more high-level, and approachable for Ruby developers sinc=
e it prevents many of the classic C footguns (use-after-free, etc)
3. The landing page can explain the benefits better than me. Check out http=
s://www.rust-lang.org/ if you aren't fully convinced.

One of the biggest pain points of creating a Gem with a Rust extension is i=
ntegrating with Gem::Ext::Builder. There are currently a couple of solution=
s, and the rely on the `RakeBulider` interface. I have personally used http=
s://github.com/malept/thermite, which is a very good solution, but still re=
quires and external dependency and does not integrate as well as native bui=
lders at the moment.
`
Currently, Gem::Ext::Builder supports four builder types: `ExtConfBuilder`,=
 `ConfigureBuilder`, `RakeBuilder`, and `CmakeBuilder`. I propose we add a =
new builder, `CargoBuilder`, which will detect a `cargo.toml` file and buil=
d the gem from that. This ease the burden of developing and publishing Rust=
 extensions for Ruby users.

### Potential Problems

1. If the user does not have `cargo` installed, building the extension will=
 not work. =

   This is an issue, but is also an issue for the CmakeBuilder. One way to =
mitigate this issue would be to make it easier to build static binaries for=
 Rust extensions.

2. The lack of a standard ruby interface for Rust extensions might cause pa=
in for developers.
   Currently, many folks use https://github.com/steveklabnik/ruby-sys to in=
terface with the C ruby API. It might make sense to make this "officially" =
supported at some point, but I don't think it has to be done immediately.

Please let me know your thoughts. I would be very excited to see Ruby take =
this step. I don't think I know enough about the Ruby extension building pr=
ocess or the Rust compilation process to actually implement this, so hopefu=
lly we could find a volunteer to step up. Thanks for reading :)






-- =

https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>