Skip to content

Commit

Permalink
Adding GC: MMTk tag to Julia's banner when building with MMTk (mmtk…
Browse files Browse the repository at this point in the history
…#193)

Merge with mmtk/julia#72.

Should add info to Julia's banner about the version of MMTk used in the
build such as:

```
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.12.0-DEV.955 (2024-11-26)
 _/ |\__'_|_|_|\__'_|  |  adding-tag-to-banner/0ccc307863* (fork: 101 commits, 134 days)
|__/                   |  Built with MMTk Julia 0.1.0 (a775934-dirty), using MMTk 0.27.0 (de10fa4, DEFAULT, IMMIX_NON_MOVING, IMMIX_SMALLER_BLOCK, OBJECT_PINNING, VM_SPACE)
```
  • Loading branch information
udesou committed Dec 4, 2024
1 parent 8a7ea90 commit 6ef2d4b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ crate-type = ["cdylib"]

[build-dependencies]
cc = "*"
built = "*"
built = { version = "*", features = ["git2"] }
bindgen = "*"

[profile.release]
Expand Down
1 change: 1 addition & 0 deletions mmtk/api/mmtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern void mmtk_runtime_panic(void);
extern void mmtk_unreachable(void);
extern unsigned char mmtk_pin_object(void* obj);
extern bool mmtk_is_pinned(void* obj);
extern const char* get_mmtk_version(void);

extern void mmtk_set_vm_space(void* addr, size_t size);
extern void mmtk_immortal_region_post_alloc(void* addr, size_t size);
Expand Down
2 changes: 2 additions & 0 deletions mmtk/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,6 @@ fn main() {
bindings
.write_to_file("src/julia_types.rs")
.expect("Couldn't write bindings!");

built::write_built_file().expect("Failed to acquire build-time information");
}
7 changes: 7 additions & 0 deletions mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,10 @@ pub extern "C" fn mmtk_unpin_object(_object: ObjectReference) -> bool {
pub extern "C" fn mmtk_is_pinned(_object: ObjectReference) -> bool {
false
}

#[no_mangle]
pub extern "C" fn get_mmtk_version() -> *const c_char {
crate::build_info::MMTK_JULIA_FULL_VERSION_STRING
.as_c_str()
.as_ptr() as _
}
18 changes: 18 additions & 0 deletions mmtk/src/build_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use std::ffi::CString;

mod raw {
// The include imports a full list of the constants in built.rs from https://docs.rs/built/latest/built/index.html
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

lazy_static! {
// Owned string for the binding version, such as MMTk Julia 0.14.0 (cfc755f-dirty)
static ref BINDING_VERSION_STRING: String = match (raw::GIT_COMMIT_HASH, raw::GIT_DIRTY) {
(Some(hash), Some(dirty)) => format!("Built with MMTk Julia {} ({}{})", raw::PKG_VERSION, hash.split_at(7).0, if dirty { "-dirty" } else { "" }),
(Some(hash), None) => format!("Built with MMTk Julia {} ({}{})", raw::PKG_VERSION, hash.split_at(7).0, "-?"),
_ => format!("Built with MMTk Julia {}", raw::PKG_VERSION),
};
// Owned string for both binding and core version.
#[derive(Debug)]
pub static ref MMTK_JULIA_FULL_VERSION_STRING: CString = CString::new(format!("{}, using {}", *BINDING_VERSION_STRING, *mmtk::build_info::MMTK_FULL_BUILD_INFO)).unwrap();
}
1 change: 1 addition & 0 deletions mmtk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::sync::{Arc, Condvar, Mutex, RwLock};

pub mod active_plan;
pub mod api;
mod build_info;
pub mod collection;
pub mod object_model;
pub mod reference_glue;
Expand Down

0 comments on commit 6ef2d4b

Please sign in to comment.