Skip to content

Commit dc88b67

Browse files
committed
Comments
1 parent 84308a8 commit dc88b67

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

objc2/src/macros.rs

+8
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ macro_rules! sel {
7676
#[used]
7777
static _IMAGE_TAG: [u32; 2] = [0, 0];
7878

79+
// Marked with `unnamed_addr` in Objective-C's LLVM.
80+
// See rust-lang/rust#18297
81+
// Should only be an optimization (?)
7982
#[link_section = "__TEXT,__objc_methname,cstring_literals"]
8083
#[export_name = concat!("\x01L_OBJC_METH_VAR_NAME_", $crate::__proc_macros::hash_idents!($($idents)+))]
8184
static NAME: [u8; X.len()] = {
@@ -89,6 +92,8 @@ macro_rules! sel {
8992
};
9093

9194
// Place the constant value in the correct section.
95+
//
96+
// Clang uses `no_dead_strip` here for some reason?
9297
#[link_section = "__DATA,__objc_selrefs,literal_pointers"]
9398
#[export_name = concat!("\x01L_OBJC_SELECTOR_REFERENCES_", $crate::__proc_macros::hash_idents!($($idents)+))]
9499
static mut REF: &[u8; X.len()] = &NAME;
@@ -97,6 +102,9 @@ macro_rules! sel {
97102
// loaded, so we need to use a volatile read to prevent the
98103
// optimizer from thinking it can circumvent the read through REF.
99104
//
105+
// Clang avoids this by marking `REF` with LLVM's
106+
// `externally_initialized`.
107+
//
100108
// TODO: `::core` here could be replaced with some more
101109
// sophisticated logic so we don't rely on downstream users having
102110
// this setup.

0 commit comments

Comments
 (0)