-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust: release binary #353
Comments
Rust 构建+安装+发布 二进制程序:
Rust 构建:
[profile.dev]
# Must always use panic = "abort" to avoid needing to define the unstable eh_personality lang item.
panic = "abort"
[profile.release]
opt-level = "z" # Optimize for size.
lto = true # Enable Link Time Optimization
codegen-units = 1 # Reduce number of codegen units to increase optimizations.
panic = "abort" # Abort on panic
strip = true # Automatically strip symbols from the binary.
cargo build --release
# cd root:
cd project-root/
# build:
docker build -t mini-docker-rust .
# run:
docker run mini-docker-rust . |
Rust 安装本地构建二进制文件:
# cd:
cd project-root
# install local build:
cargo install --path .
# 查看安装列表:
cargo install --list
|
Rust 发布二进制包:
发布到 Github Release:
发布到 Crates.io:
# 发布:
cargo publish
# 撤回发布: (问题包, 禁止新项目引用)
cargo yank --vers 1.0.1
使用 GoReleaser 发布 Rust:
brew install goreleaser/tap/goreleaser
|
fix errors:error 1:
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package: ~better-rs/learn-rs/crates/rs-scripts/Cargo.toml
workspace: ~/better-rs/learn-rs/Cargo.toml
|
Rust 交叉编译:
1. 基于 Docker 编译:
$ docker run -v /var/run/docker.sock:/var/run/docker.sock -v .:/project \
-w /project my/development-image:tag cross build --target mips64-unknown-linux-gnuabi64
docker pull clux/muslrust:stable
# build:
docker run -v $PWD:/volume --rm -t clux/muslrust:stable cargo build --release Windows:Linux:2. 本机编译:
# install:
cargo install -f cross
# build:
$ cross build --target aarch64-unknown-linux-gnu
$ cross build --target x86_64-pc-windows-gnu
$ cross build --target armv7-unknown-linux-gnueabihf
# install:
brew install FiloSottile/musl-cross/musl-cross
brew install mingw-w64
rustup toolchain add x86_64-unknown-linux-musl
rustup target add x86_64-unknown-linux-musl
rustup target list
cargo build --target x86_64-unknown-linux-musl
cargo build --release --target=x86_64-unknown-linux-musl
cargo build --release --target=x86_64-pc-windows-msvc
|
Rust 跨平台:-> % rustup target list
aarch64-apple-darwin (installed)
aarch64-apple-ios
aarch64-apple-ios-sim
aarch64-fuchsia
aarch64-linux-android
aarch64-pc-windows-msvc
aarch64-unknown-linux-gnu
aarch64-unknown-linux-musl (installed)
aarch64-unknown-none
aarch64-unknown-none-softfloat
# 添加:
rustup target add aarch64-unknown-linux-gnu
rustup target add aarch64-unknown-linux-musl
# 模拟 x86_64:
rustup target add x86_64-apple-darwin
cargo build --target x86_64-apple-darwin
cargo run --target x86_64-apple-darwin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
related:
The text was updated successfully, but these errors were encountered: