Skip to main content

ghc-musl Part 5: lsupg Executable Sizes

While I am building fully static executables with multiple versions of GHC, it would be interesting to compare the file sizes! Haskell executable sizes are notoriously huge. I have noticed that the sizes have increased over time, but I would like to see some concrete numbers.

I am comparing the executables for lsupg. I am using a local branch that contains changes related to using ghc-musl to build the static executables, but there have been no changes to the code since commit 05c0a8d (current develop HEAD).

The lsupg executables have the following file sizes when built using Stack.

GHC Version Dynamic (bytes) Static (bytes)
8.8.4 13,049,400 13,358,592
8.10.7 14,651,328 14,960,360
9.0.2 27,377,064 28,697,696
9.2.2 16,026,216 29,473,672

Chart

The lsupg executables have the following file sizes when built using Cabal and then stripped.

GHC Version Dynamic (bytes) Static (bytes)
8.8.4 15,706,008 16,015,200
8.10.7 15,694,784 15,999,720
9.0.2 27,533,000 28,849,312
9.2.2 16,046,696 29,494,152

I get slightly larger file sizes when I build using Cabal. There must be a difference in ghc (or strip) options being used…

The size of the dynamic executable when using GHC 9.2.2 is smaller than expected, with both Stack and Cabal! I do not know why. Has there been an improvement in GHC 9.2 (that only benefits dynamic executables)? I do not have time to pull on this thread at the moment. If anybody knows about this, please email me!

Previous releases of lsupg have all been compiled using GHC 8.10. It looks like the file size doubles when I use GHC 9.0 or GHC 9.2! Releases are xz-compressed, but the compressed sizes are proportional to the uncompressed sizes (still double). Since the functionality is the same, perhaps I should release executables compiled with GHC 8.8…

There are various things I can do to decrease the size of the executable. I can experiment with compilation options, such as -split-sections. I can also consider using UPX, but I do not think it is appropriate for this utility.