Adding explicit optimization flags for interaction with GHC#11716
Adding explicit optimization flags for interaction with GHC#11716zlonast wants to merge 8 commits into
Conversation
f9a78f0 to
cb0d98b
Compare
374f8bf to
50720f6
Compare
840a960 to
c0b8ed7
Compare
|
How strange, I don't know what the problem is with |
| in FieldDescr | ||
| name | ||
| ( \f -> case f of | ||
| Flag NoOptimisation -> Disp.text "False" |
There was a problem hiding this comment.
I suggest abandoning the display as Bool flags
| | str == "0" -> ParseOk [] (Flag NoOptimisation) | ||
| | str == "1" -> ParseOk [] (Flag NormalOptimisation) | ||
| | str == "2" -> ParseOk [] (Flag MaximumOptimisation) | ||
| | lstr == "false" -> ParseOk [caseWarning name] (Flag NoOptimisation) |
There was a problem hiding this comment.
I suggest you stop throwing case sensitive warning
There was a problem hiding this comment.
@jappeace @leana8959 I think you're knowledgeable about this topic. Perhaps you know why Bool type is a case-sensitive type?
instance Parsec Bool where
parsec = P.munch1 isAlpha >>= postprocess
where
postprocess str
| str == "True" = pure True
| str == "False" = pure False
| lstr == "true" = parsecWarning PWTBoolCase caseWarning *> pure True
| lstr == "false" = parsecWarning PWTBoolCase caseWarning *> pure False
| otherwise = fail $ "Not a boolean: " ++ str
where
lstr = map toLower str
caseWarning =
"Boolean values are case sensitive, use 'True' or 'False'."
There was a problem hiding this comment.
It's worth noting that the current change doesn't remove warnings, but I think they're unnecessary in the cabal ecosystem.
There was a problem hiding this comment.
hmm, I don't know.
it's introduced here:
92f018c#r185301031
(note that github helpfully collapses the line with my comment pointing it out, so you've to expand legacy to see it)
appears to be copied to other blocks as well.
There was a problem hiding this comment.
I'd like to know more about the vibe, it looks like the rest of the syntax allows for case-insensitive variants.
There was a problem hiding this comment.
I think you can drop the warnings, appears to be a backwards compat scheme:
the previous commit I found via UI but now since you asked for vibes I used a claude instance:
If you're interested this is the prompts I used: https://gist.github.com/jappeace/5e428936b633b2c6fed1c691d2e1c71e
| -- optimisation or requests a different level elsewhere. | ||
| sourceOptimization :: OptimisationLevel -> [String] | ||
| sourceOptimization = \case | ||
| NoOptimisation -> ["-O0"] |
There was a problem hiding this comment.
I propose to put a clear flag instead of nothing NoOptimisation -> [], which logically fits the situation NoOptimisation -> ["-O0"]
| "n" | ||
| (show NoOptimisation, Flag . flagToOptimisationLevel) | ||
| ( \f -> case f of | ||
| Flag NoOptimisation -> [] |
There was a problem hiding this comment.
render before: nothing -O -O2
render after: -O0 -O1 -O2
| ( \f -> case f of | ||
| Flag NoDebugInfo -> [] | ||
| Flag MinimalDebugInfo -> [Just "1"] | ||
| Flag NormalDebugInfo -> [Nothing] |
There was a problem hiding this comment.
render before: nothing -g1 -g -g3
render before: nothing -1 - -3
render after: -g0 -g1 -g2 -g3
| | -- | @-O2@ | ||
| GhcMaximumOptimisation | ||
| | -- | e.g. @-Odph@ | ||
| GhcSpecialOptimisation String |
There was a problem hiding this comment.
.. ghc-flag:: -O⟨n⟩
:shortdesc: Any -On where n > 2 is the same as -O2.
:type: dynamic
:reverse: -O0
:category: optimization-levels
.. index::
single: optimise; aggressively
Any -On where n > 2 is the same as -O2.
c0b8ed7 to
f8ee456
Compare
1a43ec1 to
a9db604
Compare
d87d3e0 to
65da48e
Compare
|
I always try to pass flags, but it's better not to do this when linking, since for some reason cabal hooks die 🤔 @sheaf Could you please tell me if I'm trying to pass extra flags when linking. Is it my fault? Or is it Because I can't always pass flags, I had to put a lot of The only test where this appears is https://github.com/haskell/cabal/actions/runs/25755559764/job/75643108252 |
Ah yes. I think this is GHC bug #16981/#24773. I think what's happening is that, with this patch, we start to compile the Let me investigate and suggest a fix, but I imagine it will simply involve implementing the changes described in GHC proposal #732. |
|
I have managed to reproduce the issue with commit f8ee456, but only on Linux (not on Windows). I tried to mitigate by moving things to the top-level but this didn't fix the isssue. So I think this is a new (different) bug in GHC. I will try to minimise and report it. Do you know which GHC versions are affected; is it only GHC 9.14 and not prior versions? |
I don't know. There's only one complex hooks test here. CI crashed consistently on all three platforms with ghc 9.14.1. |
|
CI windows are also failed c0b8ed7 |
my failed attempt: I suspect you can easy to catch it with change |
|
I wrote a reproducer and found that the issue has been fixed on the GHC 10.0 branch; I assume by this commit. I would recommend adding the following to the {-# LANGUAGE CPP #-}
-- Disable optimisations to work around GHC bug #16981 (fixed with GHC 10.0)
#if __GLASGOW_HASKELL__ < 1000
{-# OPTIONS_GHC -O0 #-}
#endif |
Cabal now adds explicit
-optc-O2,-optcxx-O2and-opta-O2flags wheninvoking GHC for C, C++ and assembler source files that are built with
optimization. These explicit flags are only inserted when the user has not
already provided an optimization flag (
-O,-O0,-O1,-O2,-O3),so that existing user choices are never overridden or duplicated.
Here are some examples
Example 1
no leakage between modules
to
expected behavior
Example 2
to
Example 3
implicit behavior
-g0to
but
because
I don't want to contribute to all cabal tests.
Example 4
to
because it's local optimization
Fan fact cabal codebase is all in OptimiSation and OptimiZation
Template Α: This PR modifies behaviour or interface
Include the following checklist in your PR:
significance: significantin the changelog file.