Skip to content

Commit fd0e7e8

Browse files
authored
Updating README, and adding target to regen julia_types.rs (#215)
Adding new instructions to build Julia with MMTk since upstream already supports it. Also adding some clarification about the FFI bindings in `julia_types.rs` and a target to regenerate that file.
1 parent b69acf5 commit fd0e7e8

File tree

3 files changed

+746
-33
lines changed

3 files changed

+746
-33
lines changed

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,15 @@ julia-debug:
5454
@echo "Building the Julia project in $(JULIA_PATH)";
5555
@cd $(JULIA_PATH) && $(PROJECT_DIRS) $(MMTK_VARS) make debug
5656

57+
regen-bindgen-ffi:
58+
@echo "Regenerating the Rust FFI bindings for Julia (and rebuilding the binding)";
59+
@cd $(MMTK_JULIA_DIR) && rm -rf mmtk/src/julia_types.rs
60+
@$(MAKE) clean
61+
@$(MAKE) release
62+
5763
# Clean up the build artifacts
5864
clean:
5965
@echo "Cleaning up build artifacts in $(JULIA_PATH) and $(MMTK_JULIA_DIR)";
6066
@cd $(MMTK_JULIA_DIR)mmtk && cargo clean
6167

62-
.PHONY: release debug julia julia-debug clean
68+
.PHONY: release debug julia julia-debug clean regen-bindgen-ffi

README.md

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,31 @@
22

33
### Quick Building Guide
44

5+
To quickly build Julia with MMTk, check out Julia from its main repository instead and create a `Make.user` file containing `MMTK_PLAN=Immix`.
6+
7+
```
8+
git clone https://github.com/JuliaLang/julia
9+
cd julia && echo 'MMTK_PLAN=Immix' > Make.user && make
10+
```
11+
12+
This should automatically check out a (binary) version of this repo, and link it when building Julia itself.
13+
14+
To build only the mmtk-julia binding from source, run:
15+
516
```
6-
git clone https://github.com/mmtk/mmtk-julia
7-
git clone https://github.com/mmtk/julia
8-
(cd julia && git checkout dev && echo 'MMTK_PLAN=Immix' > Make.user) # or MMTK_PLAN=StickyImmix to use Sticky Immix
9-
export JULIA_PATH=`pwd`/julia
10-
export MMTK_JULIA_DIR=`pwd`/mmtk-julia
11-
(cd mmtk-julia/mmtk && cargo build --features immix --release) # or drop "--release" for a debug build
12-
MMTK_BUILD=release MMTK_JULIA_DIR=`pwd`/mmtk-julia make -C julia # or "MMTK_BUILD=debug"
17+
git clone https://github.com/mmtk/mmtk-julia -b master
18+
(cd mmtk-julia && make release) # or "make debug" for a debug build
1319
```
1420

1521
If you would like debugging information in your release build of MMTk, add `debug = true` under `[profile.release]` in `mmtk/Cargo.toml`.
22+
Below, we provide some instructions on how to build the mmtk-julia binding from source _and_ link it when building Julia.
1623

1724
### Checking out and Building Julia with MMTk
1825

19-
Besides checking out the binding (this repository), it is also necessary to checkout a fork containing a modified version of the Julia repository (https://github.com/mmtk/julia).
20-
_Use the `dev` branch of the Julia repository._
21-
For example, we check out the fork as a sibling of `mmtk-julia`.
22-
For step-by-step instructions, read the section "Quick Building Guide".
26+
If you'd like to try out Julia with MMTk, simply clone the Julia repository from https://github.com/JuliaLang/julia and create a `Make.user` file inside the `julia` folder containing `MMTK_PLAN=Immix`. This will automatically checkout the latest release of the mmtk-julia binding and link it while building Julia itself.
27+
28+
To build the binding from source, besides checking out this repository, it is also necessary to checkout a version of the Julia repository (https://github.com/JuliaLang/julia). We recommend checking out the latest master, but any commit after [this](https://github.com/JuliaLang/julia/commit/22134ca28e92df321bdd08502ddd86ad2d6d614f) should work.
29+
For example, we check out Julia as a sibling of `mmtk-julia`.
2330

2431
The directory structure should look like the diagram below:
2532

@@ -34,35 +41,40 @@ Your working directory/
3441

3542
#### Build Julia binding in Rust
3643

37-
Before building Julia, build the binding in `mmtk-julia/mmtk`. You must have already checked out Julia, set `JULIA_PATH` to point to the checkout (remember to check out the `dev` branch!) and set `MMTK_JULIA_DIR` to the binding's top-level directory.
44+
Before building Julia, build the binding in `mmtk-julia`. Set `MMTK_JULIA_DIR` to the absolute path containing the binding's top-level directory and build the binding by running `make release` or `make debug` from that directory.
3845

39-
In `mmtk-core` we currently support either Immix or StickyImmix implementations.
40-
Build it with `cargo build --features immix` or `cargo build --features stickyimmix`.
41-
Add `--release` at the end if you would like to have a release build, otherwise it is a debug build.
46+
We currently only support a (non-moving) Immix implementation. We hope to add support for non-moving StickyImmix and the respective moving versions of both collectors in the near future. We also only support x86_64 Linux, more architectures should also be supported in the near future.
4247
For a release build with debugging information, first add `debug = true` under `[profile.release]` in `mmtk/Cargo.toml`.
48+
Make sure you have the prerequisites for building [MMTk](https://github.com/mmtk/mmtk-core#requirements).
4349

44-
#### Build Julia with MMTk
50+
#### Build Julia with MMTk (from source)
4551

46-
To build Julia with MMTk, first ensure you have the prerequisites for building both [Julia](https://github.com/JuliaLang/julia/blob/master/doc/src/devdocs/build/build.md#required-build-tools-and-external-libraries) and [MMTk](https://github.com/mmtk/mmtk-core#requirements).
52+
To build Julia with MMTk using the version built in the previous step, first ensure you have the prerequisites for building [Julia](https://github.com/JuliaLang/julia/blob/master/doc/src/devdocs/build/build.md#required-build-tools-and-external-libraries).
4753

48-
Next create a `Make.user` file in the top-level directory of the Julia repository consisting of the line `MMTK_PLAN=Immix` or `MMTK_PLAN=StickyImmix`.
54+
Next create a `Make.user` file in the top-level directory of the Julia repository consisting of the line `MMTK_PLAN=Immix`.
4955

50-
Finally, set the following environment variables:
56+
Finally, if you have not done it already, set the following environment variable:
5157

5258
```
53-
export MMTK_BUILD=release # or debug depending on how you build the Julia binding in Rust
5459
export MMTK_JULIA_DIR=<path-to-mmtk-julia>
5560
```
56-
... and run `make`.
61+
... and run `make` from Julia's top-level directory.
5762

5863
Alternatively you can set the environment variables in your `Make.user`
5964

6065
```
61-
export MMTK_BUILD := release
6266
export MMTK_JULIA_DIR := <path-to-mmtk-julia>
63-
export MMTK_PLAN := Immix # or export MMTK_PLAN := StickyImmix
67+
export MMTK_PLAN := Immix
6468
```
6569

70+
If you have done a debug build of the binding, make sure to also set `MMTK_BUILD=debug` before building Julia.
71+
72+
### Rust FFI bindings from Julia
73+
74+
The mmtk-julia binding requires a set of Rust FFI bindings that are automatically generated from the Julia repository using [bindgen](https://github.com/rust-lang/rust-bindgen). In this repository, the FFI bindings have already been generated, and added to the file `mmtk/src/julia_types.rs`.
75+
However, if Julia changes the object representation of any of the types defined in the FFI bindings in `mmtk/src/julia_types.rs`, that file will become outdated.
76+
To generate the FFI bindings again (and rebuild the binding), checkout the Julia repository following the steps described [previously](#checking-out-and-building-julia-with-mmtk), set the environment variable `JULIA_PATH` to point to the `julia` directory and run `make regen-bindgen-ffi` from the binding's top-level directory, note that this step will already do a release build of mmtk-julia containing the new version of `julia_types.rs`. Make sure you have all the [requirements](https://rust-lang.github.io/rust-bindgen/requirements.html) to running `bindgen`.
77+
6678
### Heap Size
6779

6880
Currently MMTk supports a fixed heap limit or variable heap within an interval. The default is a variable heap with the minimum heap size set to Julia's [`default_collection_interval`](https://github.com/mmtk/julia/blob/847cddeb7b9ddb5d6b66bec4c19d3a711748a45b/src/gc.c#L651) and the maximum size set to 70% of the free memory available. To change these values set the environment variables `MMTK_MIN_HSIZE` and `MMTK_MAX_HSIZE` to set the mininum and maximum size in megabytes, or `MMTK_MIN_HSIZE_G` and `MMTK_MAX_HSIZE_G` to set the size in gigabytes. If both environment variables are set, MMTk will use the size in megabytes. To set a fixed heap size, simply set only the variables `MMTK_MAX_HSIZE` or `MMTK_MAX_HSIZE_G`, or set `MMTK_MIN_HSIZE` or `MMTK_MIN_HSIZE_G` to 0. Note that these values can be decimal numbers, e.g. `MMTK_MAX_HSIZE_G=1.5`.

0 commit comments

Comments
 (0)