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