Skip to content

Commit

Permalink
nimble: strip comment section from binary
Browse files Browse the repository at this point in the history
After the Zig 0.9.0 release, compiling with the current snapcraft Zig
adds 30 KB to the comment section, repeating the clang version many
times.

Before this commit:

    $ readelf -p .comment ./configlet

    String dump of section '.comment':
      [     0]  clang version 13.0.1 (git@github.com:ziglang/zig-bootstrap.git 74211dd7f7e7174a2027641dfcfdb3fc5df62f0c)
      [...] (repeat for 30 KB)
      [  7969]  clang version 13.0.1 (git@github.com:ziglang/zig-bootstrap.git 74211dd7f7e7174a2027641dfcfdb3fc5df62f0c)
      [  79d2]  Linker: LLD 13.0.1 (git@github.com:ziglang/zig-bootstrap.git 74211dd7f7e7174a2027641dfcfdb3fc5df62f0c)

Binary size profile before this commit:

       FILE SIZE        VM SIZE
    --------------  --------------
     75.2%   368Ki  64.5%   368Ki    .text
      0.0%       0  19.6%   111Ki    .bss
     18.2%  89.1Ki  15.6%  89.1Ki    .rodata
      6.2%  30.6Ki   0.0%       0    .comment
      0.2%     816   0.1%     824    .data
      0.1%     640   0.0%       0    [ELF Section Headers]
      0.1%     392   0.1%     392    [ELF Program Headers]
      0.0%      64   0.0%      64    [ELF Header]
      0.0%      63   0.0%       0    .shstrtab
      0.0%       8   0.0%       8    .got
      0.0%       8   0.0%       8    [LOAD #1 [R]]
      0.0%       4   0.0%       3    .fini
      0.0%       3   0.0%       3    .init
    100.0%   489Ki 100.0%   570Ki    TOTAL

Let's just strip the comment section.
  • Loading branch information
ee7 committed Dec 21, 2021
1 parent f59296c commit 1c5af8d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion configlet.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ when defined(linux):
after build:
if existsEnv("GITHUB_ACTIONS") and findExe("zigcc").len > 0:
echo "stripping binary..."
exec "strip -s ./configlet"
exec "strip -s -R .comment ./configlet"

0 comments on commit 1c5af8d

Please sign in to comment.