Skip to content

Link errors on macOS when a dependency which also uses pyo3 has a cdylib target #1080

Open
@konstin

Description

@konstin

Bug Description

I have two crates, cell and mitochondria, where cell depends on mitochondria. Each has pyo3 bindings on its own. If mitochondria has cdylib as crate-type, trying to maturin build on mac os will fail with pyo3 linker errors, with only the default crate-type rlib or on ubuntu and windows it works. I've made a minimal example with github actions at https://github.com/konstin/maturin-mac-os-dep-repro.

The error looks like it's missing the link-arg=-undefined/link-arg=dynamic_lookup, even though they are present and work for the top level crate.

[package]
name = "mitochondria"
version = "0.1.0"
edition = "2021"

[lib]
# REMOVE cdyblib FROM THE LINE BELOW TO MAKE THIS PASS
crate-type = ["cdylib", "rlib"]

[dependencies]
pyo3 = { version = "0.17.1", features = ["extension-module"] }
[package]
name = "cell"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
pyo3 = { version = "0.17.1", features = ["extension-module"] }
mitochondria = { path = "mitochondria" }

Your Python version (python -V)

3.8

Your pip version (pip -V)

22.2.2

What bindings you're using

pyo3

Does cargo build work?

n/a, this is a linker error

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

  • Yes

Steps to Reproduce

See minimal example at https://github.com/konstin/maturin-mac-os-dep-repro

Ubuntu, passing: https://github.com/konstin/maturin-mac-os-dep-repro/runs/8144523404?check_suite_focus=true
Mac os, failing: https://github.com/konstin/maturin-mac-os-dep-repro/runs/8144523536?check_suite_focus=true

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