pyo3: Cross compilation is broken when host and target architectures are the same.
When I tried cross compiling for a x86_64 target from a x86_64 host I get a build failure that seems to be caused by broken cross compilation detection logic which results in PYO3_CROSS_LIB_DIR being ignored. My build setup appears to work fine when I cross compile for i386 or aarch64 targets from a x86_64 host.
>>> python-cryptography 3.4.6 Building
(cd /home/buildroot/buildroot/output/build/python-cryptography-3.4.6//; _PYTHON_SYSCONFIGDATA_NAME="`{ [ -e /home/buildroot/buildroot/output/per-package/python-cryptography/host/x86_64-buildroot-linux-gnu/sysroot/usr/lib/python3.9//_sysconfigdata__linux_*.py ] && basename /home/buildroot/buildroot/output/per-package/python-cryptography/host/x86_64-buildroot-linux-gnu/sysroot/usr/lib/python3.9//_sysconfigdata__linux_*.py .py; } || true`" PATH="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin:/home/buildroot/buildroot/output/per-package/python-cryptography/host/sbin:/home/buildroot/bin:/home/buildroot/.local/bin:/home/buildroot/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" PATH="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin:/home/buildroot/buildroot/output/per-package/python-cryptography/host/sbin:/home/buildroot/bin:/home/buildroot/.local/bin:/home/buildroot/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" AR="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-ar" AS="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-as" LD="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-ld" NM="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-nm" CC="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-gcc" GCC="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-gcc" CPP="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-cpp" CXX="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-g++" FC="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-gfortran" F77="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-gfortran" RANLIB="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-ranlib" READELF="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-readelf" STRIP="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-strip" OBJCOPY="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-objcopy" OBJDUMP="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-objdump" AR_FOR_BUILD="/usr/bin/ar" AS_FOR_BUILD="/usr/bin/as" CC_FOR_BUILD="/usr/bin/gcc" GCC_FOR_BUILD="/usr/bin/gcc" CXX_FOR_BUILD="/usr/bin/g++" LD_FOR_BUILD="/usr/bin/ld" CPPFLAGS_FOR_BUILD="-I/home/buildroot/buildroot/output/per-package/python-cryptography/host/include" CFLAGS_FOR_BUILD="-O2 -I/home/buildroot/buildroot/output/per-package/python-cryptography/host/include" CXXFLAGS_FOR_BUILD="-O2 -I/home/buildroot/buildroot/output/per-package/python-cryptography/host/include" LDFLAGS_FOR_BUILD="-L/home/buildroot/buildroot/output/per-package/python-cryptography/host/lib -Wl,-rpath,/home/buildroot/buildroot/output/per-package/python-cryptography/host/lib" FCFLAGS_FOR_BUILD="" DEFAULT_ASSEMBLER="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-as" DEFAULT_LINKER="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/x86_64-buildroot-linux-gnu-ld" CPPFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os " CXXFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os " LDFLAGS="" FCFLAGS=" -Os " FFLAGS=" -Os " PKG_CONFIG="/home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/pkg-config" STAGING_DIR="/home/buildroot/buildroot/output/per-package/python-cryptography/host/x86_64-buildroot-linux-gnu/sysroot" INTLTOOL_PERL=/usr/bin/perl PYTHONPATH="/home/buildroot/buildroot/output/per-package/python-cryptography/host/x86_64-buildroot-linux-gnu/sysroot/usr/lib/python3.9/" PYTHONNOUSERSITE=1 _python_sysroot=/home/buildroot/buildroot/output/per-package/python-cryptography/host/x86_64-buildroot-linux-gnu/sysroot _python_prefix=/usr _python_exec_prefix=/usr CARGO_BUILD_TARGET="x86_64-unknown-linux-gnu" PYO3_CROSS_LIB_DIR="/home/buildroot/buildroot/output/per-package/python-cryptography/host/x86_64-buildroot-linux-gnu/sysroot/usr/lib/python3.9" CARGO_HOME="/home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo" /home/buildroot/buildroot/output/per-package/python-cryptography/host/bin/python setup.py build )
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/cryptography
copying src/cryptography/utils.py -> build/lib.linux-x86_64-3.9/cryptography
copying src/cryptography/__about__.py -> build/lib.linux-x86_64-3.9/cryptography
copying src/cryptography/exceptions.py -> build/lib.linux-x86_64-3.9/cryptography
copying src/cryptography/__init__.py -> build/lib.linux-x86_64-3.9/cryptography
copying src/cryptography/fernet.py -> build/lib.linux-x86_64-3.9/cryptography
creating build/lib.linux-x86_64-3.9/cryptography/hazmat
copying src/cryptography/hazmat/_types.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat
copying src/cryptography/hazmat/_oid.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat
copying src/cryptography/hazmat/_der.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat
copying src/cryptography/hazmat/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat
creating build/lib.linux-x86_64-3.9/cryptography/x509
copying src/cryptography/x509/ocsp.py -> build/lib.linux-x86_64-3.9/cryptography/x509
copying src/cryptography/x509/base.py -> build/lib.linux-x86_64-3.9/cryptography/x509
copying src/cryptography/x509/oid.py -> build/lib.linux-x86_64-3.9/cryptography/x509
copying src/cryptography/x509/general_name.py -> build/lib.linux-x86_64-3.9/cryptography/x509
copying src/cryptography/x509/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/x509
copying src/cryptography/x509/name.py -> build/lib.linux-x86_64-3.9/cryptography/x509
copying src/cryptography/x509/extensions.py -> build/lib.linux-x86_64-3.9/cryptography/x509
copying src/cryptography/x509/certificate_transparency.py -> build/lib.linux-x86_64-3.9/cryptography/x509
creating build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings
copying src/cryptography/hazmat/bindings/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings
creating build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
copying src/cryptography/hazmat/primitives/constant_time.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
copying src/cryptography/hazmat/primitives/keywrap.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
copying src/cryptography/hazmat/primitives/hashes.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
copying src/cryptography/hazmat/primitives/_asymmetric.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
copying src/cryptography/hazmat/primitives/cmac.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
copying src/cryptography/hazmat/primitives/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
copying src/cryptography/hazmat/primitives/_cipheralgorithm.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
copying src/cryptography/hazmat/primitives/_serialization.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
copying src/cryptography/hazmat/primitives/hmac.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
copying src/cryptography/hazmat/primitives/padding.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
copying src/cryptography/hazmat/primitives/poly1305.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives
creating build/lib.linux-x86_64-3.9/cryptography/hazmat/backends
copying src/cryptography/hazmat/backends/interfaces.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends
copying src/cryptography/hazmat/backends/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends
creating build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings/openssl
copying src/cryptography/hazmat/bindings/openssl/_conditional.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings/openssl
copying src/cryptography/hazmat/bindings/openssl/binding.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings/openssl
copying src/cryptography/hazmat/bindings/openssl/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/bindings/openssl
creating build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/twofactor
copying src/cryptography/hazmat/primitives/twofactor/utils.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/twofactor
copying src/cryptography/hazmat/primitives/twofactor/hotp.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/twofactor
copying src/cryptography/hazmat/primitives/twofactor/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/twofactor
copying src/cryptography/hazmat/primitives/twofactor/totp.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/twofactor
creating build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
copying src/cryptography/hazmat/primitives/asymmetric/ec.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
copying src/cryptography/hazmat/primitives/asymmetric/utils.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
copying src/cryptography/hazmat/primitives/asymmetric/dsa.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
copying src/cryptography/hazmat/primitives/asymmetric/x25519.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
copying src/cryptography/hazmat/primitives/asymmetric/x448.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
copying src/cryptography/hazmat/primitives/asymmetric/ed448.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
copying src/cryptography/hazmat/primitives/asymmetric/dh.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
copying src/cryptography/hazmat/primitives/asymmetric/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
copying src/cryptography/hazmat/primitives/asymmetric/padding.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
copying src/cryptography/hazmat/primitives/asymmetric/rsa.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
copying src/cryptography/hazmat/primitives/asymmetric/ed25519.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/asymmetric
creating build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/serialization
copying src/cryptography/hazmat/primitives/serialization/base.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/serialization
copying src/cryptography/hazmat/primitives/serialization/ssh.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/serialization
copying src/cryptography/hazmat/primitives/serialization/pkcs7.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/serialization
copying src/cryptography/hazmat/primitives/serialization/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/serialization
copying src/cryptography/hazmat/primitives/serialization/pkcs12.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/serialization
creating build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/kdf
copying src/cryptography/hazmat/primitives/kdf/kbkdf.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/kdf
copying src/cryptography/hazmat/primitives/kdf/pbkdf2.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/kdf
copying src/cryptography/hazmat/primitives/kdf/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/kdf
copying src/cryptography/hazmat/primitives/kdf/scrypt.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/kdf
copying src/cryptography/hazmat/primitives/kdf/concatkdf.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/kdf
copying src/cryptography/hazmat/primitives/kdf/hkdf.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/kdf
copying src/cryptography/hazmat/primitives/kdf/x963kdf.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/kdf
creating build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/ciphers
copying src/cryptography/hazmat/primitives/ciphers/base.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/ciphers
copying src/cryptography/hazmat/primitives/ciphers/modes.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/ciphers
copying src/cryptography/hazmat/primitives/ciphers/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/ciphers
copying src/cryptography/hazmat/primitives/ciphers/aead.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/ciphers
copying src/cryptography/hazmat/primitives/ciphers/algorithms.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/primitives/ciphers
creating build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/encode_asn1.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/ec.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/x509.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/utils.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/dsa.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/ocsp.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/x25519.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/hashes.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/x448.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/ed448.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/dh.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/ciphers.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/cmac.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/__init__.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/decode_asn1.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/hmac.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/rsa.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/poly1305.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/backend.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/aead.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
copying src/cryptography/hazmat/backends/openssl/ed25519.py -> build/lib.linux-x86_64-3.9/cryptography/hazmat/backends/openssl
running egg_info
writing src/cryptography.egg-info/PKG-INFO
writing dependency_links to src/cryptography.egg-info/dependency_links.txt
writing requirements to src/cryptography.egg-info/requires.txt
writing top-level names to src/cryptography.egg-info/top_level.txt
reading manifest file 'src/cryptography.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs/_build'
warning: no previously-included files found matching 'vectors'
warning: no previously-included files matching '*' found under directory 'vectors'
warning: no previously-included files matching '*' found under directory '.github'
warning: no previously-included files found matching 'release.py'
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching 'codecov.yml'
warning: no previously-included files found matching '.readthedocs.yml'
warning: no previously-included files found matching 'dev-requirements.txt'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'mypy.ini'
warning: no previously-included files matching '*' found under directory '.zuul.d'
warning: no previously-included files matching '*' found under directory '.zuul.playbooks'
writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
copying src/cryptography/py.typed -> build/lib.linux-x86_64-3.9/cryptography
running build_ext
generating cffi module 'build/temp.linux-x86_64-3.9/_padding.c'
creating build/temp.linux-x86_64-3.9
generating cffi module 'build/temp.linux-x86_64-3.9/_openssl.c'
running build_rust
cargo rustc --lib --manifest-path src/rust/Cargo.toml --features pyo3/extension-module pyo3/abi3-py36 --target x86_64-unknown-linux-gnu --release --verbose -- --crate-type cdylib
Compiling proc-macro2 v1.0.24
Compiling unicode-xid v0.2.1
Running `rustc --crate-name build_script_build --edition=2018 /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.24/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' --cfg 'feature="proc-macro"' -C metadata=bfb1f9980f3c8b9c -C extra-filename=-bfb1f9980f3c8b9c --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/build/proc-macro2-bfb1f9980f3c8b9c -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Compiling syn v1.0.60
Compiling proc-macro-hack v0.5.19
Compiling libc v0.2.85
Compiling cfg-if v1.0.0
Compiling inventory v0.1.10
Compiling smallvec v1.6.1
Compiling scopeguard v1.1.0
Compiling unindent v0.1.7
Compiling pyo3 v0.13.2
Running `rustc --crate-name build_script_build --edition=2018 /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/syn-1.0.60/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="clone-impls"' --cfg 'feature="default"' --cfg 'feature="derive"' --cfg 'feature="extra-traits"' --cfg 'feature="full"' --cfg 'feature="parsing"' --cfg 'feature="printing"' --cfg 'feature="proc-macro"' --cfg 'feature="quote"' -C metadata=a9e6d896813f574d -C extra-filename=-a9e6d896813f574d --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/build/syn-a9e6d896813f574d -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Running `rustc --crate-name unicode_xid /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/unicode-xid-0.2.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' -C metadata=11360309d1f83f7c -C extra-filename=-11360309d1f83f7c --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Running `rustc --crate-name build_script_build --edition=2018 /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro-hack-0.5.19/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C metadata=7c1fdba57ac8b4dc -C extra-filename=-7c1fdba57ac8b4dc --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/build/proc-macro-hack-7c1fdba57ac8b4dc -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Running `rustc --crate-name build_script_build /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.85/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=7fe3459c3f5f63e1 -C extra-filename=-7fe3459c3f5f63e1 --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/build/libc-7fe3459c3f5f63e1 -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Running `rustc --crate-name cfg_if --edition=2018 /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/cfg-if-1.0.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C metadata=e7b0dffcdd170f33 -C extra-filename=-e7b0dffcdd170f33 --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Running `rustc --crate-name build_script_build --edition=2018 /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/inventory-0.1.10/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C metadata=4dc89529860486e0 -C extra-filename=-4dc89529860486e0 --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/build/inventory-4dc89529860486e0 -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Running `rustc --crate-name scopeguard /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/scopeguard-1.1.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C metadata=f0bf9cbd331d628b -C extra-filename=-f0bf9cbd331d628b --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Running `rustc --crate-name smallvec --edition=2018 /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/smallvec-1.6.1/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C metadata=ec0aca5aee98c6c5 -C extra-filename=-ec0aca5aee98c6c5 --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Running `rustc --crate-name unindent --edition=2018 /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/unindent-0.1.7/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C metadata=1aeb4b3143bc511d -C extra-filename=-1aeb4b3143bc511d --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Running `rustc --crate-name build_script_build --edition=2018 /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/pyo3-0.13.2/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="abi3"' --cfg 'feature="abi3-py36"' --cfg 'feature="abi3-py37"' --cfg 'feature="abi3-py38"' --cfg 'feature="abi3-py39"' --cfg 'feature="auto-initialize"' --cfg 'feature="ctor"' --cfg 'feature="default"' --cfg 'feature="extension-module"' --cfg 'feature="indoc"' --cfg 'feature="inventory"' --cfg 'feature="macros"' --cfg 'feature="paste"' --cfg 'feature="pyo3-macros"' --cfg 'feature="unindent"' -C metadata=f12fd4bcb46afcd1 -C extra-filename=-f12fd4bcb46afcd1 --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/build/pyo3-f12fd4bcb46afcd1 -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Running `rustc --crate-name unindent --edition=2018 /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/unindent-0.1.7/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C metadata=fd06cb352cfe2a71 -C extra-filename=-fd06cb352cfe2a71 --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --cap-lints allow`
Compiling instant v0.1.9
Running `rustc --crate-name instant --edition=2018 /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/instant-0.1.9/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C metadata=da957a8a7f012a18 -C extra-filename=-da957a8a7f012a18 --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --extern cfg_if=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps/libcfg_if-e7b0dffcdd170f33.rmeta --cap-lints allow`
Compiling lock_api v0.4.2
Running `rustc --crate-name lock_api --edition=2018 /home/buildroot/buildroot/output/per-package/python-cryptography/host/share/cargo/registry/src/github.com-1ecc6299db9ec823/lock_api-0.4.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C metadata=bd21e10e284ee09c -C extra-filename=-bd21e10e284ee09c --out-dir /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -C linker=x86_64-buildroot-linux-gnu-gcc -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/deps --extern scopeguard=/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/x86_64-unknown-linux-gnu/release/deps/libscopeguard-f0bf9cbd331d628b.rmeta --cap-lints allow`
Running `/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/build/syn-a9e6d896813f574d/build-script-build`
error: failed to run custom build command for `syn v1.0.60`
Caused by:
process didn't exit successfully: `/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/build/syn-a9e6d896813f574d/build-script-build` (exit code: 1)
--- stderr
/home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/build/syn-a9e6d896813f574d/build-script-build: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/src/rust/target/release/build/syn-a9e6d896813f574d/build-script-build)
warning: build failed, waiting for other jobs to finish...
error: build failed
=============================DEBUG ASSISTANCE=============================
If you are seeing a compilation error please try the following steps to
successfully install cryptography:
1) Upgrade to the latest pip and try again. This will fix errors for most
users. See: https://pip.pypa.io/en/stable/installing/#upgrading-pip
2) Read https://cryptography.io/en/latest/installation.html for specific
instructions for your platform.
3) Check our frequently asked questions for more information:
https://cryptography.io/en/latest/faq.html
4) Ensure you have a recent Rust toolchain installed:
https://cryptography.io/en/latest/installation.html#rust
5) If you are experiencing issues with Rust for *this release only* you may
set the environment variable `CRYPTOGRAPHY_DONT_BUILD_RUST=1`.
=============================DEBUG ASSISTANCE=============================
error: cargo failed with code: 101
make[1]: *** [package/pkg-generic.mk:250: /home/buildroot/buildroot/output/build/python-cryptography-3.4.6/.stamp_built] Error 1
This comment seems to indicate cross compilation mode will not function when the host and target are the same: https://github.com/PyO3/pyo3/blob/190eb728037772210bc2805432d77854703cdb42/build.rs#L885-L886
How should one ensure that pyo3 knows to always run in cross compilation mode even if the host and target architectures are the same?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (19 by maintainers)
I may have a potential fix for the cargo issue in #9322.
So does this mean that we would need to add a force cross compilation override of some sort to cargo?
Heh, well a lot it seems since the architecture being the same effectively is entirely separate from whether or not one is cross compiling.
Ok, so we need to fix this in addition to the cargo issue above still though right?
Ok, so keeping in mind I’m trying to get this working in a way that’s acceptable for upstream buildroot, I don’t think any of these would work for the following reasons:
The host OS toolchain is invalid for compiling target binaries with buildroot so we can’t do this, it can only be used for compiling buildroot host packages(build tools), not buildroot target packages(stuff that runs on the target system we are cross compiling for). The built in OS toolchain is effectively only usable for bootstrapping/running the build tools(host packages in buildroot terminology) which buildroot then uses to compile everything for the target. We can’t directly compile target binaries from the OS toolchain since buildroot needs to effectively fully control the build tools/process used for target binary compilation.
Buildroot doesn’t control the host OS toolchain glibc version so this isn’t possible.
I thought we are already doing this effectively.
Let me try to summarize what’s happening.
Rust has proc-macro and build script, they can generate code when compiling and they are linked with host toolchain and needs to be able to run on host.
When cross compiling for a different target, even though you specified
--target, proc-macro and build script ignores that and continue to use host toolchain to link so the aarch64 and i686 cross compiling works just fine.But when host and target is the same, say
x86_64-unknown-linux-gnu, cargo doesn’t think it’s cross compiling, it uses the same host toolchain to link if you didn’t configure a different linker in.cargo/config.toml. And if you do configure a different linker in.cargo/config.toml, proc-macro and build script will also use that because as far as cargo knows, you specified linker forx86_64-unknown-linux-gnutarget and you are compiling tox86_64-unknown-linux-gnu, it’s the same what could possibly go wrong?So this has nothing to do with
PYO3_CROSS_LIB_DIR, it didn’t even reach the step to use that. And because pyo3 also uses build script, it will fail to run with the same error even if it runs.I think there are several ways to resolve this:
I don’t think this is related to
PYO3_CROSS_LIB_DIR. It’s more or less a issue with your C/C++ toolchain of the buildroot, it appears to have newer version of GLIBC than the host one.synis a proc-macro, proc-macro usually compiles with host toolchain and runs on the host. My guess it that it’s compiled and linked with the buildroot toolchain instead of the host toolchain because host and buildroot target is the same, it’s likely to have setCC_x86_64_unknown_linux_gnuand other C/C++ compiler related environment variables to the buildroot toolchain, which results in linking with newer version of GLIBC that is not compatible with the host (see the-C linker=x86_64-buildroot-linux-gnu-gcccommand line option above), hence the/lib/x86_64-linux-gnu/libc.so.6: version GLIBC_2.32 not founderror.