Adding explicit optimization flags for interaction with GHC#11716
Adding explicit optimization flags for interaction with GHC#11716zlonast wants to merge 2 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 |
| -- 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"]
| | -- | @-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.
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 |
b1b2abe to
8d95791
Compare
1fcf15e to
9b81d5e
Compare
|
And here we have internet problems with |
|
@zlonast do you not have permisions to restart CI jobs? we should look into it if so. |
|
@ulysses4ever I don't have that permission. I'd also like to be able to link an issue to a pr-s |
|
@zlonast can you try now? |
|
@ulysses4ever Thank you :) |
f525a2e to
3cc9e18
Compare
3cc9e18 to
4f0f103
Compare
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.