Skip to content

Clang 3.8.1 fails when mangling constructors and destructors #653

@rpjohnst

Description

@rpjohnst

Using Clang 3.8.1, bindgen fails an LLVM assert when given a constructor. A cursory look into the source around the assert suggests that it's somehow calling mangleCXXName rather than mangleCXXCtor, though I don't why that would happen on 3.8.1 but not 3.9.0.

I'm stuck on 3.8.1 because 3.9.0 renamed some intrinsics used by the headers I'm trying to run through bindgen. If this is one of the features that needs to be disabled for LLVM <3.9, I couldn't figure out how- I tried disabling constructors/destructors and ignoring methods, but those options don't seem to take effect early enough.

It does look like 3.9 also introduced several APIs that bindgen has been using for a while, so maybe this isn't really feasible to fix, but perhaps someone else has run into this.

Input C/C++ Header

struct Foo { Foo(); };

Bindgen Invokation

bindgen::builder()
    .header("input.h")
    .generate().unwrap()

Actual Results

The assertion at tools/clang/lib/AST/ItaniumMangle.cpp:4038 fails:

!isa<CXXConstructorDecl>(D) && !isa<CXXDestructorDecl>(D) && "Invalid mangleName() call on 'structor decl!"

This happens on (at least) 64-bit Windows and 64-bit Linux builds of Clang.

RUST_LOG=bindgen Output

There doesn't appear to be any, though I could be doing something wrong (it's just run through a normal cargo build script).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions