Skip to content

-fstrip removes exported symbols when building executable #22339

Closed as not planned
@noctice007

Description

@noctice007

Summary

When using the -fstrip flag with zig build-exe, the exported symbols are removed from the resulting binary, which seems unexpected.

Steps to Reproduce

  1. Create a file main.zig with the following content:
    export fn foo() void {}
    pub fn main() void {}
  2. Run the following command:
    zig build-exe main.zig -fstrip
    
  3. Attempt to disassemble the foo function in the resulting binary:
    objdump main --disassemble=foo
    

Observed Behavior

Output

main:     file format elf64-x86-64


Disassembly of section .text:
<blank>

The foo section is not found, indicating that the -fstrip flag removed the exported symbol.

Expected Behavior

The foo function, being explicitly marked as export, should remain accessible in the binary, even when -fstrip is used

Environment

  • Zig version: 0.13.0
  • OS: Arch linux x86_64

Additional Note

If this behavior is intentional, clarification in the documentation would be helpful. If not, this might be a bug with -fstrip implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionNo questions on the issue tracker, please.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions