File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,9 +120,15 @@ fn codegen_global_asm_inner<'tcx>(
120120 }
121121
122122 let symbol = tcx. symbol_name ( instance) ;
123+ let symbol_name = if tcx. sess . target . is_like_darwin {
124+ format ! ( "_{}" , symbol. name)
125+ } else {
126+ symbol. name . to_owned ( )
127+ } ;
128+
123129 // FIXME handle the case where the function was made private to the
124130 // current codegen unit
125- global_asm. push_str ( & escape_symbol_name ( tcx, symbol . name , span) ) ;
131+ global_asm. push_str ( & escape_symbol_name ( tcx, & symbol_name , span) ) ;
126132 }
127133 GlobalAsmOperandRef :: SymStatic { def_id } => {
128134 if cfg ! ( not( feature = "inline_asm_sym" ) ) {
@@ -134,7 +140,13 @@ fn codegen_global_asm_inner<'tcx>(
134140
135141 let instance = Instance :: mono ( tcx, def_id) ;
136142 let symbol = tcx. symbol_name ( instance) ;
137- global_asm. push_str ( & escape_symbol_name ( tcx, symbol. name , span) ) ;
143+ let symbol_name = if tcx. sess . target . is_like_darwin {
144+ format ! ( "_{}" , symbol. name)
145+ } else {
146+ symbol. name . to_owned ( )
147+ } ;
148+
149+ global_asm. push_str ( & escape_symbol_name ( tcx, & symbol_name, span) ) ;
138150 }
139151 }
140152 }
Original file line number Diff line number Diff line change @@ -574,7 +574,13 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
574574 CInlineAsmOperand :: Const { ref value } => {
575575 generated_asm. push_str ( value) ;
576576 }
577- CInlineAsmOperand :: Symbol { ref symbol } => generated_asm. push_str ( symbol) ,
577+ CInlineAsmOperand :: Symbol { ref symbol } => {
578+ if binary_format == BinaryFormat :: Macho {
579+ generated_asm. push ( '_' ) ;
580+ }
581+
582+ generated_asm. push_str ( symbol) ;
583+ }
578584 }
579585 }
580586 }
You can’t perform that action at this time.
0 commit comments