I'm looking at getting guidance in order to get to building any rust python wheel properly under our framework under the SynoCommunity spksrc project, starting with cryptography.
We're using crossenv with all the necessary dependency bits AFAICT and we're building all wheels using pip either as cross-compiled or pure-python as needed.
Note that while learning on the topic I ended-up figuring that --target wasn't the way to go as it ends-up building rustc host plugins (crates?) using the cross-compiling environment making things worst as they end-up being built for the target and impossible to run on the host.
As such I'm now using env variables such as CARGO_BUILD_TARGET="armv7-unknown-linux-gnueabihf" (platform dependent) which seems to bring me closer to my goal.
The issue I believe I've been hitting is that, using pip the build environment, does not seems to find the proper linker. By default the cross-compiling environment sets all the CC, CXX, CFLAGS, etc. pointing to the cross-compiler toolchain. After quite a bit of reading it became obvious that neither CC or LD environment variables wheren't being used to define the linker for the rustc compiler.
As such I've tried passing it through the environment such as CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER="/home/spksrc/rustc/spksrc/toolchain/syno-armv7-7.0/work/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc" but it ends-up failing at linking time where the host default linker is being used:
error: could not compile `libc` due to previous error
Caused by:
process didn't exit successfully: `rustc --crate-name build_script_build /home/spksrc/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.132/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off -C overflow-checks=on --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=c6828ee39fa0c47f -C extra-filename=-c6828ee39fa0c47f --out-dir /tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/libc-c6828ee39fa0c47f -L dependency=/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/deps --cap-lints allow` (exit status: 1)
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-m64" "/tmp/rustcdK3NnT/symbols.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.0.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.1.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.10.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.11.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.12.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.13.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.14.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.15.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.2.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.3.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.4.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.5.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.6.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.7.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.8.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.build_script_build.e7ddb37a-cgu.9.rcgu.o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2.3i9cjhtqe7j8wwb5.rcgu.o" "-Wl,--as-needed" "-L" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/deps" "-L" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-8f1929c73c3f8167.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-e359d865975ccf21.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-b886fd10c5a7c7c0.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-9d7c322d48daa475.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-08ae1606a951cabe.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-682a81c4b2133b72.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-a73b3512c88de071.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-7b5ec4c918d9f957.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-65c63cf3af0af657.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-4a53f0a2785abc6a.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-868e2d515c28d027.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-394ad2d73aede76a.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-19c77e4dc3dcb87e.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-fb44a42088c9369a.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-61a7402e61a5b0e0.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-63f8356c87a0d0e8.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-a506e577d917828c.rlib" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-fc1fb63210fdafad.rlib" "-Wl,--end-group" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-c21be34a5cae8449.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/spksrc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/tmp/pip-wheel-cri4pr2f/cryptography_a11930f6101c49faa156270f4708669e/src/rust/target/release/build/pyo3-build-config-0257034bb1a5cea2/build_script_build-0257034bb1a5cea2" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs"
= note: /usr/bin/ld: /home/spksrc/rustc/spksrc/toolchain/syno-armv7-7.0/work/arm-unknown-linux-gnueabi/bin/../arm-unknown-linux-gnueabi/sysroot/usr/lib/../lib/Scrt1.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /home/spksrc/rustc/spksrc/toolchain/syno-armv7-7.0/work/arm-unknown-linux-gnueabi/bin/../arm-unknown-linux-gnueabi/sysroot/usr/lib/../lib/Scrt1.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /home/spksrc/rustc/spksrc/toolchain/syno-armv7-7.0/work/arm-unknown-linux-gnueabi/bin/../arm-unknown-linux-gnueabi/sysroot/usr/lib/../lib/Scrt1.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /home/spksrc/rustc/spksrc/toolchain/syno-armv7-7.0/work/arm-unknown-linux-gnueabi/bin/../arm-unknown-linux-gnueabi/sysroot/usr/lib/../lib/Scrt1.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /home/spksrc/rustc/spksrc/toolchain/syno-armv7-7.0/work/arm-unknown-linux-gnueabi/bin/../arm-unknown-linux-gnueabi/sysroot/usr/lib/../lib/Scrt1.o: relocations in generic ELF (EM: 40)
/usr/bin/ld: /home/spksrc/rustc/spksrc/toolchain/syno-armv7-7.0/work/arm-unknown-linux-gnueabi/bin/../arm-unknown-linux-gnueabi/sysroot/usr/lib/../lib/Scrt1.o: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status
My thought is, can/shall I use options such as --global-option=--target="armv7-unknown-linux-gnueabihf" or similar where I can enforce the default target and, most importantly, enforce the default linker?
My current work at integrating rust python wheel cross-compiling is in PR SynoCommunity/spksrc#5435. Although note that github action logs won't provide much as it currently doesn't update the build Docker image until pushed to master.
As mentionned above, guidance would be much appreciated. Thnx in advance.
I'm looking at getting guidance in order to get to building any rust python wheel properly under our framework under the SynoCommunity spksrc project, starting with
cryptography.We're using
crossenvwith all the necessary dependency bits AFAICT and we're building all wheels usingpipeither as cross-compiled or pure-python as needed.Note that while learning on the topic I ended-up figuring that
--targetwasn't the way to go as it ends-up building rustc host plugins (crates?) using the cross-compiling environment making things worst as they end-up being built for the target and impossible to run on the host.As such I'm now using env variables such as
CARGO_BUILD_TARGET="armv7-unknown-linux-gnueabihf"(platform dependent) which seems to bring me closer to my goal.The issue I believe I've been hitting is that, using
pipthe build environment, does not seems to find the proper linker. By default the cross-compiling environment sets all theCC,CXX,CFLAGS, etc. pointing to the cross-compiler toolchain. After quite a bit of reading it became obvious that neitherCCorLDenvironment variables wheren't being used to define the linker for the rustc compiler.As such I've tried passing it through the environment such as
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER="/home/spksrc/rustc/spksrc/toolchain/syno-armv7-7.0/work/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc"but it ends-up failing at linking time where the host default linker is being used:My thought is, can/shall I use options such as
--global-option=--target="armv7-unknown-linux-gnueabihf"or similar where I can enforce the default target and, most importantly, enforce the default linker?My current work at integrating rust python wheel cross-compiling is in PR SynoCommunity/spksrc#5435. Although note that github action logs won't provide much as it currently doesn't update the build Docker image until pushed to master.
As mentionned above, guidance would be much appreciated. Thnx in advance.