Skip to content

Commit eb87eab

Browse files
authored
Merge pull request #577 from rust-lang/fix/lld
Use casts instead of bitcast between pointers and integers to fix issues when using the lld linker
2 parents 9e90bed + ba97c7f commit eb87eab

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

Diff for: libgccjit.version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e1857fe179e92fd565a0a55c90e8e1deba917e03
1+
45648c2edd4ecd862d9f08196d3d6c6ccba79f07

Diff for: src/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1244,13 +1244,13 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
12441244
}
12451245

12461246
fn ptrtoint(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> {
1247-
let usize_value = self.cx.const_bitcast(value, self.cx.type_isize());
1247+
let usize_value = self.cx.context.new_cast(None, value, self.cx.type_isize());
12481248
self.intcast(usize_value, dest_ty, false)
12491249
}
12501250

12511251
fn inttoptr(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> {
12521252
let usize_value = self.intcast(value, self.cx.type_isize(), false);
1253-
self.cx.const_bitcast(usize_value, dest_ty)
1253+
self.cx.context.new_cast(None, usize_value, dest_ty)
12541254
}
12551255

12561256
fn bitcast(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> {

Diff for: src/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
231231
}
232232
};
233233
let ptr_type = base_addr.get_type();
234-
let base_addr = self.const_bitcast(base_addr, self.usize_type);
234+
let base_addr = self.context.new_cast(None, base_addr, self.usize_type);
235235
let offset =
236236
self.context.new_rvalue_from_long(self.usize_type, offset.bytes() as i64);
237-
let ptr = self.const_bitcast(base_addr + offset, ptr_type);
237+
let ptr = self.context.new_cast(None, base_addr + offset, ptr_type);
238238
if !matches!(layout.primitive(), Pointer(_)) {
239239
self.const_bitcast(ptr.dereference(None).to_rvalue(), ty)
240240
} else {

Diff for: src/consts.rs

-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,6 @@ fn check_and_apply_linkage<'gcc, 'tcx>(
402402
// TODO(antoyo): set linkage.
403403
let value = cx.const_ptrcast(global1.get_address(None), gcc_type);
404404
global2.global_set_initializer_rvalue(value);
405-
// TODO(antoyo): use global_set_initializer() when it will work.
406405
global2
407406
} else {
408407
// Generate an external declaration.

0 commit comments

Comments
 (0)