Skip to content

rustc_codegen_llvm: use opaque LLVM structs for extern type. #58271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/librustc_codegen_llvm/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ fn uncached_llvm_type<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
match name {
None => {
let (llfields, packed) = struct_llfields(cx, layout);
cx.type_struct( &llfields, packed)
cx.type_struct(&llfields, packed)
}
Some(ref name) => {
let llty = cx.type_named_struct( name);
let llty = cx.type_named_struct(name);
*defer = Some((llty, layout));
llty
}
Expand Down Expand Up @@ -298,8 +298,15 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
cx.lltypes.borrow_mut().insert((self.ty, variant_index), llty);

if let Some((llty, layout)) = defer {
let (llfields, packed) = struct_llfields(cx, layout);
cx.set_struct_body(llty, &llfields, packed)
match layout.ty.sty {
// Leave an `extern type` fully opaque (LLVM "unsized").
ty::Foreign(..) => {}

_ => {
let (llfields, packed) = struct_llfields(cx, layout);
cx.set_struct_body(llty, &llfields, packed)
}
}
}

llty
Expand Down