Skip to content

"extern type" should use opaque type in LLVM #59095

Closed
@RalfJung

Description

@RalfJung

Currently, in a situation like

extern {
    type Foo;
    static mut BAR: Foo;
}

we generate a zero-sized struct as the LLVM type for Foo. LLVM might use this to assume that BAR has size 0, which would be fatal. And anyway it seems prudent for extern types, that should match C's declared-but-not-defined types, to match what Clang does for the corresponding C types -- which is to use opaque.

See #58271 for an attempt to fix this, which ran into LLVM assertion failures.

Cc @eddyb

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-FFIArea: Foreign function interface (FFI)A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generationF-extern_types`#![feature(extern_types)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions