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

Experiment: disable -fPIC and relro #12582

Merged
merged 52 commits into from
Jul 17, 2024
Merged

Experiment: disable -fPIC and relro #12582

merged 52 commits into from
Jul 17, 2024

Conversation

Jarred-Sumner
Copy link
Collaborator

What does this PR do?

If we remove fpic and relro, we will shave off about 6 MB from the build on Linux

2.2% 1.99Mi 2.0% 1.99Mi .rela.dyn
4.9% 4.48Mi 4.1% 4.10Mi .data.rel.ro

I'm not confident we can remove fpic. It might break napi. If this build fails then let's re-enable fpic and just relro.

  47.5%  43.7Mi  44.0%  43.7Mi    .text
  42.2%  38.8Mi  39.0%  38.8Mi    .rodata
   0.0%       0   7.4%  7.35Mi    .bss
   4.9%  4.48Mi   4.1%  4.10Mi    .data.rel.ro
   2.4%  2.23Mi   2.2%  2.23Mi    .eh_frame
   2.2%  1.99Mi   2.0%  1.99Mi    .rela.dyn
   0.4%   413Ki   0.4%   413Ki    .eh_frame_hdr
   0.0%       0   0.4%   387Ki    .tbss
   0.2%   211Ki   0.2%   211Ki    .data
   0.1%   116Ki   0.1%   116Ki    .gcc_except_table
   0.0%  13.7Ki   0.0%  13.6Ki    .dynsym
   0.0%  9.67Ki   0.0%  9.61Ki    .rela.plt
   0.0%  8.21Ki   0.0%  8.14Ki    .dynstr
   0.0%  6.48Ki   0.0%  6.42Ki    .plt
   0.0%  3.80Ki   0.0%  3.80Ki    [LOAD #2 [R]]
   0.0%  3.34Ki   0.0%  3.27Ki    .got
   0.0%  3.31Ki   0.0%  3.25Ki    .got.plt
   0.0%  3.03Ki   0.0%  1.11Ki    [19 Others]
   0.0%  1.20Ki   0.0%  1.14Ki    .gnu.version
   0.0%  1.11Ki   0.0%  1.05Ki    .gnu.hash
   0.0%     592   0.0%     528    .dynamic
 100.0%  92.0Mi 100.0%  99.3Mi    TOTAL

Note that Node does not enable relro. This is node's:

❯ bloaty (which node)
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  47.6%  43.2Mi  47.5%  43.2Mi    .rodata
  36.8%  33.4Mi  36.7%  33.4Mi    .text
   8.1%  7.32Mi   8.0%  7.32Mi    .dynstr
   3.6%  3.22Mi   3.5%  3.22Mi    .eh_frame
   2.2%  2.03Mi   2.2%  2.03Mi    .dynsym
   0.8%   709Ki   0.8%   709Ki    .eh_frame_hdr
   0.6%   537Ki   0.6%   537Ki    .gnu.hash
   0.0%       0   0.2%   208Ki    .bss
   0.2%   173Ki   0.2%   173Ki    .gnu.version
   0.2%   153Ki   0.2%   153Ki    .data
   0.0%  12.0Ki   0.0%  12.0Ki    .rela.plt
   0.0%  10.4Ki   0.0%       0    [Unmapped]
   0.0%  8.00Ki   0.0%  8.00Ki    .plt
   0.0%  7.04Ki   0.0%  6.76Ki    .init_array
   0.0%  6.14Ki   0.0%  4.91Ki    [17 Others]
   0.0%  4.27Ki   0.0%  4.27Ki    .got
   0.0%  3.97Ki   0.0%  3.97Ki    [LOAD #3 [RX]]
   0.0%  3.91Ki   0.0%  3.91Ki    .gcc_except_table
   0.0%       0   0.0%  2.60Ki    [LOAD #6 [RW]]
   0.0%  2.00Ki   0.0%       0    [ELF Section Headers]
   0.0%  1.95Ki   0.0%  1.95Ki    .rela.dyn
 100.0%  90.8Mi 100.0%  91.0Mi    TOTAL

How did you verify your code works?

Copy link
Contributor

github-actions bot commented Jul 16, 2024

@Jarred-Sumner, your commit has failing tests :(

🪟💻 3 failing tests Windows x64 baseline

  • test/cli/install/registry/bun-install-registry.test.ts 1 failing
  • test/js/bun/spawn/spawn.test.ts SIGKILL
  • test/js/node/child_process/child_process.test.ts 1 failing

🪟💻 2 failing tests Windows x64

  • test/cli/install/registry/bun-install-registry.test.ts 2 failing
  • test/js/node/child_process/child_process.test.ts 1 failing

View logs

Copy link
Contributor

github-actions bot commented Jul 16, 2024

clang-tidy nits are fixed! Thank you.

@Jarred-Sumner
Copy link
Collaborator Author

current:

bloaty  /Users/jarred/Downloads/bun-linux-x64\ 16/bun --demangle=full -w
    FILE SIZE        VM SIZE
 --------------  --------------
  48.5%  43.4Mi  44.8%  43.4Mi    .text
  44.4%  39.6Mi  41.0%  39.6Mi    .rodata
   0.0%       0   7.6%  7.35Mi    .bss
   4.4%  3.94Mi   3.9%  3.77Mi    .data.rel.ro
   2.0%  1.80Mi   1.9%  1.80Mi    .eh_frame
   0.0%       0   0.4%   387Ki    .tbss
   0.4%   330Ki   0.3%   330Ki    .eh_frame_hdr
   0.2%   211Ki   0.0%       0    .data
   0.0%  23.1Ki   0.0%  23.1Ki    .gcc_except_table
   0.0%  13.6Ki   0.0%  13.6Ki    .dynsym
   0.0%  9.61Ki   0.0%  9.61Ki    .rela.plt
   0.0%  8.13Ki   0.0%  8.13Ki    .dynstr
   0.0%  6.42Ki   0.0%  6.42Ki    .plt
   0.0%  3.26Ki   0.0%  3.26Ki    [LOAD #2 [R]]
   0.0%  3.25Ki   0.0%  3.25Ki    .got.plt
   0.0%  2.59Ki   0.0%  2.44Ki    [17 Others]
   0.0%  2.41Ki   0.0%  2.41Ki    .got
   0.0%  2.06Ki   0.0%       0    [ELF Section Headers]
   0.0%  1.99Ki   0.0%  1.99Ki    .rela.dyn
   0.0%  1.14Ki   0.0%  1.14Ki    .gnu.version
   0.0%  1.07Ki   0.0%  1.07Ki    .gnu.hash
 100.0%  89.4Mi 100.0%  96.7Mi    TOTAL

@Jarred-Sumner
Copy link
Collaborator Author

Jarred-Sumner commented Jul 17, 2024

Outcome: we still have data.rel.ro, but we did get 2.9 MB smaller

The blocker now is mostly Zig's lack of PIC support - ziglang/zig#17430

    FILE SIZE
 --------------
  48.2%  42.9Mi    .text
  44.6%  39.7Mi    .rodata
   4.3%  3.86Mi    .data.rel.ro
   2.2%  1.93Mi    .eh_frame
   0.4%   356Ki    .eh_frame_hdr
   0.2%   210Ki    .data
   0.0%  23.1Ki    .gcc_except_table
   0.0%  13.5Ki    .dynsym
   0.0%  9.54Ki    .rela.plt
   0.0%  8.07Ki    .dynstr
   0.0%  6.38Ki    .plt
   0.0%  3.39Ki    [LOAD #2 [R]]
   0.0%  3.23Ki    .got.plt
   0.0%  2.42Ki    .got
   0.0%  2.06Ki    .rela.dyn
   0.0%  2.06Ki    [ELF Section Headers]
   0.0%  1.37Ki    [16 Others]
   0.0%  1.13Ki    .gnu.version
   0.0%  1.07Ki    .gnu.hash
   0.0%     560    [ELF Program Headers]
   0.0%     480    .dynamic
 100.0%  89.1Mi    TOTAL

@Jarred-Sumner Jarred-Sumner merged commit 34e493f into main Jul 17, 2024
@Jarred-Sumner Jarred-Sumner deleted the jarred/fpie branch July 17, 2024 09:33
@7heMech
Copy link

7heMech commented Jul 17, 2024

@Jarred-Sumner will replacing libicu make it even smaller?

paperdave pushed a commit that referenced this pull request Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants