haskell/cabal — pull request #2043 by edsko (2014-08-18 12:02:35+00:00)
Title: Include ghc -optc-FOO options when calling gcc

**NOTE:** I am not sure whether the below is the right approach. Submitting a pull request mostly so we have a discrete proposal :)

Motivation: Cabal translates `c-options` to `-optc` arguments to `ghc`, and then relies on `ghc` to call the right C compiler with the right arguments. However, if `ghc-options` contains options that affect the C compiler (`-optc-FOO`), these options are _not_ passed to `ghc` and hence don't make it to the C compiler. As a concrete example, for a `.cabal` section that looks like

```
executable test-sse
main-is: Main.hs
build-depends: base >=4.5 && <4.8
default-language: Haskell2010
c-sources: test.c
ghc-options: -optc-msse4
```

Cabal will not pass `optc-msse4` to `ghc` and hence the C compiler won't be passed `-sse4`. One might perhaps argue that the user should have used `c-options` instead of `ghc-options`, but since `Cabal` relies on `ghc` to call the compiler, it seems that any ghc options that affect how the C compiler is invoked should be passed along. Moreover, it is confusing to users (and, perhaps more importantly, automated tools) that options that work if we pass them directly to `ghc` may not work if we put them in `ghc-options`.