Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 98dae86

Browse files
committed
Update cranelift
1 parent 8598a34 commit 98dae86

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/constant.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fn trans_const_place<'a, 'tcx: 'a>(
179179

180180
fn data_id_for_alloc_id<B: Backend>(module: &mut Module<B>, alloc_id: AllocId) -> DataId {
181181
module
182-
.declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false)
182+
.declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false, None)
183183
.unwrap()
184184
}
185185

@@ -190,15 +190,16 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>(
190190
linkage: Linkage,
191191
) -> DataId {
192192
let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str();
193+
let ty = tcx.type_of(def_id);
193194
let is_mutable = if tcx.is_mutable_static(def_id) {
194195
true
195196
} else {
196-
!tcx.type_of(def_id)
197-
.is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP)
197+
!ty.is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP)
198198
};
199+
let align = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().align.pref.bytes();
199200

200201
let data_id = module
201-
.declare_data(&*symbol_name, linkage, is_mutable)
202+
.declare_data(&*symbol_name, linkage, is_mutable, Some(align.try_into().unwrap()))
202203
.unwrap();
203204

204205
if linkage == Linkage::Preemptible {

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ mod vtable;
5757
mod prelude {
5858
pub use std::any::Any;
5959
pub use std::collections::{HashMap, HashSet};
60+
pub use std::convert::TryInto;
6061

6162
pub use syntax::ast::{FloatTy, IntTy, UintTy};
6263
pub use syntax::source_map::{Pos, Span, DUMMY_SP};
@@ -213,7 +214,8 @@ impl CodegenBackend for CraneliftCodegenBackend {
213214
};
214215

215216
if std::env::var("SHOULD_RUN").is_ok() {
216-
let mut jit_module: Module<SimpleJITBackend> = Module::new(SimpleJITBuilder::new());
217+
let mut jit_module: Module<SimpleJITBackend> =
218+
Module::new(SimpleJITBuilder::new(cranelift_module::default_libcall_names()));
217219
assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type());
218220

219221
let sig = Signature {
@@ -263,7 +265,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
263265
build_isa(tcx.sess),
264266
name + ".o",
265267
FaerieTrapCollection::Disabled,
266-
FaerieBuilder::default_libcall_names(),
268+
cranelift_module::default_libcall_names(),
267269
)
268270
.unwrap(),
269271
);

src/trap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms
1212
let msg_bytes = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg).into_bytes().into_boxed_slice();
1313
let mut data_ctx = DataContext::new();
1414
data_ctx.define(msg_bytes);
15-
let msg_id = fx.module.declare_data(&(symbol_name.as_str().to_string() + msg), Linkage::Local, false).unwrap();
15+
let msg_id = fx.module.declare_data(&(symbol_name.as_str().to_string() + msg), Linkage::Local, false, None).unwrap();
1616

1717
// Ignore DuplicateDefinition error, as the data will be the same
1818
let _ = fx.module.define_data(msg_id, &data_ctx);

src/vtable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ fn build_vtable<'a, 'tcx: 'a>(
136136
&format!("vtable.{:?}.for.{:?}", trait_ref, ty),
137137
Linkage::Local,
138138
false,
139+
Some(fx.tcx.data_layout.pointer_align.pref.bytes().try_into().unwrap())
139140
)
140141
.unwrap();
141142

0 commit comments

Comments
 (0)