22//! standalone executable.
33
44use std:: io:: Write ;
5- use std:: path:: PathBuf ;
5+ use std:: path:: { Path , PathBuf } ;
66use std:: process:: { Command , Stdio } ;
7- use std:: sync:: Arc ;
87
98use rustc_ast:: { InlineAsmOptions , InlineAsmTemplatePiece } ;
109use rustc_codegen_ssa:: traits:: { AsmCodegenMethods , GlobalAsmOperandRef } ;
1110use rustc_middle:: ty:: TyCtxt ;
1211use rustc_middle:: ty:: layout:: {
1312 FnAbiError , FnAbiOfHelpers , FnAbiRequest , HasTyCtxt , HasTypingEnv , LayoutError , LayoutOfHelpers ,
1413} ;
15- use rustc_session:: config :: OutputFilenames ;
14+ use rustc_session:: Session ;
1615use rustc_target:: asm:: InlineAsmArch ;
1716
1817use crate :: prelude:: * ;
@@ -163,32 +162,28 @@ fn codegen_global_asm_inner<'tcx>(
163162pub ( crate ) struct GlobalAsmConfig {
164163 assembler : PathBuf ,
165164 target : String ,
166- pub ( crate ) output_filenames : Arc < OutputFilenames > ,
167165}
168166
169167impl GlobalAsmConfig {
170- pub ( crate ) fn new ( tcx : TyCtxt < ' _ > ) -> Self {
168+ pub ( crate ) fn new ( sess : & Session ) -> Self {
171169 GlobalAsmConfig {
172- assembler : crate :: toolchain:: get_toolchain_binary ( tcx . sess , "as" ) ,
173- target : match & tcx . sess . opts . target_triple {
170+ assembler : crate :: toolchain:: get_toolchain_binary ( sess, "as" ) ,
171+ target : match & sess. opts . target_triple {
174172 rustc_target:: spec:: TargetTuple :: TargetTuple ( triple) => triple. clone ( ) ,
175173 rustc_target:: spec:: TargetTuple :: TargetJson { path_for_rustdoc, .. } => {
176174 path_for_rustdoc. to_str ( ) . unwrap ( ) . to_owned ( )
177175 }
178176 } ,
179- output_filenames : tcx. output_filenames ( ( ) ) . clone ( ) ,
180177 }
181178 }
182179}
183180
184181pub ( crate ) fn compile_global_asm (
185182 config : & GlobalAsmConfig ,
186- cgu_name : & str ,
187183 global_asm : String ,
188- ) -> Result < Option < PathBuf > , String > {
189- if global_asm. is_empty ( ) {
190- return Ok ( None ) ;
191- }
184+ global_asm_object_file : & Path ,
185+ ) -> Result < ( ) , String > {
186+ assert ! ( !global_asm. is_empty( ) ) ;
192187
193188 // Remove all LLVM style comments
194189 let mut global_asm = global_asm
@@ -198,8 +193,6 @@ pub(crate) fn compile_global_asm(
198193 . join ( "\n " ) ;
199194 global_asm. push ( '\n' ) ;
200195
201- let global_asm_object_file = config. output_filenames . temp_path_ext_for_cgu ( "asm.o" , cgu_name) ;
202-
203196 // Assemble `global_asm`
204197 if option_env ! ( "CG_CLIF_FORCE_GNU_AS" ) . is_some ( ) {
205198 let mut child = Command :: new ( & config. assembler )
@@ -266,5 +259,5 @@ pub(crate) fn compile_global_asm(
266259 }
267260 }
268261
269- Ok ( Some ( global_asm_object_file ) )
262+ Ok ( ( ) )
270263}
0 commit comments