Skip to content

Commit 688791e

Browse files
authored
Get build info from mmtk-core (#174)
1 parent daf6170 commit 688791e

File tree

9 files changed

+256
-8
lines changed

9 files changed

+256
-8
lines changed

mmtk/Cargo.lock

Lines changed: 216 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mmtk/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "mmtk_openjdk"
33
version = "0.14.1"
44
authors = [" <>"]
55
rust-version = "1.57.0"
6+
build = "build.rs"
67

78
[lib]
89
name = "mmtk_openjdk"
@@ -16,7 +17,7 @@ lto = true
1617
[package.metadata.openjdk]
1718
# 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.
1819
openjdk_repo = "https://github.com/mmtk/openjdk.git"
19-
openjdk_version = "b133bb2630121b6babc35750444f178b5d240ae0"
20+
openjdk_version = "ad1809129d6288e7f8226990840e5d32aab0ea34"
2021

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

36+
[build-dependencies]
37+
built = { version = "0.5.1", features = ["git2"] }
38+
3539
[features]
3640
default = []
3741
mmtk_extreme_assertions = ["mmtk/extreme_assertions"]

mmtk/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
built::write_built_file().expect("Failed to acquire build-time information");
3+
}

mmtk/src/api.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ static NO_BARRIER: sync::Lazy<CString> = sync::Lazy::new(|| CString::new("NoBarr
2424
static OBJECT_BARRIER: sync::Lazy<CString> =
2525
sync::Lazy::new(|| CString::new("ObjectBarrier").unwrap());
2626

27+
#[no_mangle]
28+
pub extern "C" fn get_mmtk_version() -> *const c_char {
29+
crate::build_info::MMTK_OPENJDK_FULL_VERSION.as_ptr() as _
30+
}
31+
2732
#[no_mangle]
2833
pub extern "C" fn mmtk_active_barrier() -> *const c_char {
2934
match SINGLETON.get_plan().constraints().barrier {

mmtk/src/build_info.rs

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

mmtk/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use mmtk::MMTK;
2121
mod abi;
2222
pub mod active_plan;
2323
pub mod api;
24+
mod build_info;
2425
pub mod collection;
2526
mod gc_work;
2627
pub mod object_model;

0 commit comments

Comments
 (0)