# Rust + CloudABI

**URL:** <https://internals.rust-lang.org/t/rust-cloudabi/3773>\
**Category:** Uncategorized\
**Created:** [July 29, 2016, 10:04pm UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773 "2016-07-29T22:04:08Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yohanesu75](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/yohanesu75/32/1982_2.png) [@Yohanesu75](https://internals.rust-lang.org/u/Yohanesu75)\
**Post date:** [July 29, 2016, 10:04pm UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/1 "2016-07-29T22:04:08Z")

</div>

Hi

What is the current relationship/dependency between Rust’s libstd and libc? [https://nuxi.nl/cloudabi/](https://nuxi.nl/cloudabi/) has a libc that is modified to use Capsicum’s security model. I am looking into how one could leverage this in Rust.

Is there like a 1:1 mapping between libstd and libc so that one could simply replace libc and change the ffi calls to match that of Cloudabi’s function names and parameters?

---

<div class="post-metadata">

**Author:** ![jethrogb](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@jethrogb](https://internals.rust-lang.org/u/jethrogb)\
**Post date:** [July 29, 2016, 10:35pm UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/2 "2016-07-29T22:35:33Z")

</div>

This would be possible, yes. Also, work is ongoing to make supporting other platform interfaces (Linux system calls, CloudABI, etc.) easier: [https://github.com/rust-lang/rfcs/pull/1502](https://github.com/rust-lang/rfcs/pull/1502)

---

<div class="post-metadata">

**Author:** ![brson](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/brson/32/5197_2.png) [@brson](https://internals.rust-lang.org/u/brson)\
**Post date:** [July 30, 2016, 1:57am UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/3 "2016-07-30T01:57:47Z")

</div>

> [@Yohanesu75](#):
>
> Is there like a 1:1 mapping between libstd and libc so that one could simply replace libc and change the ffi calls to match that of Cloudabi's function names and parameters?

If they have different function signatures it would require modifying the places in std that call them. It's desirable for std to have a clean platform abstraction layer where those decisions can be centralized, but it doesn't really exist today (@jethrogb's link has some discussion).

---

<div class="post-metadata">

**Author:** ![brson](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/brson/32/5197_2.png) [@brson](https://internals.rust-lang.org/u/brson)\
**Post date:** [July 30, 2016, 2:00am UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/4 "2016-07-30T02:00:09Z")

</div>

Discovering how to adapt std to use the cloudabi capability model does look like an interesting experiment…

---

<div class="post-metadata">

**Author:** ![jethrogb](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@jethrogb](https://internals.rust-lang.org/u/jethrogb)\
**Post date:** [July 30, 2016, 2:45am UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/5 "2016-07-30T02:45:06Z")

</div>

> [@brson](#):
>
> Discovering how to adapt std to use the cloudabi capability model does look like an interesting experiment...

Just use `FromRawFd` and friends. Edit: I suppose you're worried about a lot of `std` just not being available, such as `TcpListener::bind` and `File::open` etc.

---

<div class="post-metadata">

**Author:** ![Yohanesu75](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/yohanesu75/32/1982_2.png) [@Yohanesu75](https://internals.rust-lang.org/u/Yohanesu75)\
**Post date:** [December 6, 2016, 8:01pm UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/6 "2016-12-06T20:01:34Z")

</div>

I want to bring this thread back to life. It would be a really interesting experiment to add CloudABI to Rust. CloudABI is also identical across platforms so apparently you can compile once on any platform and run on any platform 🙂 However, compared to libc, cloudlibc has very few (~60) functions. Not sure what functions are missing compared to a “normal” libc but am currently looking into that.

Basically you would have one x86\_64-unknown-cloudabi target that would run on all OSs supporting CloudABI. Very cool!

Rust’s and CloudABI’s strong security added together would surely make a killer combination!

---

<div class="post-metadata">

**Author:** ![jethrogb](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@jethrogb](https://internals.rust-lang.org/u/jethrogb)\
**Post date:** [December 6, 2016, 8:20pm UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/7 "2016-12-06T20:20:19Z")

</div>

This would probably be easier once something like [Refactoring std for ultimate portability](https://internals.rust-lang.org/t/refactoring-std-for-ultimate-portability/4301) is implemented.

---

<div class="post-metadata">

**Author:** ![Yohanesu75](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/yohanesu75/32/1982_2.png) [@Yohanesu75](https://internals.rust-lang.org/u/Yohanesu75)\
**Post date:** [December 7, 2016, 1:12am UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/8 "2016-12-07T01:12:31Z")

</div>

That’s really interesting. When do we start? 😄

---

<div class="post-metadata">

**Author:** ![JeffBurdges](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/jeffburdges/32/2116_2.png) [@JeffBurdges](https://internals.rust-lang.org/u/JeffBurdges)\
**Post date:** [February 2, 2017, 10:09pm UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/9 "2017-02-02T22:09:25Z")

</div>

I like this idea. 🙂 In the long run, you’d want to fork `std` so that the interface it exposed was capability friendly, and eventually you’d want folks to develop against this capability oriented `std` even if they were not meaning to run their code on capsicum.

---

<div class="post-metadata">

**Author:** ![naicode](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/naicode/32/2254_2.png) [@naicode](https://internals.rust-lang.org/u/naicode)\
**Post date:** [March 30, 2017, 12:31am UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/10 "2017-03-30T00:31:16Z")

</div>

Here is a FOSDOM talk which introduces cloudabi: [https://fosdem.org/2017/schedule/event/cloudabi/](https://fosdem.org/2017/schedule/event/cloudabi/)

and a talk on 32C3: [https://media.ccc.de/v/32c3-7231-cloudabi](https://media.ccc.de/v/32c3-7231-cloudabi) (this one has better quality and seems to cover the same informations (through I’m still listening) ;=) )

Btw. Rust+CloudABI seems like a really nice idea

---

<div class="post-metadata">

**Author:** ![naicode](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/naicode/32/2254_2.png) [@naicode](https://internals.rust-lang.org/u/naicode)\
**Post date:** [March 30, 2017, 12:55am UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/11 "2017-03-30T00:55:25Z")

</div>

I just took a short look at the API and it seems that you **have to** create a alternative `std` something like using cfg to add some “additional” parts for capabilities won’t work as some of the syscall’s std uses are not available.

The most simple example is `open`, the variation of `open` in CoudABI is very similar to the `openat` system call, except that the mode parameter takes a different struct which does some more then what the mode parameter in linux `open`/`openat` does.

But then I think rust, at some point, needs support for alternative stable std’s anyway. At last if rust wants to take over micro-controllers (!= microprocessors).

---

<div class="post-metadata">

**Author:** ![JeffBurdges](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/jeffburdges/32/2116_2.png) [@JeffBurdges](https://internals.rust-lang.org/u/JeffBurdges)\
**Post date:** [March 31, 2017, 12:51am UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/12 "2017-03-31T00:51:16Z")

</div>

Yes, you want allocation, collections, etc. from `std` but you need `io`, etc. to go thought a capability controlled library.

---

<div class="post-metadata">

**Author:** ![JeffBurdges](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/jeffburdges/32/2116_2.png) [@JeffBurdges](https://internals.rust-lang.org/u/JeffBurdges)\
**Post date:** [July 3, 2017, 8:43am UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/13 "2017-07-03T08:43:40Z")

</div>

There is a listing of more capability-based tooling at [https://github.com/dckc/awesome-ocap](https://github.com/dckc/awesome-ocap)

---

<div class="post-metadata">

**Author:** ![EdSchouten](https://avatars.discourse-cdn.com/v4/letter/e/e9a140/32.png) [@EdSchouten](https://internals.rust-lang.org/u/EdSchouten)\
**Post date:** [December 22, 2017, 8:53am UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/14 "2017-12-22T08:53:31Z")

</div>

Hi there!

I’m the main author of CloudABI. Even though I’m quite interested in Rust, I only found time recently to start experimenting with this. The other day I managed to extend rustc to support CloudABI:

> <https://github.com/rust-lang/rust/pull/46940>

I’m now able to build very simple Rust binaries that don’t use std. I’m slowly working towards getting that to work, but that’s going to take some more time. I’ll post some more instructions here as things stabilise. Stay tuned!

---

<div class="post-metadata">

**Author:** ![EdSchouten](https://avatars.discourse-cdn.com/v4/letter/e/e9a140/32.png) [@EdSchouten](https://internals.rust-lang.org/u/EdSchouten)\
**Post date:** [January 8, 2018, 12:45pm UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/15 "2018-01-08T12:45:25Z")

</div>

Minor update: compiler changes have all been merged now. The latest nightly compiler should be able to target CloudABI properly.

Right now I’m working on getting fixes for libstd upstreamed. The most important change has been sent out earlier today: [https://github.com/rust-lang/rust/pull/47268](https://github.com/rust-lang/rust/pull/47268)

Once this pull request gets merged, it’s just a matter of getting all sorts of tiny fixes upstreamed here and there and set up automated continuous integration testing and builds.

It will probably not take long until we can use rustup, cargo, etc. to build Rust code for CloudABI. I’ll post instructions here when that’s possible.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [March 25, 2019, 8:26am UTC](https://internals.rust-lang.org/t/rust-cloudabi/3773/17 "2019-03-25T08:26:33Z")

</div>

Closed on March 25, 2019, 8:26am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
