Skip to content

Commit

Permalink
Add local build instructions to the README
Browse files Browse the repository at this point in the history
  • Loading branch information
eightbitraptor committed Nov 26, 2024
1 parent 9eb56cd commit 5f9ffb0
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,43 @@ This repository holds the [MMTk](https://www.mmtk.io/) bindings for Ruby. The bi

Since this repository is sync'd into [ruby/ruby](https://github.com/ruby/ruby/), you can choose to either build it in this repository or build it in ruby/ruby. If you're building it in this repository, note that it is only expected to work on the latest commit of Ruby master.

1. Build Ruby by following the [Building Ruby](https://docs.ruby-lang.org/en/master/contributing/building_ruby_md.html) guide, but append `--with-shared-gc=<dir>` when configuring. `dir` will be the directory that the compiled GC implementations will be placed in.
To build `librubygc.mmtk.so` locally, run the following:

```sh
rake compile
```
This command will:

- **Clone the Ruby repository**: If you don't already have it, the script clones Ruby into `res/ruby`.
- **Copy MMTk GC code**: It copies the MMTk garbage collector code into the Ruby source tree.
- **Configure and build Ruby**: Sets up the build configurations to integrate MMTk with Ruby's garbage collector API.
- **Compiling the MMTk shared library**: Builds `librubygc.mmtk.so` using Rust's Cargo build system.
- **Install the shared library**: Copies `librubygc.mmtk.so` into the `mod_gc` directory.

Once it's done, you'll have a shared object `mod_gc/librubygc.mmtk.so` (`modgc/librubygc.mmtk.bundle` on macOS), that can be loaded into any Ruby interpeter built `--with-shared-gc` support.

Successful builds, when loaded, will display `+GC[mmtk]` in the Ruby version string. This indicates that Ruby has been compiled with shared GC support and that MMTk is loaded.

```sh
RUBY_GC_LIBRARY=mmtk ruby -v
ruby 3.4.0dev (2024-11-25T13:05:23Z master f127bcb829) +PRISM +GC[mmtk] [arm64-darwin24]
```

**Note**: Make sure you have all the necessary dependencies installed:

- **Rust toolchain**: Required for building MMTk.
- **Ruby build dependencies**: Libraries and tools needed to compile Ruby from source.
- **Rake**: Ruby's build program, used to run the compile task.

That's it! You're all set to experiment with different GC algorithms in Ruby using MMTk.








TODO: rest of the building guide

### Running

Expand Down

0 comments on commit 5f9ffb0

Please sign in to comment.