@@ -588,6 +588,10 @@ impl<'ll> CodegenCx<'ll, '_> {
588588 class_t
589589 }
590590
591+ // We do our best here to match what Clang does when compiling Objective-C natively. We
592+ // deduplicate references within a CGU, but we need a reference definition in each referencing
593+ // CGU. All attempts at using external references to a single reference definition result in
594+ // linker errors.
591595 fn get_objc_classref ( & self , classname : Symbol ) -> & ' ll Value {
592596 let mut classrefs = self . objc_classrefs . borrow_mut ( ) ;
593597 if let Some ( classref) = classrefs. get ( & classname) . copied ( ) {
@@ -631,6 +635,10 @@ impl<'ll> CodegenCx<'ll, '_> {
631635 g
632636 }
633637
638+ // We do our best here to match what Clang does when compiling Objective-C natively. We
639+ // deduplicate references within a CGU, but we need a reference definition in each referencing
640+ // CGU. All attempts at using external references to a single reference definition result in
641+ // linker errors.
634642 fn get_objc_selref ( & self , methname : Symbol ) -> & ' ll Value {
635643 let mut selrefs = self . objc_selrefs . borrow_mut ( ) ;
636644 if let Some ( selref) = selrefs. get ( & methname) . copied ( ) {
@@ -684,6 +692,13 @@ impl<'ll> CodegenCx<'ll, '_> {
684692 assert_eq ! ( self . tcx. sess. target. arch, "x86" ) ;
685693 assert_eq ! ( self . tcx. sess. target. os, "macos" ) ;
686694
695+ // struct _objc_module {
696+ // long version; // Hardcoded to 7 in Clang.
697+ // long size; // sizeof(struct _objc_module)
698+ // char *name; // Hardcoded to classname "" in Clang.
699+ // struct _objc_symtab* symtab; // Null without class or category definitions.
700+ // }
701+
687702 let llty = self . type_named_struct ( "struct._objc_module" ) ;
688703 let i32_llty = self . type_i32 ( ) ;
689704 let ptr_llty = self . type_ptr ( ) ;
0 commit comments