Skip to content

-staticlib is broken on GHC 8.4.3 on Linux under certain conditions

When compiling this simple program:

main = pure ()

Using the -staticlib flag on GHC 8.4.3 on Linux, it panics if using a certain toolchain:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty
$ /opt/ghc/8.4.3/bin/ghc -fforce-recomp -staticlib Bug.hs
[1 of 1] Compiling Main             ( Bug.hs, Bug.o )
Linking Bug.a ...
ghc: panic! (the 'impossible' happened)
  (GHC version 8.4.3 for x86_64-unknown-linux):
        Data.Binary.Get.runGet at position 27462987: Invalid archive header end marker
CallStack (from HasCallStack):
  error, called at libraries/binary/src/Data/Binary/Get.hs:351:5 in binary-0.8.5.1:Data.Binary.Get

I say "certain toolchain" since I am able to reproduce this issue on Ubuntu 14.04, but not 18.04:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04 LTS
Release:        18.04
Codename:       bionic
$ /opt/ghc/8.4.3/bin/ghc -fforce-recomp -staticlib Bug.hs
[1 of 1] Compiling Main             ( Bug.hs, Bug.o )
Linking Bug.a ...

This issue does not occur on GHC 8.2 and earlier:

$ /opt/ghc/8.2.2/bin/ghc -staticlib Bug.hs
[1 of 1] Compiling Main             ( Bug.hs, Bug.o )
Linking Bug.a ...
Static archive creation only supported on Darwin/OS X/iOS

Commit b8f33bc6 allowed the use of -staticlib on all platforms. angerman, do you know what might be happening here?

Edited by Ryan Scott
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information