编译我的程序'zagir'后,release文件夹的大小超过200MiB,这对我编写的程序来说太荒谬了。所以,我试着检查一下'zagir'可执行文件是否只是孤立地运行了。
但令人困惑的是,release文件夹还包含libzagir.rlib文件以及.d文件和一堆其他文件夹。
Cargo.toml
[package]
authors = ["Sharad Chand"]
name = "zagir"
version = "0.1.0"
[dependencies]
bcrypt = "0.1.3"
dotenv = "0.10.1"
image = "0.17.0"
log = "0.3.8"
r2d2 = "0.7.3"
r2d2-diesel = "0.16.0"
rand = "0.3.16"
rocket = "0.3.2"
rocket_codegen = "0.3.2"
serde = "1.0.11"
serde_derive = "1.0.11"
serde_json = "1.0.2"
validator = "0.6.0"
validator_derive = "0.6.0"
[dependencies.bigdecimal]
features = ["serde"]
version = "0.0.10"
[dependencies.chrono]
features = ["serde"]
version = "0.4.0"
[dependencies.diesel]
features = [
"mysql",
"chrono",
"unstable",
"numeric",
"huge-tables",
]
version = "0.16.0"
[dependencies.diesel_codegen]
features = ["mysql"]
version = "0.16.0"
[dependencies.rocket_contrib]
features = ["handlebars_templates"]
version = "0.3.2"
[dependencies.uuid]
features = ["v4"]
version = "0.4"
答案 0 :(得分:11)
可执行文件实际上需要目标目录中的哪些文件
除了可执行文件本身之外,它们都没有。默认情况下,Rust会生成静态链接的二进制文件。
其他文件仅仅是由Cargo维护的构建工件,以便更有效地重建代码。它们包括你的依赖项之类的东西。
您可能会找到的某些文件的非详尽示例:
*.d
- 与Makefile兼容的依赖列表*.rlib
- Rust库文件。包含依赖项的已编译代码build
- 用作临时空间的构建脚本的目录deps
- 您编译的依赖项examples
- 来自examples
目录incremental
- 增量编译缓存的目录*-{hash}
- 来自cargo test
其中一些内容已记录在案in the Cargo source code。