pyo3 already fixed...
Original Message:
Sent: Mon April 15, 2024 12:41 PM
From: Andrey Klyachkin
Subject: Rust AIX: linker fails with undefined symbols
This is btw .cargo/config from my python-cryptography build:
[env]PYO3_PYTHON="/opt/freeware/bin/python3"OBJECT_MODE="64"[target.powerpc64-ibm-aix]rustflags = [ "-C", "link-arg=-L/opt/freeware/lib", "-C", "link-arg=-lpython3.9", "-C", "link-arg=-lintl", "-C", "link-arg=-lssl", "-C", "link-arg=-lcrypto", "-C", "link-arg=-b64", "-C", "link-arg=-blazy", "-C", "link-arg=-bbigtoc",]
------------------------------
Andrey Klyachkin
https://www.power-devops.com
------------------------------
Original Message:
Sent: Mon April 15, 2024 12:37 PM
From: Andrey Klyachkin
Subject: Rust AIX: linker fails with undefined symbols
I've got to my Rust development server, where I tested pyo3 under AIX.
This is src/lib.rs
use pyo3::prelude::*;use pyo3::wrap_pyfunction;#[pyfunction]pub fn add(left: usize, right: usize) -> PyResult<String> { Ok((left + right).to_string())}#[pymodule]/// A Python module implemented in Rust.fn aixpy(_py: Python, m: &PyModule) -> PyResult<()> { m.add_wrapped(wrap_pyfunction!(add))?; Ok(())}
This is Cargo.toml:
[package]name = "aixpy"version = "0.1.0"edition = "2021"# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html[lib]name = "aixpy"crate-type = ["cdylib"][target.powerpc64-ibm-aix]rustflags = [ "-C", "link-arg=-bbigtoc",][dependencies][dependencies.pyo3]version = "0.18.1"features = ["extension-module"][patch.crates-io]pyo3 = { path = "/home/root/rust/pyo3", package = "pyo3" }
This is .cargo/config:
[target.powerpc64-ibm-aix]rustflags = [ "-C", "link-arg=-L/usr/opt/python3/lib/python3.9/config-3.9", "-C", "link-arg=-lpython3.9", "-C", "link-arg=-lintl", "-C", "link-arg=-lc++abi", "-C", "link-arg=-bdynamic", "-C", "link-arg=-blazy",]
AFAIU the last file is the most important to link to AIX python.
I hope it helps.
------------------------------
Andrey Klyachkin
https://www.power-devops.com
Original Message:
Sent: Thu April 11, 2024 08:41 AM
From: C- -T
Subject: Rust AIX: linker fails with undefined symbols
i just used rpds-py for testing cause its rather "small" and overseeable. your point on pyo3 seems reasonable is its indeed a bug infested piece of junk.
------------------------------
I regret starting this entire conversation
Original Message:
Sent: Thu April 11, 2024 08:35 AM
From: Andrey Klyachkin
Subject: Rust AIX: linker fails with undefined symbols
I know nothing about rpds-py, but the flags is usually what pyo3 does. It means it didn't find the correct flags for your python installation
------------------------------
Andrey Klyachkin
https://www.power-devops.com
Original Message:
Sent: Thu April 11, 2024 08:32 AM
From: C- -T
Subject: Rust AIX: linker fails with undefined symbols
after adding the python3.9 ldflags to RUSTFLAGS the wheel built successfully...should'nt the rust compiler itself take care of this...quite a annoyance IMHO
root@nimvie: /tmp/rpds_py-0.18.0 # python3.9-config --ldflags -L/usr/opt/python3/lib -lpython3.9 -lintl -ldl -lm -lmroot@nimvie: /tmp/rpds_py-0.18.0 # echo $RUSTFLAGS-C link-arg=-bbigtocroot@nimvie: /tmp/rpds_py-0.18.0 # export RUSTFLAGS="-C link-arg=-bbigtoc -L/usr/opt/python3/lib -lpython3.9 -lintl -ldl -lm -lm"root@nimvie: /tmp/rpds_py-0.18.0 # echo $RUSTFLAGS-C link-arg=-bbigtoc -L/usr/opt/python3/lib -lpython3.9 -lintl -ldl -lm -lm
root@nimvie: /tmp/rpds_py-0.18.0 # maturin build📦 Including license file "/tmp/rpds_py-0.18.0/LICENSE"🔗 Found pyo3 bindings🐍 Found CPython 3.9 at /usr/bin/python3📡 Using build options features from pyproject.toml Compiling target-lexicon v0.12.9 Compiling autocfg v1.1.0 Compiling proc-macro2 v1.0.66 Compiling once_cell v1.18.0 Compiling unicode-ident v1.0.11 Compiling libc v0.2.147 Compiling parking_lot_core v0.9.8 Compiling smallvec v1.11.0 Compiling scopeguard v1.1.0 Compiling cfg-if v1.0.0 Compiling heck v0.4.1 Compiling triomphe v0.1.9 Compiling static_assertions v1.1.0 Compiling indoc v2.0.4 Compiling unindent v0.2.3 Compiling archery v1.1.0 Compiling rpds v1.1.0 Compiling lock_api v0.4.10 Compiling memoffset v0.9.0 Compiling quote v1.0.31 Compiling pyo3-build-config v0.20.2 Compiling syn v2.0.32 Compiling parking_lot v0.12.1 Compiling pyo3-ffi v0.20.2 Compiling pyo3 v0.20.2 Compiling pyo3-macros-backend v0.20.2 Compiling pyo3-macros v0.20.2 Compiling rpds-py v0.18.0 (/tmp/rpds_py-0.18.0) Finished dev [unoptimized + debuginfo] target(s) in 56.71s📖 Found type stub file at rpds.pyi📦 Built wheel for CPython 3.9 to /tmp/rpds_py-0.18.0/target/wheels/rpds_py-0.18.0-cp39-cp39-aix_3_00CA8B904B00.whl
------------------------------
I regret starting this entire conversation