• she/her

Principal engineer at Mercury. I've authored the Dhall configuration language, the Haskell for all blog, and countless packages and keynote presentations.

I'm a midwife to the hidden beauty in everything.

💖 @wiredaemon


discord
Gabriella439
discord server
discord.gg/XS5ZDZ8nnp
location
bay area
private page
cohost.org/newmoon

I'm documenting this on the off chance that it helps someone else who runs in the same problem

So a pretty common idiom for CI goes something like this:

  • Build with optimizations disabled in CI (so that you can merge faster)
  • Build with optimizations enabled for the production build

Now suppose that is Haskell project where you use -O0 to disable optimizations for CI and -O2 to enable optimizations for the production build. Furthermore, suppose that in both cases you build with -Werror

You'd think that if your build passes CI with -Werror -O0 then then the production build should also succeed with -Werror -O2, but you would be wrong!!!

As it turns out, there's a Haskell warning which is only enabled when you enable optimizations (i.e. -O1 or -O2), which looks like this:

    • Ignoring unusable UNPACK pragma
        on the third argument of 'Foo'
    • In the definition of data constructor 'Foo'
      In the data type declaration for 'Foo'

So you can run into situations where this warning can fail the production build because CI will miss it when building with -O0.

However, as I learned today, there is a way to selectively enable the one optimization that would trigger this warning while still disable other optimizations: you set the -fno-omit-interface-pragmas flag (and you still keep the -O0)

This gives you the best of both worlds: you still disable almost all optimizations, but you catch the above warning in CI so that it doesn't fail the production build.

For more details, see:

Note: Also, in case you were wondering, there is not flag to selectively enable or disable this warning. I checked.


You must log in to comment.

in reply to @fullmoon's post: