Skip to content

strip does not work on rust 1.70 binaries #112187

Open
@kiap

Description

@kiap

Compiling any code with the standard library as shared.

env RUSTFLAGS="-C prefer-dynamic" cargo build -v --release

strip -s target/release/hello

I expected to see this happen:

the stripped version must have a smaller executable and have all symbols removed

Instead, this happened:

the size of the executable increased to 2.1 M and all symbols were there

rustc --version --verbose:

rustc 1.70.0 (90c541806 2023-05-31)
binary: rustc
commit-hash: 90c541806f23a127002de5b4038be731ba1458ca
commit-date: 2023-05-31
host: x86_64-unknown-linux-gnu
release: 1.70.0
LLVM version: 16.0.2

compiling as static or with musl works correctly

Worked as expected in all previous releases

I suspect LLVM 16 is the cause but cannot pinpoint the cause really.

tested on:

  1. Red Hat Enterprise Linux release 8.8 (Ootpa)
  2. CentOS Linux release 7.9.2009 (Core)
  3. Rocky Linux 8.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    -Cprefer-dynamicCodegen option: Prefer dynamic linking to static linking.C-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions