Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--strip should emit no debug info and result in a stripped binary according to binutils #351

Closed
andrewrk opened this issue May 1, 2017 · 5 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented May 1, 2017

--strip is supposed to not emit debug info, but it still does.

Additionally if you use file on the binary it should say "stripped" and it should not say "not stripped".

@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label May 1, 2017
@andrewrk andrewrk added this to the 0.2.0 milestone May 1, 2017
@andrewrk
Copy link
Member Author

andrewrk commented Jan 3, 2018

Postponing to 0.3.0. We only have to solve this issue in the self-hosted compiler.

@andrewrk andrewrk modified the milestones: 0.2.0, 0.3.0 Jan 3, 2018
@andrewrk andrewrk modified the milestones: 0.3.0, 0.4.0 Feb 28, 2018
@andrewrk andrewrk modified the milestones: 0.4.0, 0.5.0 Feb 22, 2019
@andrewrk
Copy link
Member Author

Strip now works fairly well but it does not strip everything. It's no longer a bug.

@andrewrk andrewrk changed the title --strip doesn't work --strip still emits some debug info Aug 16, 2019
@andrewrk andrewrk removed the bug Observed behavior contradicts documented or intended behavior label Aug 16, 2019
@andrewrk andrewrk changed the title --strip still emits some debug info --strip should emit no debug info Aug 16, 2019
@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. stage1 The process of building from source via WebAssembly and the C backend. labels Aug 16, 2019
@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Aug 16, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Oct 23, 2019
@artob
Copy link

artob commented May 27, 2020

This bit me just now when packaging my project for Debian. Namely, the last stage (linting) of debuild shows an error due to the shared libraries produced by Zig 0.6.0 with --strip still indicating that they are unstripped in the ELF information (scroll to the end of the output from file):

$ zig build-lib --name foo -target x86_64-linux-gnu -dynamic --strip

$ file libfoo.so.0.0.0
libfoo.so.0.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped

$ strip libfoo.so.0.0.0

$ file libfoo.so.0.0.0
libfoo.so.0.0.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, stripped

The Lintian error is unstripped-binary-or-object:

E: libfoo0: unstripped-binary-or-object usr/lib/x86_64-linux-gnu/libfoo.so.0.0.0
N: 
N:    The package installs an unstripped binary or object file.
N:    
N:    Please note, that shared libraries have to be stripped with the
N:    --strip-unneeded option.
N:    
N:    Refer to Debian Policy Manual section 10.1 (Binaries) and Debian Policy
N:    Manual section 10.2 (Libraries) for details.
N:    
N:    Severity: important, Certainty: certain
N:    
N:    Check: binaries, Type: binary, udeb

This will affect all shared libraries produced by Zig when packaged for Debian or Ubuntu. The workaround for now is to either add an explicit spurious strip(1) invocation after Zig builds the library, or else add a Lintian override to suppress the error.

@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 9, 2020
@andrewrk andrewrk added frontend Tokenization, parsing, AstGen, Sema, and Liveness. and removed stage1 The process of building from source via WebAssembly and the C backend. labels Oct 9, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Jun 4, 2021
@andrewrk andrewrk changed the title --strip should emit no debug info --strip should emit no debug info and result in a stripped binary according to binutils Jun 9, 2021
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 Nov 21, 2021
@Ristovski
Copy link
Contributor

Ristovski commented Jun 8, 2022

This appears to be fixed.

$ zig build-exe test.zig -femit-bin=striptest
$ file striptest
striptest: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, with debug_info, not stripped
$ zig build-exe test.zig -femit-bin=striptest --strip
$ file striptest
striptest: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped

0.10.0-dev.2562+61844b6bd

@andrewrk
Copy link
Member Author

andrewrk commented Jun 8, 2022

Fixed by 366c767

@andrewrk andrewrk closed this as completed Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

3 participants