From 8b67a37f8bb84a2d7445a032a73dd96d3f05fd17 Mon Sep 17 00:00:00 2001 From: Ola x Nilsson Date: Thu, 7 Sep 2023 15:14:34 +0200 Subject: [PATCH] Add cfg option gnu_time64_abi --- build.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/build.rs b/build.rs index 787b8b86a236d..a259cfe967c2a 100644 --- a/build.rs +++ b/build.rs @@ -79,6 +79,11 @@ fn main() { Some(_) | None => (), } + // Some ABIs need to redirect time related symbols to their time64 equivalents. + if is_gnu_time64_abi() { + println!("cargo:rustc-cfg=gnu_time64_abi"); + } + // On CI: deny all warnings if libc_ci { set_cfg("libc_deny_warnings"); @@ -281,3 +286,32 @@ fn set_cfg(cfg: &str) { } println!("cargo:rustc-cfg={}", cfg); } + +fn is_gnu_time64_abi() -> bool { + match env::var("CARGO_CFG_TARGET_ENV") { + Ok(target_env) => { + if target_env != "gnu" { + return false; + } + }, + Err(_) => panic!("CARGO_CFG_TARGET_ENV not set"), + } + match env::var("CARGO_CFG_TARGET_OS") { + Ok(target_os) => { + if target_os != "linux" { + return false; + } + }, + Err(_) => panic!("CARGO_CFG_TARGET_OS not set"), + } + let _ptrbits = match env::var("CARGO_CFG_TARGET_POINTER_WIDTH") { + Ok(bits) => { + if bits == "64" { + return false; + } + bits + }, + Err(_) => panic!("CARGO_CFG_TARGERT_POINTER_WIDTH not set"), + }; + return false; +}