Skip to content

Commit 61e29f3

Browse files
authored
Adding GC: MMTk tag to Julia's banner when building with MMTk (#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) ```
1 parent eeb9f7f commit 61e29f3

File tree

6 files changed

+31
-2
lines changed

6 files changed

+31
-2
lines changed

mmtk/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ edition = "2018"
1111
[package.metadata.julia]
1212
# Our CI matches the following line and extract mmtk/julia. If this line is updated, please check ci yaml files and make sure it works.
1313
julia_repo = "https://github.com/mmtk/julia.git"
14-
julia_version = "7a953be76af34dee24e17cf2b33ba5fb0a7eac02"
14+
julia_version = "5cacfa481ccb467a14cdba322c65fd7805d6d8f6"
1515

1616
[lib]
1717
crate-type = ["cdylib"]
1818

1919
[build-dependencies]
2020
cc = "*"
21-
built = "*"
21+
built = { version = "*", features = ["git2"] }
2222
bindgen = "*"
2323

2424
[profile.release]

mmtk/api/mmtk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ extern void mmtk_runtime_panic(void);
5050
extern void mmtk_unreachable(void);
5151
extern unsigned char mmtk_pin_object(void* obj);
5252
extern bool mmtk_is_pinned(void* obj);
53+
extern const char* get_mmtk_version(void);
5354

5455
extern void mmtk_set_vm_space(void* addr, size_t size);
5556
extern void mmtk_immortal_region_post_alloc(void* addr, size_t size);

mmtk/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,6 @@ fn main() {
7171
bindings
7272
.write_to_file("src/julia_types.rs")
7373
.expect("Couldn't write bindings!");
74+
75+
built::write_built_file().expect("Failed to acquire build-time information");
7476
}

mmtk/src/api.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,3 +504,10 @@ pub extern "C" fn mmtk_unpin_object(_object: ObjectReference) -> bool {
504504
pub extern "C" fn mmtk_is_pinned(_object: ObjectReference) -> bool {
505505
false
506506
}
507+
508+
#[no_mangle]
509+
pub extern "C" fn get_mmtk_version() -> *const c_char {
510+
crate::build_info::MMTK_JULIA_FULL_VERSION_STRING
511+
.as_c_str()
512+
.as_ptr() as _
513+
}

mmtk/src/build_info.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use std::ffi::CString;
2+
3+
mod raw {
4+
// The include imports a full list of the constants in built.rs from https://docs.rs/built/latest/built/index.html
5+
include!(concat!(env!("OUT_DIR"), "/built.rs"));
6+
}
7+
8+
lazy_static! {
9+
// Owned string for the binding version, such as MMTk Julia 0.14.0 (cfc755f-dirty)
10+
static ref BINDING_VERSION_STRING: String = match (raw::GIT_COMMIT_HASH, raw::GIT_DIRTY) {
11+
(Some(hash), Some(dirty)) => format!("Built with MMTk Julia {} ({}{})", raw::PKG_VERSION, hash.split_at(7).0, if dirty { "-dirty" } else { "" }),
12+
(Some(hash), None) => format!("Built with MMTk Julia {} ({}{})", raw::PKG_VERSION, hash.split_at(7).0, "-?"),
13+
_ => format!("Built with MMTk Julia {}", raw::PKG_VERSION),
14+
};
15+
// Owned string for both binding and core version.
16+
#[derive(Debug)]
17+
pub static ref MMTK_JULIA_FULL_VERSION_STRING: CString = CString::new(format!("{}, using {}", *BINDING_VERSION_STRING, *mmtk::build_info::MMTK_FULL_BUILD_INFO)).unwrap();
18+
}

mmtk/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::sync::{Arc, Condvar, Mutex, RwLock};
1717

1818
pub mod active_plan;
1919
pub mod api;
20+
mod build_info;
2021
pub mod collection;
2122
pub mod object_model;
2223
pub mod reference_glue;

0 commit comments

Comments
 (0)