quic协议的rust实现库quiche-master作为rust的编译目标
如何在64系统的rust下编译32位的rust程序或库
0.已离线安装64位的rust
https://forge.rust-lang.org/infra/other-installation-methods.html
x86_64-unknown-linux-gnu ==》linux x86_64
1.rust离线安装包默认没有自带rustup工具。
2.从rust离线安装包中安装脚本进行卸载已安装的rust
3.配置代理后(内网情况下)
根据https://wiki.jikexueyuan.com/index.php/project/rust-primer/install/rustup.html
#curl https://sh.rustup.rs -sSf | sh
进行安装后,查看/.cargo/bin/下生成的有rustup,但没有加到环境变量,手动添加/.cargo/bin目录到$PATH
4.#rustup target list查看支持的目标系统工具链
包括i686-unknown-linux-gnu
5#rustup target add i686-unknown-linux-gnu
即可编译出32位的库
6.查到资料说明
https://forge.rust-lang.org/release/platform-support.html
这个i686其实是i386的子集,x86_64才指64位,几年前遇到过这个坑。。。
i686-unknown-linux-gnu 32-bit Linux (kernel 2.6.32+, glibc 2.11+)
编译支持androud的armv7失败,ring构建失败
root@gw:/home/gw/opensource/quiche-master# cargo build --release --target=armv7-linux-androideabi
Compiling ring v0.16.15
error: failed to run custom build command for `ring v0.16.15`
Caused by:
process didn't exit successfully: `/home/gw/opensource/quiche-master/target/release/build/ring-2a4e78684a0d9f36/build-script-build` (exit code: 101)
--- stdout
OPT_LEVEL = Some("3")
TARGET = Some("armv7-linux-androideabi")
HOST = Some("x86_64-unknown-linux-gnu")
CC_armv7-linux-androideabi = None
CC_armv7_linux_androideabi = None
TARGET_CC = None
CC = None
CFLAGS_armv7-linux-androideabi = None
CFLAGS_armv7_linux_androideabi = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
--- stderr
ENV CARGO=/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo
ENV CARGO_CFG_TARGET_ARCH=arm
ENV CARGO_CFG_TARGET_ENDIAN=little
ENV CARGO_CFG_TARGET_ENV=
ENV CARGO_CFG_TARGET_FAMILY=unix
ENV CARGO_CFG_TARGET_OS=android
ENV CARGO_CFG_TARGET_POINTER_WIDTH=32
ENV CARGO_CFG_TARGET_VENDOR=unknown
ENV CARGO_CFG_UNIX=
ENV CARGO_FEATURE_ALLOC=1
ENV CARGO_FEATURE_DEFAULT=1
ENV CARGO_FEATURE_DEV_URANDOM_FALLBACK=1
ENV CARGO_FEATURE_ONCE_CELL=1
ENV CARGO_HOME=/root/.cargo
ENV CARGO_MAKEFLAGS=--jobserver-fds=6,7 -j --jobserver-auth=6,7 -j
ENV CARGO_MANIFEST_DIR=/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15
ENV CARGO_MANIFEST_LINKS=ring-asm
ENV CARGO_PKG_AUTHORS=Brian Smith <brian@briansmith.org>
ENV CARGO_PKG_DESCRIPTION=Safe, fast, small crypto using Rust.
ENV CARGO_PKG_HOMEPAGE=
ENV CARGO_PKG_NAME=ring
ENV CARGO_PKG_REPOSITORY=https://github.com/briansmith/ring
ENV CARGO_PKG_VERSION=0.16.15
ENV CARGO_PKG_VERSION_MAJOR=0
ENV CARGO_PKG_VERSION_MINOR=16
ENV CARGO_PKG_VERSION_PATCH=15
ENV CARGO_PKG_VERSION_PRE=
ENV CLUTTER_IM_MODULE=ibus
ENV COLORTERM=truecolor
ENV DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
ENV DEBUG=true
ENV DESKTOP_SESSION=ubuntu
ENV DISPLAY=:0
ENV GDMSESSION=ubuntu
ENV GNOME_DESKTOP_SESSION_ID=this-is-deprecated
ENV GNOME_SHELL_SESSION_MODE=ubuntu
ENV GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/c8c38971_6ce7_4928_ae74_272ca5b8b8e1
ENV GNOME_TERMINAL_SERVICE=:1.84
ENV GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
ENV GTK_IM_MODULE=ibus
ENV GTK_MODULES=gail:atk-bridge
ENV HOME=/root
ENV HOST=x86_64-unknown-linux-gnu
ENV IM_CONFIG_PHASE=1
ENV INVOCATION_ID=00b350efd00843679b35fd7c3471b32c
ENV JOURNAL_STREAM=9:29157
ENV LANG=en_US.UTF-8
ENV LC_ADDRESS=zh_CN.UTF-8
ENV LC_IDENTIFICATION=zh_CN.UTF-8
ENV LC_MEASUREMENT=zh_CN.UTF-8
ENV LC_MONETARY=zh_CN.UTF-8
ENV LC_NAME=zh_CN.UTF-8
ENV LC_NUMERIC=zh_CN.UTF-8
ENV LC_PAPER=zh_CN.UTF-8
ENV LC_TELEPHONE=zh_CN.UTF-8
ENV LC_TIME=zh_CN.UTF-8
ENV LD_LIBRARY_PATH=/home/gw/opensource/quiche-master/target/release/deps:/home/gw/opensource/quiche-master/target/release:/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib:/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib
ENV LESSCLOSE=/usr/bin/lesspipe %s %s
ENV LESSOPEN=| /usr/bin/lesspipe %s
ENV LOGNAME=gw
ENV LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
ENV MAIL=/var/mail/root
ENV MANAGERPID=986
ENV NUM_JOBS=1
ENV OLDPWD=/home/gw/opensource
ENV OPT_LEVEL=3
ENV OUT_DIR=/home/gw/opensource/quiche-master/target/armv7-linux-androideabi/release/build/ring-3ad48afdb7ba8743/out
ENV PATH=/root/.cargo/bin:/root/.cargo/bin:/home/gw/opensource/code/usr/share/code/bin:/home/gw/opensource/code/usr/share/code/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
ENV PROFILE=release
ENV PWD=/home/gw/opensource/quiche-master
ENV QT4_IM_MODULE=ibus
ENV QT_ACCESSIBILITY=1
ENV QT_IM_MODULE=ibus
ENV RUSTC=rustc
ENV RUSTDOC=rustdoc
ENV RUSTUP_HOME=/root/.rustup
ENV RUSTUP_TOOLCHAIN=stable-x86_64-unknown-linux-gnu
ENV RUST_BACKTRACE=full
ENV RUST_RECURSION_COUNT=1
ENV SESSION_MANAGER=local/gw:@/tmp/.ICE-unix/1308,unix/gw:/tmp/.ICE-unix/1308
ENV SHELL=/bin/bash
ENV SHLVL=2
ENV SSH_AGENT_PID=1194
ENV SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
ENV SSLKEYLOGFILE=/home/gw/opensource/ssl.log
ENV SSL_CERT_DIR=/usr/lib/ssl/certs
ENV SSL_CERT_FILE=/usr/lib/ssl/certs/ca-certificates.crt
ENV TARGET=armv7-linux-androideabi
ENV TERM=xterm-256color
ENV USER=gw
ENV USERNAME=gw
ENV VTE_VERSION=6001
ENV WINDOWPATH=2
ENV XAUTHORITY=/run/user/1000/gdm/Xauthority
ENV XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg
ENV XDG_CURRENT_DESKTOP=ubuntu:GNOME
ENV XDG_DATA_DIRS=/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
ENV XDG_MENU_PREFIX=gnome-
ENV XDG_RUNTIME_DIR=/run/user/1000
ENV XDG_SESSION_CLASS=user
ENV XDG_SESSION_DESKTOP=ubuntu
ENV XDG_SESSION_TYPE=x11
ENV XMODIFIERS=@im=ibus
ENV _=/root/.cargo/bin/cargo
running "arm-linux-androideabi-clang" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=armv7-linux-androideabi" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-DNDEBUG" "-c" "-o/home/gw/opensource/quiche-master/target/armv7-linux-androideabi/release/build/ring-3ad48afdb7ba8743/out/aesv8-armx-linux32.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/aesv8-armx-linux32.S"
thread 'main' panicked at 'failed to execute ["arm-linux-androideabi-clang" "-O3" "-DANDROID" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=armv7-linux-androideabi" "-I" "include" "-Wall" "-Wextra" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-fstack-protector" "-g3" "-DNDEBUG" "-c" "-o/home/gw/opensource/quiche-master/target/armv7-linux-androideabi/release/build/ring-3ad48afdb7ba8743/out/aesv8-armx-linux32.o" "/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/aesv8-armx-linux32.S"]: No such file or directory (os error 2)', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/build.rs:661:9
stack backtrace:
0: 0x55cd292c2e75 - backtrace::backtrace::libunwind::trace::h396c07d2071b43af
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
1: 0x55cd292c2e75 - backtrace::backtrace::trace_unsynchronized::h7aa0e4bb23d9c158
at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
2: 0x55cd292c2e75 - std::sys_common::backtrace::_print_fmt::hd15ac5d4adcd355b
at src/libstd/sys_common/backtrace.rs:78
3: 0x55cd292c2e75 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hec5354be8ccc3ecc
at src/libstd/sys_common/backtrace.rs:59
4: 0x55cd292e7eac - core::fmt::write::h3d34909eeb4f225b
at src/libcore/fmt/mod.rs:1076
5: 0x55cd292bed23 - std::io::Write::write_fmt::h1da287b3de55ed16
at src/libstd/io/mod.rs:1537
6: 0x55cd292c56d0 - std::sys_common::backtrace::_print::h4d206838e1ace354
at src/libstd/sys_common/backtrace.rs:62
7: 0x55cd292c56d0 - std::sys_common::backtrace::print::h1f778e9940ee5977
at src/libstd/sys_common/backtrace.rs:49
8: 0x55cd292c56d0 - std::panicking::default_hook::{{closure}}::h704403a56cbf5783
at src/libstd/panicking.rs:198
9: 0x55cd292c541c - std::panicking::default_hook::ha4567a10dec4ef8d
at src/libstd/panicking.rs:218
10: 0x55cd292c5d07 - std::panicking::rust_panic_with_hook::h88a1f16ec8a7bb20
at src/libstd/panicking.rs:486
11: 0x55cd292c590b - rust_begin_unwind
at src/libstd/panicking.rs:388
12: 0x55cd292c587b - std::panicking::begin_panic_fmt::ha3ac96e620978458
at src/libstd/panicking.rs:342
13: 0x55cd2928ff4f - build_script_build::run_command::{{closure}}::h8bd40e6903e06c8a
at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/build.rs:661
14: 0x55cd2928fea1 - core::result::Result<T,E>::unwrap_or_else::h8bb85ddef76a0b16
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2/src/libcore/result.rs:853
15: 0x55cd2928fea1 - build_script_build::run_command::h41690cabf8ae2c20
at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/build.rs:660
16: 0x55cd2928bc6b - build_script_build::compile::hb31e1fb88f14263a
at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/build.rs:532
17: 0x55cd2928bc6b - build_script_build::build_library::{{closure}}::hffcac157e418beed
at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/build.rs:467
18: 0x55cd2928bc6b - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once::h365486b3cec0106a
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2/src/libcore/ops/function.rs:285
19: 0x55cd29293dcc - core::option::Option<T>::map::hefe3084a378bad8c
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2/src/libcore/option.rs:458
20: 0x55cd29293dcc - <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::next::h1f923b13e8b79229
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2/src/libcore/iter/adapters/mod.rs:849
21: 0x55cd29293dcc - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter::hfd7a5be4b4b36aa9
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2/src/liballoc/vec.rs:2076
22: 0x55cd2928eb49 - <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter::h27af843d5da48576
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2/src/liballoc/vec.rs:1978
23: 0x55cd2928eb49 - core::iter::traits::iterator::Iterator::collect::h74580549e85c7667
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2/src/libcore/iter/traits/iterator.rs:1671
24: 0x55cd2928eb49 - build_script_build::build_library::h862e12fd951e7228
at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/build.rs:463
25: 0x55cd2928eb49 - build_script_build::build_c_code::{{closure}}::h5cc69fb918d1582f
at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/build.rs:436
26: 0x55cd2928eb49 - <core::slice::Iter<T> as core::iter::traits::iterator::Iterator>::for_each::h52d2ac066b1fd6f0
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2/src/libcore/slice/mod.rs:3361
27: 0x55cd2928eb49 - build_script_build::build_c_code::h5fc1596408ff55f1
at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/build.rs:435
28: 0x55cd2928eb49 - build_script_build::ring_build_rs_main::h8cb4ff53a0c7978d
at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/build.rs:298
29: 0x55cd2928eb49 - build_script_build::main::h7b30b726b2aec87e
at /root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/build.rs:255
30: 0x55cd292922c3 - std::rt::lang_start::{{closure}}::h3b9abd58f6dfa8e2
at /rustc/5c1f21c3b82297671ad3ae1e8c942d2ca92e84f2/src/libstd/rt.rs:67
31: 0x55cd292c60d8 - std::rt::lang_start_internal::{{closure}}::h6d21eebfa4beaf70
at src/libstd/rt.rs:52
32: 0x55cd292c60d8 - std::panicking::try::do_call::h560a27b87db38b9c
at src/libstd/panicking.rs:297
33: 0x55cd292c60d8 - std::panicking::try::h453d4afd696011f9
at src/libstd/panicking.rs:274
34: 0x55cd292c60d8 - std::panic::catch_unwind::h211d02671f23030f
at src/libstd/panic.rs:394
35: 0x55cd292c60d8 - std::rt::lang_start_internal::h464df2bbf46c7e7c
at src/libstd/rt.rs:51
36: 0x55cd29291f28 - main
37: 0x7fe5fdaa00b3 - __libc_start_main
38: 0x55cd2928b19e - _start
39: 0x0 - <unknown>
看报错似乎缺少ndk和/root/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated/aesv8-armx-linux32.S 文件
实际上文件是存在的,ndk确实没有安装。
找了下ndk的安装无果。
如下好想又是说目前还不支持armv7 32位的工具链。
https://rust-lang.github.io/rustup-components-history/arm-linux-androideabi.html
但按照如下说发好像又是可以自己安装配置。。。
https://github.com/rust-lang/rustup#cross-compilation
交叉编译
Rust 支持大量平台。对于许多这样的平台,Rust Project会发布标准库的二进制发行版,而对于某些完整的编译器也会发布。rustup轻松访问所有这些对象。
首次安装工具链时,rustup仅安装主机平台的标准库-即当前正在运行的体系结构和操作系统。要编译到其他平台,必须安装其他目标平台。这是通过rustup target add命令完成的。例如,要添加Android目标:
$ rustup target添加arm-linux-androideabi
信息:为'arm-linux-androideabi'下载组件'rust-std'信息:为'arm-linux-androideabi'
安装组件'rust-std'
随着arm-linux-androideabi目标上安装然后你可以通过传递和Cargo构建Android --target标志,如cargo build --target=arm-linux-androideabi。
请注意,rustup target add仅为给定目标安装Rust标准库。通常还需要交叉编译的其他工具,尤其是链接器。例如,要交叉编译到Android,必须安装Android NDK。将来,rustup 还将提供安装NDK组件的帮助。
要为不是默认工具链的工具链安装目标,请使用--toolchain参数rustup target add,如下所示:
$ rustup target add --toolchain <工具链> <目标> ...
要查看可用目标的列表,请参见rustup target list。要删除先前添加的目标,,rustup target remove。
Android NDK
独立工具链
https://developer.android.com/ndk/guides/standalone_toolchain?hl=zh-cn
独立工具链的版本确认和安装以及配置还不清楚。
关于ring的报错查看如下文档
https://github.com/briansmith/ring
有如下说明:
安卓系统 ARMv7,Aarch64 适用于ARMv7的* ring * Android是使用针对API级别18(Android 4.3+)的SDK版本26在CI中内置的;使用相应的系统映像在模拟器中对其进行测试。适用于AArch64的* ring * Android是使用针对API级别21(Android 5.0)的SDK版本26在CI中内置的。
另外,如下地址仓库可能是github上的某个历史版本ring-2a4e78684a0d9f36该版本编译找的文件所在目录名称已变更,即便如此,
https://s0docs0rs.icopy.site/crate/ring/0.14.6/source/pregenerated/aesv8-armx-ios64.S
实际在查看quiche最新依赖的ring版本信息时
root@gw:~/.cargo/registry/src/github.com-1ecc6299db9ec823/ring-0.16.15/pregenerated# ls -la aesv8-armx-linux32.S
-rw-r--r-- 1 root root 9270 7月 5 17:16 aesv8-armx-linux32.S
该目录下是有该文件的。
而quiche依赖的libev
https://github.com/enki/libev
未找到明显arm for android的指导。
以上是查到的信息