|
3 | 3 |
|
4 | 4 | use std::path::PathBuf; |
5 | 5 |
|
| 6 | +use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; |
6 | 7 | use rustc_codegen_ssa::back::linker::LinkerInfo; |
7 | 8 | use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind}; |
8 | 9 | use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; |
@@ -41,7 +42,7 @@ fn emit_module( |
41 | 42 |
|
42 | 43 | unwind_context.emit(&mut product); |
43 | 44 |
|
44 | | - let tmp_file = tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(&name)); |
| 45 | + let tmp_file = tcx.output_filenames(()).temp_path(OutputType::Object, Some(&name)); |
45 | 46 | let obj = product.object.write().unwrap(); |
46 | 47 | if let Err(err) = std::fs::write(&tmp_file, obj) { |
47 | 48 | tcx.sess.fatal(&format!("error writing object file: {}", err)); |
@@ -73,7 +74,7 @@ fn reuse_workproduct_for_cgu( |
73 | 74 | let work_product = cgu.work_product(tcx); |
74 | 75 | if let Some(saved_file) = &work_product.saved_file { |
75 | 76 | let obj_out = tcx |
76 | | - .output_filenames(LOCAL_CRATE) |
| 77 | + .output_filenames(()) |
77 | 78 | .temp_path(OutputType::Object, Some(&cgu.name().as_str())); |
78 | 79 | object = Some(obj_out.clone()); |
79 | 80 | let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file); |
@@ -125,9 +126,19 @@ fn module_codegen( |
125 | 126 | MonoItem::Static(def_id) => crate::constant::codegen_static(tcx, &mut module, def_id), |
126 | 127 | MonoItem::GlobalAsm(item_id) => { |
127 | 128 | let item = cx.tcx.hir().item(item_id); |
128 | | - if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind { |
129 | | - cx.global_asm.push_str(&*asm.as_str()); |
130 | | - cx.global_asm.push_str("\n\n"); |
| 129 | + if let rustc_hir::ItemKind::GlobalAsm(asm) = item.kind { |
| 130 | + if !asm.options.contains(InlineAsmOptions::ATT_SYNTAX) { |
| 131 | + cx.global_asm.push_str("\n.intel_syntax noprefix\n"); |
| 132 | + } else { |
| 133 | + cx.global_asm.push_str("\n.att_syntax\n"); |
| 134 | + } |
| 135 | + for piece in asm.template { |
| 136 | + match *piece { |
| 137 | + InlineAsmTemplatePiece::String(ref s) => cx.global_asm.push_str(s), |
| 138 | + InlineAsmTemplatePiece::Placeholder { .. } => todo!(), |
| 139 | + } |
| 140 | + } |
| 141 | + cx.global_asm.push_str("\n.att_syntax\n\n"); |
131 | 142 | } else { |
132 | 143 | bug!("Expected GlobalAsm found {:?}", item); |
133 | 144 | } |
@@ -185,7 +196,7 @@ pub(crate) fn run_aot( |
185 | 196 | let mut work_products = FxHashMap::default(); |
186 | 197 |
|
187 | 198 | let cgus = if tcx.sess.opts.output_types.should_codegen() { |
188 | | - tcx.collect_and_partition_mono_items(LOCAL_CRATE).1 |
| 199 | + tcx.collect_and_partition_mono_items(()).1 |
189 | 200 | } else { |
190 | 201 | // If only `--emit metadata` is used, we shouldn't perform any codegen. |
191 | 202 | // Also `tcx.collect_and_partition_mono_items` may panic in that case. |
@@ -271,7 +282,7 @@ pub(crate) fn run_aot( |
271 | 282 | .to_string(); |
272 | 283 |
|
273 | 284 | let tmp_file = tcx |
274 | | - .output_filenames(LOCAL_CRATE) |
| 285 | + .output_filenames(()) |
275 | 286 | .temp_path(OutputType::Metadata, Some(&metadata_cgu_name)); |
276 | 287 |
|
277 | 288 | let obj = crate::backend::with_object(tcx.sess, &metadata_cgu_name, |object| { |
@@ -304,7 +315,7 @@ pub(crate) fn run_aot( |
304 | 315 | metadata_module, |
305 | 316 | metadata, |
306 | 317 | windows_subsystem, |
307 | | - linker_info: LinkerInfo::new(tcx), |
| 318 | + linker_info: LinkerInfo::new(tcx, crate::target_triple(tcx.sess).to_string()), |
308 | 319 | crate_info: CrateInfo::new(tcx), |
309 | 320 | }, |
310 | 321 | work_products, |
@@ -348,7 +359,7 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) { |
348 | 359 | .join("\n"); |
349 | 360 |
|
350 | 361 | let output_object_file = |
351 | | - tcx.output_filenames(LOCAL_CRATE).temp_path(OutputType::Object, Some(cgu_name)); |
| 362 | + tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu_name)); |
352 | 363 |
|
353 | 364 | // Assemble `global_asm` |
354 | 365 | let global_asm_object_file = add_file_stem_postfix(output_object_file.clone(), ".asm"); |
|
0 commit comments