From db0613c72f5217e956123a49f7102650ca808cf9 Mon Sep 17 00:00:00 2001 From: southorange0929 Date: Tue, 14 May 2024 15:48:58 +0800 Subject: [PATCH 1/3] fix(openssl-sys): ignore atomic for openharmony armv7a --- openssl-sys/build/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openssl-sys/build/main.rs b/openssl-sys/build/main.rs index be4c21436..c04defe28 100644 --- a/openssl-sys/build/main.rs +++ b/openssl-sys/build/main.rs @@ -207,11 +207,13 @@ fn main() { } // https://github.com/openssl/openssl/pull/15086 + // Given that the armv7a architecture of openharmony doesn't support atomic, we should disregard this configuration. if version == Version::Openssl3xx && kind == "static" && (env::var("CARGO_CFG_TARGET_OS").unwrap() == "linux" || env::var("CARGO_CFG_TARGET_OS").unwrap() == "android") && env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32" + && !target.contains("ohos") { println!("cargo:rustc-link-lib=atomic"); } From d88441274ec136e1a20f7bb456e1feb4f12d1a36 Mon Sep 17 00:00:00 2001 From: southorange0929 Date: Mon, 12 Aug 2024 17:32:26 +0800 Subject: [PATCH 2/3] refactor: use env to adapt to more general scenarios --- openssl-sys/build/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/openssl-sys/build/main.rs b/openssl-sys/build/main.rs index c04defe28..559a82bab 100644 --- a/openssl-sys/build/main.rs +++ b/openssl-sys/build/main.rs @@ -207,15 +207,17 @@ fn main() { } // https://github.com/openssl/openssl/pull/15086 - // Given that the armv7a architecture of openharmony doesn't support atomic, we should disregard this configuration. + // Embrace the atomic capability library across various platforms. + // For instance, on certain platforms, llvm has relocated the atomic of the arm32 architecture to libclang_rt.builtins.a + // while some use libatomic.a, and others use libatomic_ops.a. + let atomic_name = env::var("DEP_ATOMIC").unwrap_or("atomic".to_owned()); if version == Version::Openssl3xx && kind == "static" && (env::var("CARGO_CFG_TARGET_OS").unwrap() == "linux" || env::var("CARGO_CFG_TARGET_OS").unwrap() == "android") && env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32" - && !target.contains("ohos") { - println!("cargo:rustc-link-lib=atomic"); + println!("cargo:rustc-link-lib={}",atomic_name); } if kind == "static" && target.contains("windows") { From 2e033c6f5ba3e0000c0d36625c61a36680a8c411 Mon Sep 17 00:00:00 2001 From: southorange0929 Date: Mon, 12 Aug 2024 17:48:06 +0800 Subject: [PATCH 3/3] chore: format code --- openssl-sys/build/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openssl-sys/build/main.rs b/openssl-sys/build/main.rs index 559a82bab..5ad2eda7a 100644 --- a/openssl-sys/build/main.rs +++ b/openssl-sys/build/main.rs @@ -207,7 +207,7 @@ fn main() { } // https://github.com/openssl/openssl/pull/15086 - // Embrace the atomic capability library across various platforms. + // Embrace the atomic capability library across various platforms. // For instance, on certain platforms, llvm has relocated the atomic of the arm32 architecture to libclang_rt.builtins.a // while some use libatomic.a, and others use libatomic_ops.a. let atomic_name = env::var("DEP_ATOMIC").unwrap_or("atomic".to_owned()); @@ -217,7 +217,7 @@ fn main() { || env::var("CARGO_CFG_TARGET_OS").unwrap() == "android") && env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32" { - println!("cargo:rustc-link-lib={}",atomic_name); + println!("cargo:rustc-link-lib={}", atomic_name); } if kind == "static" && target.contains("windows") {