Skip to content

cffi broken for Rust edition 2024 #2500

Closed
@pacman82

Description

@pacman82

Bug Description

Projects utilizing cffi bindings do not run after migrating to Rust 2024. Reason for this is the use of unsafe attributes. This changes the #[no_mangle] attribute into #[unsafe(no_mangle)].

Maturin currently depends on cbindgen 0.27 which is unable to parse unsafe attributes. An update to cbindgen 0.28 should fix this.

See #2498

Your maturin version (maturin --version)

maturin 1.7.8

Your Python version (python -V)

Python 3.13.2

Your pip version (pip -V)

pip 24.3.1

What bindings you're using

cffi

Does cargo build work?

  • Yes, it works

If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash /)?

  • Yes

Steps to Reproduce

  1. Build any project with cffi bindings utilizing at least one exported function from Python
  2. Run any python code supposed to call that function. This results in an error:

cffi library '<path to dynamic library>' has no function, constant or global variable named '<unmangled function name>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions