pyo3: Undefined symbols for architecture arm64
🐛 Bug Reports
When reporting a bug, please provide the following information. If this is not a bug report you can just discard this template.
🌍 Environment
- Your operating system and version: MacOS 11.5 Big Sur, on M1 / arm64
- Your python version: 3.9.5
- How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?: Pyenv, with virtualenv. Also tested with system python with virtualenv.
- Your Rust version (
rustc --version): rustc 1.54.0 (a178d0322 2021-07-26) - Your PyO3 version: 0.14.2
- Have you tried using latest PyO3 main (replace
version = "0.x.y"withgit = "https://github.com/PyO3/pyo3")?: Yes
💥 Reproducing
$ cat Cargo.toml
[package]
name = "foo"
version = "0.1.0"
edition = "2018"
[lib]
name = "foo"
crate-type = ["cdylib"]
[dependencies.pyo3]
version = "0.14.2"
features = ["extension-module"]
$ cat src/lib.rs
use pyo3::prelude::*;
#[pyfunction]
fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
Ok((a + b).to_string())
}
#[pymodule]
fn foo(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test() {
assert_ne!(sum_as_string(10, 20).unwrap(), "29");
assert_eq!(sum_as_string(10, 20).unwrap(), "30");
}
}
$ ./.venv/bin/python -m pip install --upgrade maturin
Collecting maturin
Using cached maturin-0.11.2-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (10.5 MB)
Collecting toml~=0.10.2
Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Installing collected packages: toml, maturin
Successfully installed maturin-0.11.2 toml-0.10.2
$ maturin develop
🔗 Found pyo3 bindings
🐍 Found CPython 3.9 at python
Compiling proc-macro2 v1.0.28
Compiling unicode-xid v0.2.2
Compiling proc-macro-hack v0.5.19
Compiling syn v1.0.74
Compiling pyo3-build-config v0.14.2 (https://github.com/PyO3/pyo3#336e87ec)
Compiling once_cell v1.8.0
Compiling libc v0.2.99
Compiling unindent v0.1.7
Compiling quote v1.0.9
Compiling parking_lot_core v0.8.3
Compiling parking_lot v0.11.1
Compiling paste-impl v0.1.18
Compiling pyo3 v0.14.2 (https://github.com/PyO3/pyo3#336e87ec)
Compiling paste v0.1.18
Compiling pyo3-macros-backend v0.14.2 (https://github.com/PyO3/pyo3#336e87ec)
Compiling indoc-impl v0.3.6
Compiling indoc v0.3.6
Compiling pyo3-macros v0.14.2 (https://github.com/PyO3/pyo3#336e87ec)
Compiling foo v0.1.0 (/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo)
Finished dev [unoptimized + debuginfo] target(s) in 6.09s
$ cargo test
Compiling foo v0.1.0 (/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo)
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-arch" "arm64" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.110fvvgslxwl7xjc.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.12kh3itm9hwj9eya.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.16g57alsqnv4g7f.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.1a0ghimskmekwiuk.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.1av1bln3bhfp9nj.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.1f7ufrshnyieunmq.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.1grj2h43vo039nxn.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.1w6b9uzfz2s5unib.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.23ga6qr0715pwz5y.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.24e8nkkcbbxnt787.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2a30e9rsdwwu0myc.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2bfqaxllo29w3ifh.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2crziipwfs2kz1rl.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2ehls50ircwkdmom.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2f1e1rxz18gsu2mj.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2fdsczpl1dm1fip.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2g4fb0qea2p4q6xm.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2guxm18uiabqkc4g.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2jufnvyjxohkzt7x.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2knf917igqi0yh23.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2p5zghtzgwcs84b3.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2ryebkgzo7xg8qnt.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2w9t2gyroz08k6r5.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2zqka4hc0y9fowwt.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2zxc1obih7i5hr7t.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.2zygjmkbd28bfn6s.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.31ff4xyicc3wnhmg.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.32mlaq0jdx1jm6es.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.386vuxnbh48s9wou.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.3cd74yt2oylhtzgz.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.3exvfe10ewcn52er.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.3g5mqpn1qg0wh1a9.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.3h0owt6q12tqs9k1.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.3lmvouff0a9ask7g.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.3m044sb2289k1a45.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.3nlmoppukou4iz9o.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.3sp1r43kboysk609.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.3z1hnn9k793ut1vv.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.404rd2jigivih456.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.41g3d6jr8g5e13dg.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.44bcgq52s2fm83bo.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.46y4g6gr7pgrmj5p.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.4a8upifjlrchwi95.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.4ibyiowjhkywlxz5.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.4kb8d8qea0l2v9xb.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.4u279idye23i71pz.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.4vdhqlwluf10xra6.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.4vw02eizd1tr7ojw.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.4wsoqwueg83w4bj4.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.4xwdfbwtcu6drnpn.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.4zb71mjndf679w95.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.4zebmmyhpove6ig9.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.50i6cvni8o6e604x.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.50m5yqhkl1tj8tt7.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.51bwrx5e8skq6vdz.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.53gw0dkzu34phl59.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.54uz16ierizblqjb.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.58htorl2ddld3vy6.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.5efmic2dvfz0pyna.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.7vrbjuouu484zpk.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.d8kk98i9kjuql8j.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.gc7opmckjdvlw86.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.io5k9a5m56skmi7.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.m0svsb223gbvcdi.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.ov0hczhn18vqy4g.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.pp1aw1mhc4kqgka.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.q1smzop47y4w3d2.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.snh43turx8z4g5z.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.vfssu1qsbtfwmz3.rcgu.o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879.44z81xxn3zvsfpbf.rcgu.o" "-L" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps" "-L" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libtest-06ff11d645105e2b.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libterm-f05ecaeca66814e6.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libgetopts-6ad0d034fc8e15c7.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libunicode_width-c4beacdc35405cb8.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_std-fc0f4647def297a8.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/libpyo3-194c7c6b45ae4486.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/libparking_lot-3d6f176468cb3e55.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/libparking_lot_core-1a66328f5320fcf8.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/libsmallvec-b1d3333bf059e064.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/liblock_api-09ae7dbe1cd82c80.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/libscopeguard-62e7a6d9289eec1f.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/libinstant-4e05ab198a32da16.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/libcfg_if-254a4227ea494762.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/liblibc-2d65d84e2d4e9c71.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/libunindent-dda6001dcdbb754c.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/libpaste-61320a4b949429d0.rlib" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/libindoc-758ee8d2665c486a.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd-000cdec9267bfd7b.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-2669f3cbce8358f4.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libobject-86461a1c60728ccb.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-f17574752cb5ddba.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libgimli-3bb606c936cc0d28.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-8139a4b0cda20184.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-ea0823eca3e9abf9.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-4f19e1259f6028e7.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-435daca85b8e10b5.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libunwind-d73085abefd284c6.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-e6a09ca0044b34e5.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liblibc-e07333f48f53c71e.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-2a49b0d9fbc7a459.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-b66dda66aafe36c9.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-34d0b58da984bf31.rlib" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-01275baa20724171.rlib" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/Users/n8henrie/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879" "-Wl,-dead_strip" "-nodefaultlibs"
= note: Undefined symbols for architecture arm64:
"_PyExc_TypeError", referenced from:
_$LT$pyo3..exceptions..PyTypeError$u20$as$u20$pyo3..type_object..PyTypeInfo$GT$::type_object_raw::h3351d28f1f012e04 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.1.rcgu.o)
"_PyExc_BaseException", referenced from:
_$LT$pyo3..exceptions..PyBaseException$u20$as$u20$pyo3..type_object..PyTypeInfo$GT$::type_object_raw::h3e7fd002a901032a in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.1.rcgu.o)
"_PyBytes_AsString", referenced from:
pyo3::types::bytes::PyBytes::as_bytes::hcb83c311a32d8877 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.15.rcgu.o)
"_PyErr_Print", referenced from:
pyo3::err::panic_after_error::h86153d46e74bf037 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.15.rcgu.o)
"_PyBytes_Size", referenced from:
pyo3::types::bytes::PyBytes::as_bytes::hcb83c311a32d8877 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.15.rcgu.o)
"_PyErr_NormalizeException", referenced from:
pyo3::err::PyErr::normalized::h9588758d1ccab3f5 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.15.rcgu.o)
"_PyErr_PrintEx", referenced from:
pyo3::err::PyErr::print::h797d38ccce2cbbaf in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.15.rcgu.o)
"_PyErr_NewException", referenced from:
pyo3::err::PyErr::new_type::hfb51b941f04ed644 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.15.rcgu.o)
"_PyErr_Restore", referenced from:
pyo3::err::PyErr::restore::h1dbbf8b88416361d in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.15.rcgu.o)
"_PyGILState_Release", referenced from:
_$LT$pyo3..gil..GILGuard$u20$as$u20$core..ops..drop..Drop$GT$::drop::hf2f8a6f21e2d4dfe in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.10.rcgu.o)
"_PyErr_Fetch", referenced from:
pyo3::err::PyErr::fetch::h48d0241c5aeeaf12 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.15.rcgu.o)
"_PyUnicode_AsUTF8AndSize", referenced from:
pyo3::types::string::PyString::to_str::h7219ef1704e18050 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.2.rcgu.o)
"_PyGILState_Ensure", referenced from:
pyo3::gil::GILGuard::acquire_unchecked::hb63c5f585f222b6d in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.10.rcgu.o)
"_PyEval_ThreadsInitialized", referenced from:
pyo3::gil::GILGuard::acquire::_$u7b$$u7b$closure$u7d$$u7d$::hb0a84271271719f2 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.10.rcgu.o)
"_PyUnicode_AsEncodedString", referenced from:
pyo3::types::string::PyString::to_string_lossy::hdc219ee0b91d0d09 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.2.rcgu.o)
"_Py_IsInitialized", referenced from:
pyo3::gil::GILGuard::acquire::_$u7b$$u7b$closure$u7d$$u7d$::hb0a84271271719f2 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.10.rcgu.o)
"_PyExc_SystemError", referenced from:
_$LT$pyo3..exceptions..PySystemError$u20$as$u20$pyo3..type_object..PyTypeInfo$GT$::type_object_raw::h788c3eab76189041 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.1.rcgu.o)
"_PyObject_Repr", referenced from:
pyo3::types::any::PyAny::repr::hb17f942fc5a28d64 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.11.rcgu.o)
"__Py_Dealloc", referenced from:
pyo3::ffi::object::Py_DECREF::h99cb8d1a6d9fe0a4 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.5.rcgu.o)
"_PyUnicode_FromStringAndSize", referenced from:
pyo3::types::string::PyString::new::h875d8b9d6e9e8e21 in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.2.rcgu.o)
"_PyObject_GetAttr", referenced from:
pyo3::types::any::PyAny::getattr::_$u7b$$u7b$closure$u7d$$u7d$::h26dc56d4a757defc in libpyo3-194c7c6b45ae4486.rlib(pyo3-194c7c6b45ae4486.pyo3.960x274q-cgu.11.rcgu.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: aborting due to previous error
error: could not compile `foo`
To learn more, run the command again with --verbose.
Things I’ve tried with / without in various combinations:
[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
This results in a different error:
dyld: Symbol not found: _PyExc_BaseException
Referenced from: /private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879
Expected in: flat namespace
in /private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879
error: test failed, to rerun pass '--lib'
Caused by:
process didn't exit successfully: `/private/var/folders/kb/tw_lp_xd2_bbv0hqk4m0bvt80000gn/T/tmp.uLGa46f6aT/foo/target/debug/deps/foo-bf9e8350fad87879` (signal: 6, SIGABRT: process abort signal)
PYO3_PYTHON=/usr/bin/python3 cargo testno changePYO3_PYTHON=/opt/homebrew/bin/python3 cargo testno change- PYO3_PYTHON=/usr/bin/python3 cargo test
PYO3_PYTHON=~/.pyenv/versions/3.9.6/bin/python cargo testno change- In or out of virtualenv no change
Also no change with:
[features]
extension-module = ["pyo3/extension-module"]
default = ["extension-module"]
I’ve tried to cargo clean before cargo test with all of these, and tried with cargo test --no-default-features as well.
Thanks for a cool library, I’m excited to start delving into it. FWIW this was building and testing fine on Windows yesterday 😃 It looks like there is some active work going on to make this easier on MacOS, so I hope this is more constructive than just adding to noise or confusion.
Further reading:
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 36 (33 by maintainers)
Right, so if I’m reading this correctly,
maturin developworks to build the library. But you are having difficulty running tests.maturinactually passes the cargo config automatically, but I suspect that the cargo config will cause problems with testing. To confirm, can you try:maturin developstill builds successfullyCargo.tomllooks like this: This is necessary so that we’re sure that pyo3’sextension-modulefeature will not be requested whencargo test --no-default-featuresis run.cargo test --no-default-featuresThis issue is present on android termux as well as macos.
sorry, my error is different, deleting this comment error happens only with maturin build, not maturin develop: “attempted to link to Python shared library but config does not contain lib_name”
[oops, I don’t see a way to delete comments, apologies]
websearchers: the workaround here is to make a custom config file as described at the bottom of https://github.com/PyO3/pyo3/issues/1800#issuecomment-902539210
this helped me: https://pyo3.rs/v0.14.2/building_and_distribution.html#macos
I hit the problem with m1 Mac when trying to publish a crate original built fine on intel-based machines.
I was able to resolve the issue by adding
--no-default-featuresflag.Good new: with some help from the pyenv team, I found a different way of approaching the framework install that seems to have things working without any extra steps (
build.rs, linker flags, etc.).The short of it is that
CONFIGURE_OPTS, which is what I was using, is working differently thanPYTHON_CONFIGURE_OPTS(https://github.com/pyenv/pyenv/issues/2081). WithPYTHON_CONFIGURE_OPTS, the--enable-frameworkbuild flag is working and seems to be properly settingprefix, so whileLIBDIRis unchanged, rust is finding everything as expected.https://github.com/pyenv/pyenv/issues/2038#issuecomment-931728391
So I think only the system MacOS installation remains an issue, and it certainly seems buggy based on the above.
Well, it fixes the
pyenvissue at least! No more need for dirty environment variable hacks, nice that abuild.rscan get placed in git (though perhaps I should figure out some dynamic way to set the homedirI guessPYENV_ROOTwill work for now).Relevant conversations:
Tried a bazillion or so cross-product combinations of:
adding to cargo config:
Just as I was about to give up, I hit gold:
Seems like that’s all that’s needed, I removed the
rpath = trueand it still works.I prefer
/Library/Developer/CommandLineTools/Library/Frameworksto the Xcode path above, and it seems to work as well, though there are a lot of differences between the two (according todiff -r).POC:
One way to make this a little easier is the same virtualenv trick as per above:
Probably a better solution is to put in
./.cargo/config:With regards to
build.rs, I thought this looked promising, but no dice:But using
nightly(for testing only, looks like it has been stabilized to be released with 0.56) and using thisbuild.rsworked a treat:Works just as well with
/Applications/Xcode.app/Contents/Developer/Library/Frameworks(instead of theCommandLineToolspath).Phew!
Once
cargo:rustc-link-argis available in stable rust, would it be reasonable for me to submit a PR to PyO3’s build.rs ~L110, with some logic looking for/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.frameworkinlib_dir, and if found, emit therustc-link-argabove? I would probably stick to theXcodepath, since that’s the one contained inLIBDIR:I usually install Python from pyenv using
PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install X.Y.Zwhich doesn’t build thePython.frameworkthing and never encountered this kind of issues.