rust - 为什么我的 Release模式 Rust 可执行文件包含带有绝对路径名的字符串?

标签 rust exe compiler-optimization rust-cargo

我刚刚构建了我的第一个 Rust hello world 程序,然后是一个 websocket 客户端,编译时使用:

cargo build --release

使用十六进制编辑器在 hello_cargo\target\release 中搜索 216 KB 可执行文件我看到了:

C:\\Users\\GirkovArpa\\.cargo\\registry\\src\\github.com-1ecd2293db9ea513\\embedded-websocket-0.3.0\\src\\lib.rs
C:\\Users\\GirkovArpa\\.cargo\\registry\\src\\github.com-1ecd2293db9ea513\\heapless-0.5.5\\src\\string.rs
C:\\Users\\GirkovArpa\\.cargo\\registry\\src\\github.com-1ecd2293db9ea513\\rand-0.7.3\\src\\rngs\\thread.rs
C:\\Users\\GirkovArpa\\Documents\\GitHub\\hello_cargo\\target\\release\\deps\\hello_cargo.pdb

还有一些像这样的字符串。这是在运行 strip hello_cargo.exe 之后。

如何避免这种情况?

最佳答案

这对于分布式编译/缓存来说是个大问题。我建议关注 this issue .他们建议使用 --remap-path-prefix。文档 here .

People are working on first class support for this.

关于rust - 为什么我的 Release模式 Rust 可执行文件包含带有绝对路径名的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62056753/

相关文章:

rust - macro_rules 是一个普通的宏吗?

Java:以管理员身份运行

wix - 如何使用 wix bootstraper 更改 exe 文件的详细信息?

c - 编译器(通过链接时优化)如何处理快速返回的函数(提前退出路径)?

c - GCC 编译器选项 : which set of enabled options is correct?

编译器标志更改代码行为(O2、Ox)

web-services - 为什么我无法从 Internet 访问这个 Rust 简单服务器?

generics - 有没有办法表达具有不同生命周期界限的 "same"泛型类型?

rust - 如何在不进行手动解析的情况下从可能包含剩余字符的字符串中解析 float ?

windows-installer - 确定 MSI/EXE 是否支持某些标志/参数?