[Haskell-cafe] With cabal.project, what's the story about warning and -Werror compiler flags?

Mikolaj Konarski mikolaj at well-typed.com
Sun Aug 28 19:19:30 UTC 2022


Let me CC to cabal-devel at haskell.org.

On Sun, Aug 28, 2022 at 3:39 PM Nicolas Trangez <ikke at nicolast.be> wrote:
>
> All,
>
> Working on some project, I was wondering about best-practices and
> community standards for compiler flags now that `cabal.project` is a
> thing.
>
> Before, I put compiler warning flags like `-Wall` in `Ghc-Options` and
> `Cc-Options` in `mypackage.cabal` files. The use of `-Werror`, whilst
> (IMHO) useful in development and CI was a bit more troublesome, since
> having those in `package.cabal` (not under a default-disabled flag) was
> frowned upon (and even not allowed by Hackage?)
>
> Having these options in `mypackage.cabal` always felt slightly weird,
> since they are in no way required for a package to function: they're
> developer options, not user/consumer options. Where `-wavx2` could be a
> required `Cc-Options` setting for a package to build/function, `-Wall`
> is not.
>
> With the advent of `cabal.project`, it seems to me this is the ideal
> place to put developer flags: from what I understood, `cabal.project`
> doesn't influence sdist/Hackage distribution, and hence could contain
> all kind of GHC and C compiler flags that are useful during development
> but not required for a package to build/function, including `-Werror`
> (if desired by the project authors).
>
> Does this sound like a reasonable stance?
>
> If it is, I did run into a couple of issues getting things to actually
> work. Whilst putting `Ghc-Options` in a `Package mypackage` section in
> `cabal.project` seems to work, I'm unable to achieve the same resulsts
> for C compiler invocations. Presumably there's a `Gcc-Options` setting
> one can use (which is also generated in `cabal.project.local` by `cabal
> configure --gcc-options ...`). However, in testing, it appears said
> compiler optons are only passed to GCC when compiling, e.g., a HSC2HS
> file, but not when compiling a C file part of a `C-Sources` setting
> (whilst `Cc-Options` in `mypackage.cabal` are).
>
> Is there some discrepancy between what can be done from `cabal.project`
> vs. `mypackage.cabal`? Is this intentional? Am I trying to accomplish
> something that isn't/shouldn't be supported by Cabal in the first
> place?
>
> Cheers,
>
> Nicolas
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.


More information about the cabal-devel mailing list