An open API service indexing awesome lists of open source software.

https://github.com/erikbjare/rust-exploration

Exploring the wonders of Rust by writing a gravity simulator and doing some FFI
https://github.com/erikbjare/rust-exploration

experimentation ffi nbody

Last synced: 15 days ago
JSON representation

Exploring the wonders of Rust by writing a gravity simulator and doing some FFI

Awesome Lists containing this project

README

        

rust-exploration
=============

My own exercises in:

- calling Rust code from other languages.
- writing a gravity simulator.

# Usage

This repo currently contains two experiments.

## Gravitysim

Just run with:

```
cargo run
```

You can see all the available command line arguments with:

```
cargo run -- --help
```

## FFI part

Compile the Rust code:

```
cargo build --release
```

Call the library from Python:

```
cd misc
python3 call_with_python.py
```

# Decreasing executable size

Use `strip` to remove debug symbols (almost halves the size of the executable!):

```
strip target/release/gravitysim
```

The smallest I managed to get the binary down to was ~1.6MB. This with the system allocator, `lto=true`, `panic='abort'` and use of `strip`.