Compilation problem - enormous but cryptic error message

My package compiles just fine. So I've tried to expose some code as a Python module using pyo3. Now the command maturin develop correctly builds a Python library that correctly import in Python. However, now with Pyo3 macros the cargo build results in a very long and very cryptic error (below). Let me rephrase:

  • when I have #[pymethods] macros in the code, maturin develop works, cargo build doesn't
  • when I comment out #[pymethods] (and all related), cargo build compiles the very same code just fine.

I've tested that on a fresh terminal, after removing the targets folder, with and without maturin venv.

So the error message is:

(venv-maturin) MacBook-Pro:~/src.git/package $cargo build
   Compiling pyo3-build-config v0.15.2
   Compiling pyo3-macros-backend v0.15.2
   Compiling pyo3 v0.15.2
   Compiling pyo3-macros v0.15.2
   Compiling myapp_numerical v4.0.0-dev (/Users/johndoe/src.git/package/myapp_numerical)
error: linking with `cc` failed: exit status: 1
  |
  = note: "cc" "-Wl,-exported_symbols_list,/var/folders/_p/_rb7mnfj163gxb7q9hxwgv880000gn/T/rustcNZzudh/list" "-arch" "arm64" "/var/folders/_p/_rb7mnfj163gxb7q9hxwgv880000gn/T/rustcNZzudh/symbols.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.10rzo64lrn74k5ad.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.10zazphl56m09s1i.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.12ij8152s0ltjxfg.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.12tke9d9fserlh3t.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.13f974v4tw8d2h7f.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.13ufj41a2pzdllip.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.14ag24dmo1f69k5h.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.15j1735o3sv470pn.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.175csforfrcfcqqj.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.18kyrtg81bkpxnjf.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1a09n32odtyeso5o.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1a5lx16yc8xwmirj.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1a8g5bft6xdcpxwc.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1bhgec36fpi01mjz.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1bjn6c5vdly3m639.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1c8vcz1vxxqu1yyp.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1coedqzob82rwcih.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1dcxgi1ygm2vtvx7.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1e2709jxrxmkz5ne.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1f9fs7o3x8e5dzmy.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1flpbm27cgokdnsq.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1h2cumls5zpd689j.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1kvq5qr6hegu3zwd.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1lkkzykeg1ent699.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1lqmdqtz9t6o1oev.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1lz78bxtpliiivqz.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1md3fdja0zsg00t8.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1nnrvsdxxgf5kisg.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1ogpzg41367uv352.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1oj6wfoddbgadqy3.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1op1zxnx3dc2ct5c.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1pybek601rtdukq8.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1q0idiew6yb2h6ur.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1qdoibx3v9w4xi8l.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1rh90u5sxwsm93zc.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1t6b1illfev8k5qb.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1tixvzqs5ukc2oo4.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1u8msg46nn548lyw.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1uuaiqq2x5hnyw3t.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1v6zu4pf6egchjsm.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1vaxvj66f9z984y.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1wrspz9mtses74zz.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1xbqdcwl24gpi19x.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.1xyya5iilrakw5na.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2327w1on4txhqv9p.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.23vkcjzjjbzsqnge.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.24r5kd6l64hkoe5j.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.24spxgxbpk3d1vo9.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.279qwxw5ylai5iby.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.28tp3s3nem0qcgcn.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.29vjcnuudb8kv02o.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2b79w9y733duwz4f.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2djkizx9lbgdbdun.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2dmugr5xc2t55fy1.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2eb900sgqed4dgn5.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2ekfyutyknmxhxsm.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2f0aauidqxpven2h.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2htgpa06b0ap6xft.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2jus3xshh1ibilqt.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2l47aannhobki7qt.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2lmoi7pfamhnkzaw.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2m3z9kxp3xkh2b3v.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2m9k0k16329jxnq5.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2odfg103udorhacy.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2oyxv5ti54id5rq7.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2ozkdo6ks2fanuug.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2q9ot0m86hiqhoul.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2rkhvguyoagryblf.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2xj0cdit57k3a6gu.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2yunl6ttjwzdl8s6.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.2zhkrf60wadfguk3.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.30tj0f1q3zrcl6j.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.337o1pcmq55e6dbo.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.33c4l6q95eq170wu.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.34n0vx6wo726cct9.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.35j2zrb0gdm13qdv.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.369x4jatatgt85s6.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.36cxkbtdkyrw54zo.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.39ag3514swj2bjvx.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3apn8w45r6typ3wt.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3aw1p36a9kacob6l.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3e90vjrff77crwed.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3eftvqie5n21xjx7.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3f1yp2igwn37hlj9.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3fwxb1n9hhx7xisk.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3hc1t15frygp72k3.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3hgjdfj3f2a8y3r2.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3jvffm6brvnw2k11.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3np8cp4f82dqruwk.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3pnc02wo5iapmxuz.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3pr6k63exmb2vtq7.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3q191dvkpwt769mc.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3q2f4mwn1rdc5m42.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3r4qgj6rhpiuvl6m.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3sl1j4ymwt6rer.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3tfhe5q64buo29sz.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3v9db63e64ibcbam.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3vev68mth2m6imu.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3wr0sc9ahea3zf06.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3x706yh605liw1u4.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3ysp82k3eaa1yaxa.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.3zxkzh32znql9epv.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.42k7spb95t0kmm56.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.440ee8pqnqvhopho.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.44fp9d7k1rlzvfq1.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.44iaotoy5sw4qdfh.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.44nqqy7qhobdyxx2.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.44t9aaqs397eaerb.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.44upo6ef031tc2qp.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.45a0q769srscyur9.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.45w3oq2wk3n8zaan.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.46l7uffb6q4qe904.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.48mn2x9dnba7c01t.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.48wdlxcsn5ngjx1y.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4cokqlcta15xzvml.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4ex557449dtzvljc.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4fwoyw06ai4ght6w.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4hclpmycjuq5artj.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4joyh621awnwz6sf.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4mzxfahj0xmydc23.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4n0rcor80mt4gn6v.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4nvks6x4ouzcizi.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4opcy5lrhy6k0oj5.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4qptw8koqzd8n56a.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4t8h4wma5rdglad1.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4thlk53invymqbs3.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4vqowpilratcifwd.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4xqt7eumuyxni958.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.4xxv5utuxc7u4xzz.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.505je8fnfmlyhrwp.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.51qkc6e6ky137t71.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.54mlxx7ky23plea8.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.54yvdp7tiavn7h2q.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.5auinq0nt2jb3qco.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.5b5kn43rqy83eyts.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.5dbmaoro7ui0rfl0.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.5em7vuwy46pfekll.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.8x4eysnsbfml64v.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.akpdk7oi0tc7so9.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.axawb6zw57bnqrj.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.b8b0gve9wyb0lnm.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.d5mod4hig0d2f1y.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.d5ob236vent30ox.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.ev34wk3wqdjth01.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.f4y8jrrpbrg5ktd.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.f5iib2f5vuizsww.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.fv37bh6pcyhkaln.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.gjajmoip3jipplv.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.we8oddu41lcegb3.rcgu.o" "/Users/johndoe/src.git/package/target/debug/deps/myapp_numerical.jjup2ek794c3i9i.rcgu.o" "-L" "/Users/johndoe/src.git/package/target/debug/deps" "-L" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/Users/johndoe/src.git/package/target/debug/deps/libpyo3-cf9c9644d761101b.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libparking_lot-8b890adfa1caec3e.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libparking_lot_core-00fdbdb1de77c150.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libsmallvec-7a6867783f5f6d68.rlib" "/Users/johndoe/src.git/package/target/debug/deps/liblock_api-1b448108f8ed1d15.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libscopeguard-d7dce28efe117e2a.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libinstant-2a378168baba154f.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libunindent-ddddc7e37fb71ab2.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libpaste-65971c22bfb2b8fd.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libindoc-1f61c45563e34abc.rlib" "/Users/johndoe/src.git/package/target/debug/deps/librand_distr-88025beea685da1c.rlib" "/Users/johndoe/src.git/package/target/debug/deps/librand-0491459677551f18.rlib" "/Users/johndoe/src.git/package/target/debug/deps/librand_chacha-04af1bf57650deec.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libppv_lite86-83ccbe27f584a0cc.rlib" "/Users/johndoe/src.git/package/target/debug/deps/librand_core-fb6fc68e5c54699e.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libgetrandom-6452864637d35a6b.rlib" "/Users/johndoe/src.git/package/target/debug/deps/liblibc-167b652a2a09c8a9.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libcfg_if-a08cfa42db5d7bec.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libnalgebra-d42e9cfb75784332.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libmatrixmultiply-d1e5e1397e2e0e01.rlib" "/Users/johndoe/src.git/package/target/debug/deps/librawpointer-00b78b4ce2053fc7.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libnum_rational-91bb2e8bc820d5b8.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libnum_integer-859830178e1fd7e5.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libtypenum-b618aff4f364a497.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libsimba-a023658df442c80e.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libwide-70caf4cef3cad29a.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libbytemuck-0cd42780d63e75b4.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libsafe_arch-b030b28428d9bb93.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libnum_complex-9ea113f40a766f01.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libapprox-20815cba96253c1d.rlib" "/Users/johndoe/src.git/package/target/debug/deps/libnum_traits-76a684c8064af948.rlib" "/Users/johndoe/src.git/package/target/debug/deps/liblibm-6d836bca37d91d11.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd-f6811f31090e0239.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-585aa2ea4819ce90.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libobject-1b4ea1dc4a3823f8.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libmemchr-f653b27121920f5c.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-ef1f6d7964edf865.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libgimli-8d0a95997d48da47.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-68d9470ea5ba2fa3.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-d4ed7f63db7e9953.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-d2ad324cf0492211.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libminiz_oxide-a00c8eba7ff52d83.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libadler-92e25d254b309fb5.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-9cf27ed549592a86.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libunwind-ebee0ebd9a510319.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-718033b8fe200c22.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liblibc-5ec3532fb120beec.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-80ef5ce8d4cd7e19.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-b5600cb14c277fae.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-760870d297bc6b81.rlib" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-931e7dc6a4f959e6.rlib" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/Users/johndoe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/johndoe/src.git/package/target/debug/deps/libmyapp_numerical.dylib" "-Wl,-dead_strip" "-dynamiclib" "-Wl,-dylib" "-nodefaultlibs"
  = note: Undefined symbols for architecture arm64:
            "_PyUnicode_FromStringAndSize", referenced from:
                pyo3::types::string::PyString::new::h1734e53026f4b2da in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.12.rcgu.o)
            "_PyList_Append", referenced from:
                pyo3::types::list::PyList::append::_$u7b$$u7b$closure$u7d$$u7d$::hfea2359f07ea5941 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.11.rcgu.o)
            "_PyList_New", referenced from:
                pyo3::types::list::PyList::empty::h13fa92a68be04e06 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.11.rcgu.o)
            "_PyObject_Repr", referenced from:
                pyo3::types::any::PyAny::repr::h2934dcbcd3d4aec2 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.8.rcgu.o)
            "_PyExc_ValueError", referenced from:
                _$LT$pyo3..exceptions..PyValueError$u20$as$u20$pyo3..type_object..PyTypeInfo$GT$::type_object_raw::h050041d47afdcd7a in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.0.rcgu.o)
            "_PyExc_RuntimeError", referenced from:
                _$LT$pyo3..exceptions..PyRuntimeError$u20$as$u20$pyo3..type_object..PyTypeInfo$GT$::type_object_raw::hac7cd6aa59498411 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.0.rcgu.o)
            "_PyExc_BaseException", referenced from:
                _$LT$pyo3..exceptions..PyBaseException$u20$as$u20$pyo3..type_object..PyTypeInfo$GT$::type_object_raw::h0ddeafd2b2b3d3c9 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.0.rcgu.o)
            "_PyGILState_Release", referenced from:
                _$LT$pyo3..gil..GILGuard$u20$as$u20$core..ops..drop..Drop$GT$::drop::h4c148b591eb70908 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.3.rcgu.o)
            "_PyObject_Str", referenced from:
                pyo3::types::any::PyAny::str::h6309de5c2d927ab3 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.8.rcgu.o)
            "_PyGILState_Ensure", referenced from:
                pyo3::gil::GILGuard::acquire_unchecked::hdbebeae6a41910bc in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.3.rcgu.o)
            "__Py_NoneStruct", referenced from:
                pyo3::ffi::object::Py_None::h378d7e00b42ab4e5 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
            "_PyErr_GivenExceptionMatches", referenced from:
                pyo3::err::PyErr::is_instance::h57e26017c72f2ef8 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
            "_PyObject_GetAttr", referenced from:
                pyo3::types::any::PyAny::getattr::_$u7b$$u7b$closure$u7d$$u7d$::h90f1f9c5c017df53 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.8.rcgu.o)
            "_PyErr_NewException", referenced from:
                pyo3::err::PyErr::new_type::h6855f587f5895daa in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
            "_PyErr_Restore", referenced from:
                pyo3::err::PyErr::restore::h1d396af5370b4b2c in myapp_numerical.3eftvqie5n21xjx7.rcgu.o
                pyo3::err::PyErr::take::h19f97db3fd5a637e in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
                pyo3::err::PyErr::restore::hc7780ba0d94dbbec in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
            "_PyErr_Fetch", referenced from:
                pyo3::err::PyErr::take::h19f97db3fd5a637e in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
            "_PyObject_GenericSetDict", referenced from:
                pyo3::pyclass::push_dict_getset::h4bbc3ecadc8fb0db in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.12.rcgu.o)
            "_PyErr_Print", referenced from:
                pyo3::err::panic_after_error::h89e378db0a484235 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
            "_PyFloat_FromDouble", referenced from:
                pyo3::types::floatob::PyFloat::new::h5f1114f97790c423 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.10.rcgu.o)
            "_PyObject_SetAttrString", referenced from:
                pyo3::type_object::initialize_tp_dict::he0ea6e01288c9f53 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.10.rcgu.o)
            "_PyBytes_AsString", referenced from:
                pyo3::types::bytes::PyBytes::as_bytes::h5b541412ff68f968 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.10.rcgu.o)
            "_Py_IsInitialized", referenced from:
                pyo3::gil::GILGuard::acquire::_$u7b$$u7b$closure$u7d$$u7d$::h528072d5122a8297 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.3.rcgu.o)
            "_PyDict_New", referenced from:
                pyo3::types::dict::PyDict::new::hdb3dd52cb1bbc8bc in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.6.rcgu.o)
            "_PyExc_TypeError", referenced from:
                _$LT$pyo3..exceptions..PyTypeError$u20$as$u20$pyo3..type_object..PyTypeInfo$GT$::type_object_raw::h5d3f6f2a1192f8aa in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.0.rcgu.o)
            "_PyTuple_SetItem", referenced from:
                pyo3::types::tuple::_$LT$impl$u20$pyo3..conversion..IntoPy$LT$pyo3..instance..Py$LT$pyo3..types..any..PyAny$GT$$GT$$u20$for$u20$$LP$T0$C$$RP$$GT$::into_py::h44286c0d11970835 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.5.rcgu.o)
                pyo3::types::tuple::_$LT$impl$u20$pyo3..conversion..IntoPy$LT$pyo3..instance..Py$LT$pyo3..types..any..PyAny$GT$$GT$$u20$for$u20$$LP$T0$C$$RP$$GT$::into_py::h85a57d1d561a4c63 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
            "_PyTuple_New", referenced from:
                pyo3::types::tuple::PyTuple::new::h82afd939dbca5314 in myapp_numerical.4ex557449dtzvljc.rcgu.o
                pyo3::types::tuple::PyTuple::new::h9f18b36bb70e8a49 in myapp_numerical.4ex557449dtzvljc.rcgu.o
                pyo3::types::tuple::_$LT$impl$u20$pyo3..conversion..IntoPy$LT$pyo3..instance..Py$LT$pyo3..types..any..PyAny$GT$$GT$$u20$for$u20$$LP$T0$C$$RP$$GT$::into_py::h44286c0d11970835 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.5.rcgu.o)
                pyo3::types::tuple::_$LT$impl$u20$pyo3..conversion..IntoPy$LT$pyo3..instance..Py$LT$pyo3..types..any..PyAny$GT$$GT$$u20$for$u20$$LP$T0$C$$RP$$GT$::into_py::h85a57d1d561a4c63 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
            "_PyErr_NormalizeException", referenced from:
                pyo3::err::PyErr::normalized::hb2952342bc4388fc in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
            "_PyErr_PrintEx", referenced from:
                pyo3::err::PyErr::take::h19f97db3fd5a637e in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
                pyo3::err::PyErr::print::he378298d5f7091f1 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
            "_PyExc_AttributeError", referenced from:
                _$LT$pyo3..exceptions..PyAttributeError$u20$as$u20$pyo3..type_object..PyTypeInfo$GT$::type_object_raw::h79672f2e4afea538 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.0.rcgu.o)
            "__Py_Dealloc", referenced from:
                pyo3::ffi::object::Py_DECREF::h779398dd32528989 in myapp_numerical.s5260nvpf9t70pa.rcgu.o
                pyo3::ffi::object::Py_DECREF::h43112f237ead1f41 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.15.rcgu.o)
            "_PyType_GenericAlloc", referenced from:
                _$LT$pyo3..pyclass_init..PyNativeTypeInitializer$LT$T$GT$$u20$as$u20$pyo3..pyclass_init..PyObjectInit$LT$T$GT$$GT$::into_new_object::hdf55f595001a3497 in myapp_numerical.ks7dvv74xwckbps.rcgu.o
            "_PyBytes_Size", referenced from:
                pyo3::types::bytes::PyBytes::as_bytes::h5b541412ff68f968 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.10.rcgu.o)
            "_PyType_IsSubtype", referenced from:
                pyo3::ffi::object::PyObject_TypeCheck::hf9ce23d71e70cb70 in myapp_numerical.s5260nvpf9t70pa.rcgu.o
            "_PyFloat_AsDouble", referenced from:
                pyo3::types::floatob::_$LT$impl$u20$pyo3..conversion..FromPyObject$u20$for$u20$f64$GT$::extract::hed57f7b971ddc47b in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.10.rcgu.o)
            "_PyModule_Create2", referenced from:
                pyo3::ffi::modsupport::PyModule_Create::h1e6eccc637e3f7e6 in myapp_numerical.505je8fnfmlyhrwp.rcgu.o
            "_PyType_FromSpec", referenced from:
                pyo3::pyclass::create_type_object::he7e86c3646eb8a2f in myapp_numerical.f5iib2f5vuizsww.rcgu.o
            "_PyEval_ThreadsInitialized", referenced from:
                pyo3::gil::GILGuard::acquire::_$u7b$$u7b$closure$u7d$$u7d$::h528072d5122a8297 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.3.rcgu.o)
            "_PyDict_Next", referenced from:
                _$LT$pyo3..types..dict..PyDictIterator$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::next::h8cc5147fae92d621 in myapp_numerical.44nqqy7qhobdyxx2.rcgu.o
            "_PyBaseObject_Type", referenced from:
                _$LT$pyo3..pycell..PyCellBase$LT$U$GT$$u20$as$u20$pyo3..pycell..PyCellLayout$LT$T$GT$$GT$::tp_dealloc::h412b92ac540ff8c9 in myapp_numerical.14ag24dmo1f69k5h.rcgu.o
                _$LT$pyo3..types..any..PyAny$u20$as$u20$pyo3..type_object..PyTypeInfo$GT$::type_object_raw::ha02c7e0d8a5017b0 in myapp_numerical.45a0q769srscyur9.rcgu.o
                _$LT$pyo3..pyclass_init..PyNativeTypeInitializer$LT$T$GT$$u20$as$u20$pyo3..pyclass_init..PyObjectInit$LT$T$GT$$GT$::into_new_object::hdf55f595001a3497 in myapp_numerical.ks7dvv74xwckbps.rcgu.o
            "_PyUnicode_AsEncodedString", referenced from:
                pyo3::types::string::PyString::to_string_lossy::h77c31dbe390fb41d in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.12.rcgu.o)
            "_PyDict_SetItem", referenced from:
                pyo3::types::dict::PyDict::set_item::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hca247ca89a34a5f5 in myapp_numerical.1bhgec36fpi01mjz.rcgu.o
            "_PyObject_GenericGetDict", referenced from:
                pyo3::pyclass::push_dict_getset::h4bbc3ecadc8fb0db in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.12.rcgu.o)
            "_PyObject_SetAttr", referenced from:
                pyo3::types::any::PyAny::setattr::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::h1b2b45e82cee9404 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.8.rcgu.o)
                pyo3::types::any::PyAny::setattr::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hf057ecb4ca8f6aa2 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.8.rcgu.o)
            "_PyUnicode_AsUTF8AndSize", referenced from:
                pyo3::types::string::PyString::to_str::h4c262caeabbcd83c in myapp_numerical.440ee8pqnqvhopho.rcgu.o
                pyo3::types::string::PyString::to_str::hf42db64b403ec287 in libpyo3-cf9c9644d761101b.rlib(pyo3-cf9c9644d761101b.pyo3.3570a432-cgu.12.rcgu.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

It's not that cryptic. The error messages are basically saying the symbols from CPython are not found. Try install python development package for your system.

I think you will have to always use maturin rather than cargo when using pyo3. I'm pretty sure that maturin passes extra linker arguments to ensure that the linker is fine with importing these symbols from the executable using the dylib. Normally when using extern symbols, you explicitly specify a dependency on the dylib providing them. However for python there is no dylib to load them from. Instead the symbols are loaded from the executable that uses the dylib. The linker needs to be told that this is fine.

Unfortunately maturin develop doesn't compile anything but the library. I can't compile neither apps, tests nor examples. I see two possible solutions:

  • to write a script in (most likely in Python) that will strip off all code related to PyO3: has anyone has such a tool?
  • to create a separate crate, say myapp-pylib that will basically delegate all calls to the main crate (i.e. myapp); this would be 90% duplication of the code with one advantage: I'd move python-related stuff (such as numpy support) out of the main crate.

Can anyone suggest a better solution?