Skip to content

Commit

Permalink
Get build info from mmtk-core (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
qinsoon authored Aug 15, 2022
1 parent daf6170 commit 688791e
Show file tree
Hide file tree
Showing 9 changed files with 256 additions and 8 deletions.
222 changes: 216 additions & 6 deletions mmtk/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions mmtk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "mmtk_openjdk"
version = "0.14.1"
authors = [" <>"]
rust-version = "1.57.0"
build = "build.rs"

[lib]
name = "mmtk_openjdk"
Expand All @@ -16,7 +17,7 @@ lto = true
[package.metadata.openjdk]
# Our CI matches the following line and extract mmtk/openjdk. If this line is updated, please check ci yaml files and make sure it works.
openjdk_repo = "https://github.com/mmtk/openjdk.git"
openjdk_version = "b133bb2630121b6babc35750444f178b5d240ae0"
openjdk_version = "ad1809129d6288e7f8226990840e5d32aab0ea34"

[dependencies]
libc = "0.2"
Expand All @@ -28,10 +29,13 @@ once_cell = "1.10.0"
# - change branch
# - change repo name
# But other changes including adding/removing whitespaces in commented lines may break the CI.
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "a96e8f991c91a81df51e7975849441f52fdbcdcc" }
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "4904004d55c48858d12a97a8e2ebb559fb91c0de" }
# Uncomment the following to build locally
# mmtk = { path = "../repos/mmtk-core" }

[build-dependencies]
built = { version = "0.5.1", features = ["git2"] }

[features]
default = []
mmtk_extreme_assertions = ["mmtk/extreme_assertions"]
Expand Down
3 changes: 3 additions & 0 deletions mmtk/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
built::write_built_file().expect("Failed to acquire build-time information");
}
5 changes: 5 additions & 0 deletions mmtk/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ static NO_BARRIER: sync::Lazy<CString> = sync::Lazy::new(|| CString::new("NoBarr
static OBJECT_BARRIER: sync::Lazy<CString> =
sync::Lazy::new(|| CString::new("ObjectBarrier").unwrap());

#[no_mangle]
pub extern "C" fn get_mmtk_version() -> *const c_char {
crate::build_info::MMTK_OPENJDK_FULL_VERSION.as_ptr() as _
}

#[no_mangle]
pub extern "C" fn mmtk_active_barrier() -> *const c_char {
match SINGLETON.get_plan().constraints().barrier {
Expand Down
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 @@
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 OpenJDK 0.14.0 (cfc755f-dirty)
static ref BINDING_VERSION_STRING: String = match (raw::GIT_COMMIT_HASH, raw::GIT_DIRTY) {
(Some(hash), Some(dirty)) => format!("MMTk OpenJDK {} ({}{})", raw::PKG_VERSION, hash.split_at(7).0, if dirty { "-dirty" } else { "" }),
(Some(hash), None) => format!("MMTk OpenJDK {} ({}{})", raw::PKG_VERSION, hash.split_at(7).0, "-?"),
_ => format!("MMTk OpenJDK {}", raw::PKG_VERSION),
};
// Owned string for both binding and core version.
static ref MMTK_OPENJDK_FULL_VERSION_STRING: String = format!("{}, using {}", *BINDING_VERSION_STRING, *mmtk::build_info::MMTK_FULL_BUILD_INFO);

// Exposed &str for the full version.
pub static ref MMTK_OPENJDK_FULL_VERSION: &'static str = &MMTK_OPENJDK_FULL_VERSION_STRING;
}
1 change: 1 addition & 0 deletions mmtk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use mmtk::MMTK;
mod abi;
pub mod active_plan;
pub mod api;
mod build_info;
pub mod collection;
mod gc_work;
pub mod object_model;
Expand Down
Loading

0 comments on commit 688791e

Please sign in to comment.