Consistent Binary Compilation: Removing Username from Final Build with remap-path-prefix

I've created a simple helloworld project in Rust with tokio and serde as dependencies. After compiling, I found that my username appears in the resultant binary. To address this, I tried using remap-cwd-prefix and remap-path-prefix flags. My compile command is as follows:

RUSTFLAGS="-Zremap-cwd-prefix=. --remap-path-prefix=/Users/foo=bar" cargo build

With this, I was able to eliminate the username from the libhelloworld.rlib file. However, the username still appears in the helloworld binary(using the grep command). Additionally, I observed that libserde_derive-xxx.dylib and libtokio_macros-xxx.dylib also contain references to my username.

This inconsistency in compilation results poses challenges for me, as I'm aiming for stable build outputs across different users and machines. I believed that the remap-path-prefix option would help ensure this consistency.

Have I overlooked something in my approach? Any guidance or suggestions on achieving a consistent compile result would be greatly appreciated.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.