Skip to content

Commit 0db6050

Browse files
committed
Use CallConv::triple_default instead of hard coding SystemV
Fixes rust-lang#718
1 parent 44792f1 commit 0db6050

File tree

7 files changed

+18
-14
lines changed

7 files changed

+18
-14
lines changed

src/abi/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ fn clif_sig_from_fn_sig<'tcx>(
2626
abi => abi,
2727
};
2828
let (call_conv, inputs, output): (CallConv, Vec<Ty>, Ty) = match abi {
29-
Abi::Rust => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()),
30-
Abi::C => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()),
29+
Abi::Rust => (crate::default_call_conv(tcx.sess), sig.inputs().to_vec(), sig.output()),
30+
Abi::C => (crate::default_call_conv(tcx.sess), sig.inputs().to_vec(), sig.output()),
3131
Abi::RustCall => {
3232
assert_eq!(sig.inputs().len(), 2);
3333
let extra_args = match sig.inputs().last().unwrap().kind {
@@ -36,10 +36,10 @@ fn clif_sig_from_fn_sig<'tcx>(
3636
};
3737
let mut inputs: Vec<Ty> = vec![sig.inputs()[0]];
3838
inputs.extend(extra_args.types());
39-
(CallConv::SystemV, inputs, sig.output())
39+
(crate::default_call_conv(tcx.sess), inputs, sig.output())
4040
}
4141
Abi::System => unreachable!(),
42-
Abi::RustIntrinsic => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()),
42+
Abi::RustIntrinsic => (crate::default_call_conv(tcx.sess), sig.inputs().to_vec(), sig.output()),
4343
_ => unimplemented!("unsupported abi {:?}", sig.abi),
4444
};
4545

@@ -142,7 +142,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> {
142142
let sig = Signature {
143143
params: input_tys.iter().cloned().map(AbiParam::new).collect(),
144144
returns: output_tys.iter().cloned().map(AbiParam::new).collect(),
145-
call_conv: CallConv::SystemV,
145+
call_conv: crate::default_call_conv(self.tcx.sess),
146146
};
147147
let func_id = self
148148
.module

src/allocator.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ pub fn codegen(tcx: TyCtxt<'_>, module: &mut Module<impl Backend + 'static>) ->
2121
if any_dynamic_crate {
2222
false
2323
} else if let Some(kind) = *tcx.sess.allocator_kind.get() {
24-
codegen_inner(module, kind);
24+
codegen_inner(tcx.sess, module, kind);
2525
true
2626
} else {
2727
false
2828
}
2929
}
3030

31-
pub fn codegen_inner(module: &mut Module<impl Backend + 'static>, kind: AllocatorKind) {
31+
pub fn codegen_inner(sess: &Session, module: &mut Module<impl Backend + 'static>, kind: AllocatorKind) {
3232
let usize_ty = module.target_config().pointer_type();
3333

3434
for method in ALLOCATOR_METHODS {
@@ -55,7 +55,7 @@ pub fn codegen_inner(module: &mut Module<impl Backend + 'static>, kind: Allocato
5555
};
5656

5757
let sig = Signature {
58-
call_conv: CallConv::SystemV,
58+
call_conv: crate::default_call_conv(sess),
5959
params: arg_tys.iter().cloned().map(AbiParam::new).collect(),
6060
returns: output.into_iter().map(AbiParam::new).collect(),
6161
};

src/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn run_jit(tcx: TyCtxt<'_>, log: &mut Option<File>) -> ! {
6161
returns: vec![AbiParam::new(
6262
jit_module.target_config().pointer_type(), /*isize*/
6363
)],
64-
call_conv: CallConv::SystemV,
64+
call_conv: crate::default_call_conv(tcx.sess),
6565
};
6666
let main_func_id = jit_module
6767
.declare_function("main", Linkage::Import, &sig)

src/intrinsics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ pub fn codegen_intrinsic_call<'tcx>(
10631063
try, (v f, v data, v _local_ptr) {
10641064
// FIXME once unwinding is supported, change this to actually catch panics
10651065
let f_sig = fx.bcx.func.import_signature(Signature {
1066-
call_conv: cranelift::codegen::isa::CallConv::SystemV,
1066+
call_conv: crate::default_call_conv(fx.tcx.sess),
10671067
params: vec![AbiParam::new(fx.bcx.func.dfg.value_type(data))],
10681068
returns: vec![],
10691069
});

src/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
225225

226226
sess.profiler(|p| p.start_activity("link_crate"));
227227
rustc::util::common::time(sess, "linking", || {
228-
let target_cpu = target_triple(sess).to_string();
228+
let target_cpu = crate::target_triple(sess).to_string();
229229
link_binary::<crate::archive::ArArchiveBuilder<'_>>(
230230
sess,
231231
&codegen_results,
@@ -244,6 +244,10 @@ fn target_triple(sess: &Session) -> target_lexicon::Triple {
244244
sess.target.target.llvm_target.parse().unwrap()
245245
}
246246

247+
fn default_call_conv(sess: &Session) -> CallConv {
248+
CallConv::triple_default(&target_triple(sess))
249+
}
250+
247251
fn build_isa(sess: &Session, enable_pic: bool) -> Box<dyn isa::TargetIsa + 'static> {
248252
let mut flags_builder = settings::builder();
249253
if enable_pic {
@@ -279,7 +283,7 @@ fn build_isa(sess: &Session, enable_pic: bool) -> Box<dyn isa::TargetIsa + 'stat
279283
}
280284
}*/
281285

282-
let target_triple = target_triple(sess);
286+
let target_triple = crate::target_triple(sess);
283287
let flags = settings::Flags::new(flags_builder);
284288
cranelift::codegen::isa::lookup(target_triple)
285289
.unwrap()

src/main_shim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module<impl Back
4141
returns: vec![AbiParam::new(
4242
m.target_config().pointer_type(), /*isize*/
4343
)],
44-
call_conv: CallConv::SystemV,
44+
call_conv: crate::default_call_conv(tcx.sess),
4545
};
4646

4747
let cmain_func_id = m

src/trap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms
77
"puts",
88
Linkage::Import,
99
&Signature {
10-
call_conv: CallConv::SystemV,
10+
call_conv: crate::default_call_conv(fx.tcx.sess),
1111
params: vec![AbiParam::new(pointer_ty(fx.tcx))],
1212
returns: vec![],
1313
},

0 commit comments

Comments
 (0)