Skip to content

zig cc combines --strip-all and --strip-debug #23823

@Bownairo

Description

@Bownairo

Zig Version

0.14.0

Steps to Reproduce and Observed Behavior

zig cc handles --strip-all and --strip-debug as the same, so stripping is all or nothing.


With gcc, there are three distinct strip configurations:

$ cargo build
$ file target/debug/dummy
target/debug/dummy: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=430838d8f4b10293753bed30eddfd37193914521, for GNU/Linux 3.2.0, with debug_info, not stripped

$ RUSTFLAGS="-C link-args=-Wl,--strip-debug" cargo build
$ file target/debug/dummy
target/debug/dummy: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=070bef503e2d64752c27ea7831b1b51e2601f4df, for GNU/Linux 3.2.0, not stripped

$ RUSTFLAGS="-C link-args=-Wl,--strip-all" cargo build
$ file target/debug/dummy
target/debug/dummy: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=f21f0136208958ff93512fecc20b59bcbb576f65, for GNU/Linux 3.2.0, stripped

With zig cc, there are only two:

$ cargo build
$ file target/debug/dummy
target/debug/dummy: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.0.0, with debug_info, not stripped

$ RUSTFLAGS="-C link-args=-Wl,--strip-debug" cargo build
$ file target/debug/dummy
target/debug/dummy: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.0.0, stripped

$ RUSTFLAGS="-C link-args=-Wl,--strip-all" cargo build
$ file target/debug/dummy
target/debug/dummy: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.0.0, stripped

Expected Behavior

--strip-all and --strip-debug should be distinct, so that symbols can be preserved without debug_info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions