Skip to content

Commit fe6f8cc

Browse files
committed
Weakly export platform_version symbols
The symbols __isPlatformVersionAtLeast and __isOSVersionAtLeast. This allows the user to link both compiler_rt and std.
1 parent d51f0ea commit fe6f8cc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/std/src/sys/platform_version/darwin/public_extern.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ use super::{current_version, pack_i32_os_version};
7777
// NOTE: This symbol has a workaround in the compiler's symbol mangling to avoid mangling it, while
7878
// still not exposing it from non-cdylib (like `#[no_mangle]` would).
7979
#[rustc_std_internal_symbol]
80+
// NOTE: Making this a weak symbol might not be entirely the right solution for this, `compiler_rt`
81+
// doesn't do that, it instead makes the symbol have "hidden" visibility. But since this is placed
82+
// in `libstd`, which might be used as a dylib, we cannot do the same here.
83+
#[linkage = "weak"]
8084
// extern "C" is correct, Clang assumes the function cannot unwind:
8185
// https://github.com/llvm/llvm-project/blob/llvmorg-20.1.0/clang/lib/CodeGen/CGObjC.cpp#L3980
8286
//
@@ -145,6 +149,7 @@ pub(super) extern "C" fn __isPlatformVersionAtLeast(
145149
/// Old entry point for availability. Used when compiling with older Clang versions.
146150
// SAFETY: Same as for `__isPlatformVersionAtLeast`.
147151
#[rustc_std_internal_symbol]
152+
#[linkage = "weak"]
148153
pub(super) extern "C" fn __isOSVersionAtLeast(major: i32, minor: i32, subminor: i32) -> i32 {
149154
let version = pack_i32_os_version(major, minor, subminor);
150155
(version <= current_version()) as i32

0 commit comments

Comments
 (0)