guedou/cargo-strip

cargo-strip not stripping

brainstorm opened this issue · 8 comments

While trying to strip a 15MB binary from this project, I'm getting the following puzzling behavior:

$ file target/x86_64-unknown-linux-musl/release/bootstrap
target/x86_64-unknown-linux-musl/release/bootstrap: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped
$ cargo-strip -t x86_64-unknown-linux-musl
"/htsget-aws/target/x86_64-unknown-linux-musl/release/bootstrap" stripped (reduced by 0 kB)!
$ file target/x86_64-unknown-linux-musl/release/bootstrap
target/x86_64-unknown-linux-musl/release/bootstrap: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped

Does the system strip managed to reduce the size of the binary? Could you share the target/x86_64-unknown-linux-musl/release/bootstrap for example with https://send.firefox.com?

This is strange. On my system, strip reduced the binary size from 15965016 bytes to 10449816 bytes.

Weird, which host system are you running on? Not sure it matters, but I'm on OSX... also which cmdline did you use?

On macOS, the strip command will only strip Mach-O binaries, not ELF. That is why calling it does not reduce the size of your binary.

I am currently working on a solution that will strip an ELF binary without calling the strip command. That will likely fix #5.

FTR, this is also why the "Build & run cargo-strip on the ARM binary" CI test does not reduce the size of the binary.

Does this not work on ARM binaries? I am trying to strip the ARM from an Ubuntu workstation? The target platform is arm-unknown-linux-musleabihf

@dwhiteddsoft on Linux, it works fine. Does cargo strip --target arm-unknown-linux-musleabihf work OK?

This is from the build machine

Screen Shot 2021-06-29 at 11 50 58 PM