microsoft / microsoft/SizeBench

Attempt to detect incorrect/improveable incorrect linker flags

Open
#50 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
175
Forks
20
PR merge metrics
No merged PRs in 30d

Description

Is your feature request related to a problem? Please describe.

I use CMake RelWithDebInfo builds - I don't use Release as I'm never going to distribute something if I don't have debug symbols for it :)

It seems that this disables some of the usual release mode linker flags, in particular:

  • /INCREMENTAL:NO - SizeBench does warn about this
  • /OPT:ICF
  • /OPT:REF

Describe the solution you'd like

It seems like SizeBench could make a reasonable guess that /OPT:ICF or /OPT:REF were not passed, and suggest I enable them.

Describe alternatives you've considered

doing it with sizebench without 'magic' :)

I eventually found all of these flags through looking through SizeBench's reports; for example, the lack of /OPT:REF was obvious from this:

Image

I'm only using one of those WinRT classes, so the majority of them should not be in my executable. After everything else, finding this and turning on /OPT:REF cut my executable from 3MB to 1.5MB

Additional context

Thank you so much for this incredible tool. I read the 2021 blog post last night, and this morning I easily cut my executable from 12.5MB to 1.5MB.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing SizeBench’s existing warning for /INCREMENTAL:NO and the reports that expose linker flags. Determine how /OPT:ICF and /OPT:REF can be detected or reasonably inferred for CMake RelWithDebInfo builds, then verify that the resulting suggestions distinguish enabled and missing flags.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, csharp
Domain
build-system, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.