@@ -109,16 +109,17 @@ pub(crate) fn compile_codegen_unit(
109109 attributes:: apply_to_llfn ( entry, llvm:: AttributePlace :: Function , & attrs) ;
110110 }
111111
112- // Define Objective-C module info for 32-bit x86 macOS . Note, this generates a global
113- // that gets added to the `llvm.compiler.used` variable, created later.
112+ // Define Objective-C module info and module flags . Note, the module info will
113+ // also be added to the `llvm.compiler.used` variable, created later.
114114 //
115- // This is only necessary when we need the linker to do its Objective-C-specific magic.
116- // We could theoretically do it unconditionally, but at a slight cost to linker
115+ // These are only necessary when we need the linker to do its Objective-C-specific
116+ // magic. We could theoretically do it unconditionally, but at a slight cost to linker
117117 // performance in the common case where it's unnecessary.
118- let uses_objc =
119- !cx. objc_classrefs . borrow ( ) . is_empty ( ) || !cx. objc_selrefs . borrow ( ) . is_empty ( ) ;
120- if uses_objc && cx. tcx . sess . target . arch == "x86" && cx. tcx . sess . target . os == "macos" {
121- cx. define_objc_module_info ( ) ;
118+ if !cx. objc_classrefs . borrow ( ) . is_empty ( ) || !cx. objc_selrefs . borrow ( ) . is_empty ( ) {
119+ if cx. tcx . sess . target . arch == "x86" && cx. tcx . sess . target . os == "macos" {
120+ cx. define_objc_module_info ( ) ;
121+ }
122+ cx. add_objc_module_flags ( ) ;
122123 }
123124
124125 // Finalize code coverage by injecting the coverage map. Note, the coverage map will
@@ -149,15 +150,6 @@ pub(crate) fn compile_codegen_unit(
149150 }
150151 }
151152
152- // Add Objective-C module flags.
153- //
154- // This is only necessary when we need the linker to do its Objective-C-specific magic.
155- // We could theoretically do it unconditionally, but at a slight cost to linker
156- // performance in the common case where it's unnecessary.
157- if uses_objc {
158- cx. add_objc_module_flags ( ) ;
159- }
160-
161153 // Finalize debuginfo
162154 if cx. sess ( ) . opts . debuginfo != DebugInfo :: None {
163155 cx. debuginfo_finalize ( ) ;
0 commit comments