Built Python module using pyo3 and maturin fails to load with undefined symbol

Hi,

I'using using Kubuntu Linux, Rust nightly, pyo3, 0.12.3 and maturin to build a Python module.
The module builds fine. But when I try to load the module I get an unresolved symbol error.

ImportError: /home/user/.pyenv/versions/3.7.8/lib/python3.7/site-packages/pyfoolib.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN53_$LT$pyo3..err..PyErr$u20$as$u20$core..fmt..Debug$GT$3fmt17h1568af9f5f35f60fE

When the module was compiled the following commands were printed to console:


Running `rustc --crate-name pyo3 --edition=2018 /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.12.3/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C codegen-units=1 --cfg 'feature="ctor"' --cfg 'feature="default"' --cfg 'feature="extension-module"' --cfg 'feature="indoc"' --cfg 'feature="inventory"' --cfg 'feature="macros"' --cfg 'feature="paste"' --cfg 'feature="pyo3cls"' --cfg 'feature="unindent"' -C metadata=59fd623f0cd651b9 -C extra-filename=-59fd623f0cd651b9 --out-dir /home/user/Rust/fooproject/target/release/deps -L dependency=/home/user/Rust/fooproject/target/release/deps --extern ctor=/home/user/Rust/fooproject/target/release/deps/libctor-9b1432d35685be7e.so --extern indoc=/home/user/Rust/fooproject/target/release/deps/libindoc-b4600caa1b74c55e.rmeta --extern inventory=/home/user/Rust/fooproject/target/release/deps/libinventory-e5486f65389a5b3e.rmeta --extern libc=/home/user/Rust/fooproject/target/release/deps/liblibc-67b1f2df6421b94a.rmeta --extern parking_lot=/home/user/Rust/fooproject/target/release/deps/libparking_lot-c0f93abd7369f853.rmeta --extern paste=/home/user/Rust/fooproject/target/release/deps/libpaste-b84df10727ab9f48.rmeta --extern pyo3cls=/home/user/Rust/fooproject/target/release/deps/libpyo3cls-b92ed2fb48d47a57.so --extern unindent=/home/user/Rust/fooproject/target/release/deps/libunindent-31544d4128b45d96.rmeta --cap-lints allow -Z mutable-noalias --cfg Py_3_5 --cfg Py_3_6 --cfg Py_3_7 --cfg Py_3 --cfg 'py_sys_config="WITH_THREAD"'`

Running `rustc --crate-name pyfoolib --edition=2018 pyfoolib/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type cdylib --emit=dep-info,link -C opt-level=3 -C lto -C codegen-units=1 --crate-type cdylib --cfg 'feature="default"' -C metadata=3af4564279027178 --out-dir /home/user/Rust/fooproject/target/release/deps -L dependency=/home/user/Rust/fooproject/target/release/deps --extern flume=/home/user/Rust/fooproject/target/release/deps/libflume-f259df15f7272626.rlib --extern parking_lot=/home/user/Rust/fooproject/target/release/deps/libparking_lot-c0f93abd7369f853.rlib --extern pyo3=/home/user/Rust/fooproject/target/release/deps/libpyo3-59fd623f0cd651b9.rlib --extern structopt=/home/user/Rust/fooproject/target/release/deps/libstructopt-e61cb08467ad404e.rlib --extern zarlib=/home/user/Rust/fooproject/target/release/deps/libzarlib.so -Z mutable-noalias -L native=/home/user/Rust/fooproject/target/release/build/ring-879144004bffaeca/out -L native=/home/user/Rust/fooproject/target/release/build/zstd-sys-36016982930390b1/out`

A search for the missing symbol above shows that it can be found in file libpyo3-59fd623f0cd651b9.rlib. AFAIK rlib files are for static linking. So I would assume that the error message should not be possible. So I'm really confused and have no idea to get rid of this problem.

Does anybody have an idea how to solve this?