-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dead links when unstable-static-class
enabled
#667
Comments
Hmm, we explicitly add But looking at it again, I think perhaps I was mistaken back then, and thought that this code meant that In any case, I don't see a reason to keep |
Hmm, actually, from my testing, it seems like |
Just to confirm: You're testing with |
I ran IDA to find the unwanted symbol. You can also try a min macos version lower than 12.0 to see a link error when I tried with UPDATE: rust version: |
I cloned this objc2 repo and checked out to diff --git a/crates/objc2/src/macros/mod.rs b/crates/objc2/src/macros/mod.rs
index 815f1025..9b8ce381 100644
--- a/crates/objc2/src/macros/mod.rs
+++ b/crates/objc2/src/macros/mod.rs
@@ -505,7 +505,7 @@ macro_rules! __statics_class {
}
/// SAFETY: Same as `REF` above in `__statics_sel!`.
- #[link_section = "__DATA,__objc_classrefs,regular,no_dead_strip"]
+ #[link_section = "__DATA,__objc_classrefs,regular"]
#[export_name = $crate::__macro_helpers::concat!(
"\x01L_OBJC_CLASSLIST_REFERENCES_$_",
$hash, And now there are no dead links. |
Now I have tried this one: diff --git a/crates/objc2/src/macros/mod.rs b/crates/objc2/src/macros/mod.rs
index 815f1025..25fd2542 100644
--- a/crates/objc2/src/macros/mod.rs
+++ b/crates/objc2/src/macros/mod.rs
@@ -443,11 +443,11 @@ macro_rules! __statics_sel {
// Clang uses `no_dead_strip` in the link section for some reason,
// which other tools (notably some LLVM tools) now assume is
// present, so we have to add it as well.
- link_section = "__DATA,__objc_selrefs,literal_pointers,no_dead_strip",
+ link_section = "__DATA,__objc_selrefs,literal_pointers",
)]
#[cfg_attr(
all(target_os = "macos", target_arch = "x86"),
- link_section = "__OBJC,__message_refs,literal_pointers,no_dead_strip",
+ link_section = "__OBJC,__message_refs,literal_pointers",
)]
#[export_name = $crate::__macro_helpers::concat!("\x01L_OBJC_SELECTOR_REFERENCES_", $hash)]
static mut REF: $crate::__macro_helpers::UnsafeCell<$crate::runtime::Sel> = unsafe {
@@ -505,7 +505,7 @@ macro_rules! __statics_class {
}
/// SAFETY: Same as `REF` above in `__statics_sel!`.
- #[link_section = "__DATA,__objc_classrefs,regular,no_dead_strip"]
+ #[link_section = "__DATA,__objc_classrefs,regular"]
#[export_name = $crate::__macro_helpers::concat!(
"\x01L_OBJC_CLASSLIST_REFERENCES_$_",
$hash,
@@ -537,7 +537,7 @@ macro_rules! __statics_class {
static NAME_DATA: [$crate::__macro_helpers::u8; X.len()] = $crate::__statics_string_to_known_length_bytes!(X);
/// SAFETY: Same as `REF` above in `__statics_sel!`.
- #[link_section = "__OBJC,__cls_refs,literal_pointers,no_dead_strip"]
+ #[link_section = "__OBJC,__cls_refs,literal_pointers"]
#[export_name = $crate::__macro_helpers::concat!(
"\x01L_OBJC_CLASS_REFERENCES_",
$hash, And it at least works on my machine:) The system info: |
Hmm, I clearly don't understand enough about this, have opened llvm/llvm-project#114111 to get some clarification from the Clang developers. |
I've tried both
unstable-static-class
andunstable-static-class-inlined
with LTO enabled. It seems that there are some dead links to the classes. For example, when I enable the featureNSAttributedString
inobjc2-app-kit
,NSPresentationIntent
is also linked to the final binary even if I don't use it. Is there some way to optimize these links out?The text was updated successfully, but these errors were encountered: