Skip to content

Commit

Permalink
Simpler window check
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Jul 23, 2024
1 parent bf46f35 commit c6b0aff
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions rubicon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ macro_rules! compatibility_check {
len
}

#[cfg(unix)]
#[ctor]
fn check_compatibility() {
eprintln!("Entering check_compatibility function");
let imported: &[(&str, &str)] = &[
Expand Down Expand Up @@ -681,18 +683,30 @@ macro_rules! compatibility_check {
panic!("{}", error_message);
}

#[cfg(unix)]
#[ctor]
fn compatibility_check_caller() {
check_compatibility();
}

#[cfg(windows)]
#[ctor]
fn compatibility_check_caller() {
std::thread::spawn(|| {
check_compatibility();
});
fn check_compatibility() {
// on Windows we cannot allocate at all from a DLL initializer,

let imported: &[(&str, &str)] = &[
("rustc-version", $crate::RUBICON_RUSTC_VERSION),
("target-triple", $crate::RUBICON_TARGET_TRIPLE),
$($feature)*
];
let exported = unsafe { COMPATIBILITY_INFO };

for item in imported.iter() {
if !exported.contains(item) {
eprintln!("Compatibility mismatch detected: {} (imported) != {} (exported)", item.0, item.1);
std::process::exit(1);
}
}
for item in exported.iter() {
if !imported.contains(item) {
eprintln!("Compatibility mismatch detected: {} (exported) != {} (imported)", item.0, item.1);
std::process::exit(1);
}
}
}
};
}
Expand Down

0 comments on commit c6b0aff

Please sign in to comment.