The following code fails to link on macOS with incremental compilation. It works fine with incremental compilation turned off.
fn obj_alloc<T>(_p: T) -> *const [u8; 6] {
struct Foo(*const [u8; 6]);
unsafe impl Send for Foo {}
unsafe impl Sync for Foo {}
#[link_section="__TEXT,__objc_methname,cstring_literals"]
static OBJC_METH_VAR_NAME_ : [u8; 6] = *b"alloc\0";
#[link_section="__DATA,__objc_selrefs,literal_pointers,no_dead_strip"]
static OBJC_SELECTOR_REFERENCES_: Foo = Foo(&OBJC_METH_VAR_NAME_);
return OBJC_SELECTOR_REFERENCES_.0;
}
fn main() {
let i: u32 = 0;
obj_alloc(i);
}
The linker error is
= note: Undefined symbols for architecture x86_64:
"example::obj_alloc::OBJC_SELECTOR_REFERENCES_::ha196cc644aeae679", referenced from:
example::obj_alloc::h54a034c209c8e4e3 in example-4a01b102e2898ce7.4jffkl93bkv60fxe.rcgu.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The motivation for this weird code is getting native performance for objective-c message selectors. See SSheldon/rust-objc#49
The following code fails to link on macOS with incremental compilation. It works fine with incremental compilation turned off.
The linker error is
The motivation for this weird code is getting native performance for objective-c message selectors. See SSheldon/rust-objc#49