Skip to content

Commit 02dc22b

Browse files
authored
Unrolled build for #146343
Rollup merge of #146343 - madsmtm:fix-platform_version, r=tgross35 Weakly export `platform_version` symbols The symbols `__isPlatformVersionAtLeast` and `__isOSVersionAtLeast`. This should allow linking both `compiler-rt` and `std`, which fixes #138944 (comment). r? tgross35 CC ``@zmodem,`` could you please verify that this works for you?
2 parents fefce3c + fe6f8cc commit 02dc22b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
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

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ fn compare_against_sw_vers() {
2828
let subminor: i32 = sw_vers.next().unwrap_or("0").parse().unwrap();
2929
assert_eq!(sw_vers.count(), 0);
3030

31+
// Test directly against the lookup
32+
assert_eq!(lookup_version().get(), pack_os_version(major as _, minor as _, subminor as _));
33+
3134
// Current version is available
3235
assert_eq!(__isOSVersionAtLeast(major, minor, subminor), 1);
3336

@@ -40,9 +43,6 @@ fn compare_against_sw_vers() {
4043
assert_eq!(__isOSVersionAtLeast(major, minor, subminor + 1), 0);
4144
assert_eq!(__isOSVersionAtLeast(major, minor + 1, subminor), 0);
4245
assert_eq!(__isOSVersionAtLeast(major + 1, minor, subminor), 0);
43-
44-
// Test directly against the lookup
45-
assert_eq!(lookup_version().get(), pack_os_version(major as _, minor as _, subminor as _));
4646
}
4747

4848
#[test]

0 commit comments

Comments
 (0)