about summary refs log tree commit diff
path: root/compiler/rustc_codegen_cranelift/src/backend.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-05-01 09:59:54 +0000
committerbors <bors@rust-lang.org>2021-05-01 09:59:54 +0000
commitfed59d669c5ca3c0e9c39dcb1f6510b5876ede64 (patch)
tree71be961123cb9718153613d9a53c138f2a409075 /compiler/rustc_codegen_cranelift/src/backend.rs
parent1c2c6b670023efda0fea8e1837f9542d3ed12f5d (diff)
parent6af045f00a3bf7d34a2dcd84d1f89e2b5fef0f36 (diff)
downloadrust-fed59d669c5ca3c0e9c39dcb1f6510b5876ede64.tar.gz
rust-fed59d669c5ca3c0e9c39dcb1f6510b5876ede64.zip
Auto merge of #84786 - JohnTitor:rollup-j5omx6f, r=JohnTitor
Rollup of 8 pull requests

Successful merges:

 - #84601 (rustdoc: Only store locations in Cache::extern_locations and calculate the other info on-demand)
 - #84704 (platform-support.md: Update for consistency with Target Tier Policy)
 - #84724 (Replace llvm::sys::fs::F_None with llvm::sys::fs::OF_None)
 - #84740 (Reset the docs' copy path button after 1 second)
 - #84749 (Sync `rustc_codegen_cranelift`)
 - #84756 (Add a ToC to the Target Tier Policy documentation)
 - #84765 (Update cargo)
 - #84774 (Fix misspelling)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/backend.rs')
-rw-r--r--compiler/rustc_codegen_cranelift/src/backend.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/backend.rs b/compiler/rustc_codegen_cranelift/src/backend.rs
index eb7927fc4ad..05c06bac27d 100644
--- a/compiler/rustc_codegen_cranelift/src/backend.rs
+++ b/compiler/rustc_codegen_cranelift/src/backend.rs
@@ -5,23 +5,23 @@ use std::convert::{TryFrom, TryInto};
 use rustc_data_structures::fx::FxHashMap;
 use rustc_session::Session;
 
+use cranelift_codegen::isa::TargetIsa;
 use cranelift_module::FuncId;
+use cranelift_object::{ObjectBuilder, ObjectModule, ObjectProduct};
 
 use object::write::*;
 use object::{RelocationEncoding, SectionKind, SymbolFlags};
 
-use cranelift_object::{ObjectBuilder, ObjectModule, ObjectProduct};
-
 use gimli::SectionId;
 
 use crate::debuginfo::{DebugReloc, DebugRelocName};
 
 pub(crate) trait WriteMetadata {
-    fn add_rustc_section(&mut self, symbol_name: String, data: Vec<u8>, is_like_osx: bool);
+    fn add_rustc_section(&mut self, symbol_name: String, data: Vec<u8>);
 }
 
 impl WriteMetadata for object::write::Object {
-    fn add_rustc_section(&mut self, symbol_name: String, data: Vec<u8>, _is_like_osx: bool) {
+    fn add_rustc_section(&mut self, symbol_name: String, data: Vec<u8>) {
         let segment = self.segment_name(object::write::StandardSegment::Data).to_vec();
         let section_id = self.add_section(segment, b".rustc".to_vec(), object::SectionKind::Data);
         let offset = self.append_section_data(section_id, &data, 1);
@@ -113,7 +113,7 @@ impl WriteDebugInfo for ObjectProduct {
 }
 
 pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object)) -> Vec<u8> {
-    let triple = crate::build_isa(sess).triple().clone();
+    let triple = crate::target_triple(sess);
 
     let binary_format = match triple.binary_format {
         target_lexicon::BinaryFormat::Elf => object::BinaryFormat::Elf,
@@ -141,13 +141,9 @@ pub(crate) fn with_object(sess: &Session, name: &str, f: impl FnOnce(&mut Object
     metadata_object.write().unwrap()
 }
 
-pub(crate) fn make_module(sess: &Session, name: String) -> ObjectModule {
-    let mut builder = ObjectBuilder::new(
-        crate::build_isa(sess),
-        name + ".o",
-        cranelift_module::default_libcall_names(),
-    )
-    .unwrap();
+pub(crate) fn make_module(sess: &Session, isa: Box<dyn TargetIsa>, name: String) -> ObjectModule {
+    let mut builder =
+        ObjectBuilder::new(isa, name + ".o", cranelift_module::default_libcall_names()).unwrap();
     // Unlike cg_llvm, cg_clif defaults to disabling -Zfunction-sections. For cg_llvm binary size
     // is important, while cg_clif cares more about compilation times. Enabling -Zfunction-sections
     // can easily double the amount of time necessary to perform linking.