Cleanly setting C compiler options when building RTS

Alp Mestanogullari alp at
Thu Jul 11 09:55:00 UTC 2019

That's indeed one Hadrian solution. An alternative one (requires 
'master' from yesterday) is:

$ hadrian/ --flavour=... " += 
-fsanitize=address -fsanitize=undefined"

Note that I'm not quite sure who between GHC and the C compiler gets 
invoked to build the RTS. If it's GHC, then you'll need to replace 
'builder Cc' in Matthew's solution with 'builder (Ghc CompileCWithGhc)', 
or with the key-value style approach:

$ hadrian/ --flavour=... "stage1.rts.ghc.c.opts += 
-fsanitize=address -fsanitize=undefined"

You can find more about how both of those settings mechanisms work here:

... once GitLab works again. :-)

Until then:

On 11/07/2019 11:49, Matthew Pickering wrote:
> Hi Siddharth,
> The correct way is to create a custom flavour with something like the
> following in.
> grts = quickFlavour { name = "grts", args = args quickFlavour <>
> (builder Cc ? package rts ? arg "-g3" <> arg "-O0") }
> Cheers,
> Matt
> On Thu, Jul 11, 2019 at 10:20 AM Siddharth Bhat <siddu.druid at> wrote:
>> Hello all,
>> I was interested in building the GHC RTS with GCC's AddressSanitizer and Ubsan enabled.
>> What I want to do very specifically is to pass "-fsanitize=address -fsanitize=undefined" when compiling the RTS.
>> What's the "correct" way to set this up in the build system? Is there a configure flag? Do I need to change the Shake script?
>> Thanks,
>> ~Siddharth
>> _______________________________________________
>> ghc-devs mailing list
>> ghc-devs at
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at

Alp Mestanogullari, Haskell Consultant
Well-Typed LLP,

Registered in England and Wales, OC335890
118 Wymering Mansions, Wymering Road, London, W9 2NF, England

More information about the ghc-devs mailing list