libretro/rust-libretro

Name: rust-libretro

Owner: libretro

Description: libretro wrapper for Rust

Created: 2015-10-30 09:07:59.0

Updated: 2017-02-26 17:48:13.0

Pushed: 2014-11-08 03:55:39.0

Homepage:

Size: 748

Language: Rust

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

rust-libretro

WIP libretro wrapper for Rust.

License: MIT

Thread Safety Requirements

This software is intended soley for producing libretro core libraries, to be called from a correctly implemented libretro frontend. If you decide to call any such library from outside its specified environment then you must ensure thread safety. All calls to the library, with the exception of a call to retro_audio_callback, must be made from the same thread. Failure to follow this restriction may result in undefined behavior.

This restriction may be lifted in future versions if I can figure out how to do it without significantly harming performance.

Installation

rust-libretro cannot easily be distributed as a Cargo dependency because it is a library for producing libraries. The rust-libretro code needs to access symbols in your code, and this is not possible across crate boundaries. Additionally, libretro does not define a guaranteed first entry point for the core, so you cannot define that entry point in your own code and pass configuration data to rust-libretro from there.

Future versions of Cargo should make this easier, but for now the simplest solution is to clone this repo and make your updates directly.

You can then merge updated versions of only the files in rust_wrapper:

Set up a remote to upstream if you haven't already done so:

$ git remote add upstream https://github.com/mprobinson/rust-libretro.git

Fetch changes from upstream:

$ git fetch upstream

Tell git to prepare for a partial merge:

$ git merge --no-ff --no-commit -s ours upstream/master

Checkout only the changes to files in src/rust_wrapper:

$ git checkout upstream/master src/rust_wrapper/*

Merge those changes:

$ git commit

Compilation

Rust currently sets all library symbols visible, resulting is very bloated libraries. If you are linking with GNU ld it is possible to restrict the visible symbols to those required by the libretro API, using a version script. Cargo does not support custom rustc parameters, so first run cargo with –verbose to discover the cargo parameters. Then run rustc manually, passing the version script in src/visible_symbols.script by appending:

-C link-args="-Wl,-version-script=src/visible_symbols.script -Wl,-gc-sections"

This will result in a much more reasonably sized core. The core size may be futher reduced without loss of function by running strip -s.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.