2. 对于linux-gnu目标平台类型的则自Rust1.19后则可通过传递-C target-feature=+crt-static参数给rustc编译器。其./.cargo/config.toml文件类似于: [build] target = "riscv64gc-unknown-linux-gnu" [target.riscv64gc-unknown-linux-gnu] rustflags = ["-C", "target-feature=+crt-static"] linker = ...
首先,需要指定 i686-pc-windows target 和/SUBSYSTEM:CONSOLE,5.01链接选项,这样生成的可执行文件才能...
rustflags = ["-C", "target-feature=+crt-static"] 如下:如果用DIE软件来检测出你写出的RUST程序的依赖,加载exe文件后,点Import,发现只依赖系统自带的dll动态链接库,因此客户不用再安装其他dll了。
1[target.x86_64-unknown-linux-musl]2linker ="rust-lld"3rustflags = ["-C","linker-flavor=ld.lld"]45[target.x86_64-pc-windows-msvc]6rustflags = ["-C","target-feature=+crt-static"] 编译打包 1cross build --release --target=x86_64-unknown-linux-musl 其他: 在某天早上还能成功编译,到...
rustc -Ctarget-feature=+crt-static main.rs 1. 或者 set -Ctarget-feature=+crt-static cd project cargo project --target i686-pc-windows-msvc 1. 2. 3. 编译xp目标rust程序推荐方法 把如下代码保存在bat脚本文件中,打开脚本后,直接使用cargo build或者cargo run就可以了 ...
这也支持+crt-static和-crt-staticfeature 来控制 静态C 运行时链接. 每个target 和target-cpu都有一组默认启用的 features 。 tune-cpu 这会指示rustc为特定处理器调度代码。这不会影响兼容性(指令集或 ABI),但应该会使得代码在所选定的 CPU 上更有效率。
Problem The value of target_feature = "crt-static" can be controlled in rustc with -Ctarget-feature=+crt-static or -Ctarget-feature=-crt-static. Some targets have this enabled by default, but that doesn't seem to be propagated to CARGO_C...
rustflags = ["-Ctarget-feature=+crt-static"] 之后使用cargo build --release --target mipsel-unknown-linux-musl编译即可 注意:因为用了静态链接,编译出的二进制文件会很大,一个Hello world都可能会有4MB,但是路由器给的存储空间一般也不会很大,所以之后就需要对项目进行一些优化。
target_feature键值对选项,用于设置当前编译目标的可用平台特性。示例值:"avx" "avx2" "crt-static" "rdrand" "sse" "sse2" "sse4.1"有关可用特性的更多细节,请参见 target_feature属性。此外,编译器还为 target_feature选项提供了一个额外的 crt-static特性,它表示需要链接一个可用的静态C运行时。
# CompileFROM rust:1.75.0-alpine3.18AS compiler RUN apk add-q--update-cache--no-cache build-base openssl-dev cmake WORKDIR/ENV RUSTFLAGS="-C target-feature=-crt-static"COPY..RUNset-eux;\ cargo build--release# RunFROM alpine:3.18RUN apk update--quiet \&&apk add-q--no-cache libgcc ti...