Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jun 16, 2022
1 parent 4346979 commit 71dd2ea
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions objc2/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ macro_rules! sel {
#[used]
static _IMAGE_TAG: [u32; 2] = [0, 0];

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

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

0 comments on commit 71dd2ea

Please sign in to comment.