Skip to content

Commit b4f83c6

Browse files
committed
Fix error
1 parent d8b5a3e commit b4f83c6

File tree

3 files changed

+6
-37
lines changed

3 files changed

+6
-37
lines changed

patches/0024-core-Disable-portable-simd-test.patch

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
241241
let value =
242242
if layout.size == Size::ZERO {
243243
let value = self.const_usize(alloc.inner().align.bytes());
244-
self.context.new_cast(None, value, ty)
244+
self.const_bitcast(value, ty)
245245
}
246246
else {
247247
let init = const_alloc_to_gcc(self, alloc);

src/consts.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ pub fn codegen_static_initializer<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, def_id
341341

342342
fn check_and_apply_linkage<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, attrs: &CodegenFnAttrs, ty: Ty<'tcx>, sym: &str) -> LValue<'gcc> {
343343
let is_tls = attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
344-
let llty = cx.layout_of(ty).gcc_type(cx);
344+
let gcc_type = cx.layout_of(ty).gcc_type(cx);
345345
if let Some(linkage) = attrs.import_linkage {
346346
// Declare a symbol `foo` with the desired linkage.
347347
let global1 = cx.declare_global_with_linkage(&sym, cx.type_i8(), base::global_linkage_to_gcc(linkage));
@@ -354,9 +354,10 @@ fn check_and_apply_linkage<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, attrs: &Codeg
354354
// zero.
355355
let mut real_name = "_rust_extern_with_linkage_".to_string();
356356
real_name.push_str(&sym);
357-
let global2 = cx.define_global(&real_name, llty, is_tls, attrs.link_section);
357+
let global2 = cx.define_global(&real_name, gcc_type, is_tls, attrs.link_section);
358358
// TODO(antoyo): set linkage.
359-
global2.global_set_initializer_rvalue(global1.get_address(None));
359+
let value = cx.const_ptrcast(global1.get_address(None), gcc_type);
360+
global2.global_set_initializer_rvalue(value);
360361
// TODO(antoyo): use global_set_initializer() when it will work.
361362
global2
362363
}
@@ -370,6 +371,6 @@ fn check_and_apply_linkage<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, attrs: &Codeg
370371
// don't do this then linker errors can be generated where the linker
371372
// complains that one object files has a thread local version of the
372373
// symbol and another one doesn't.
373-
cx.declare_global(&sym, llty, GlobalKind::Imported, is_tls, attrs.link_section)
374+
cx.declare_global(&sym, gcc_type, GlobalKind::Imported, is_tls, attrs.link_section)
374375
}
375376
}

0 commit comments

Comments
 (0)