Skip to content

Commit 2762851

Browse files
authored
Merge branch 'master' into wip/9.4-eval-plugin
2 parents 4541fef + 00f4e61 commit 2762851

File tree

9 files changed

+64
-43
lines changed

9 files changed

+64
-43
lines changed

.github/actions/setup-build/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ inputs:
2323
runs:
2424
using: "composite"
2525
steps:
26-
- uses: haskell/actions/setup@v2
26+
- uses: haskell/actions/setup@v2.3.3
2727
id: HaskEnvSetup
2828
with:
2929
ghc-version : ${{ inputs.ghc }}

.github/workflows/bench.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
example: ['cabal', 'lsp-types']
111111

112112
steps:
113-
- uses: haskell/actions/setup@v2
113+
- uses: haskell/actions/setup@v2.3.3
114114
with:
115115
ghc-version : ${{ matrix.ghc }}
116116
cabal-version: ${{ matrix.cabal }}

.github/workflows/caching.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,15 @@ jobs:
8282
matrix:
8383
# This list of GHC (including the "exclude" list) versions must match
8484
# to the list of GHC versions specified in 'test.yml'
85-
ghc: [ "9.4.3"
86-
, "9.4.2"
85+
ghc: [ "9.4.4"
8786
, "9.2.5"
88-
, "9.2.4"
8987
, "9.0.2"
9088
, "8.10.7"
9189
]
9290
os: [ "ubuntu-latest"
9391
, "macOS-latest"
9492
, "windows-latest"
9593
]
96-
exclude:
97-
# Exclude until https://github.com/haskell/actions/issues/129
98-
# is resolved.
99-
- os: windows-latest
100-
ghc: '9.4.3' # Excluded because github action cannot install it
101-
- os: windows-latest
102-
ghc: '9.2.5'
103-
10494
steps:
10595
- uses: actions/checkout@v3
10696

.github/workflows/test.yml

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,33 +60,20 @@ jobs:
6060
# **don't forget**
6161
# to update the ghc versions in 'caching.yml'.
6262
matrix:
63-
ghc: [ "9.4.3"
64-
, "9.4.2"
63+
ghc: [ "9.4.4"
6564
, "9.2.5"
66-
, "9.2.4"
67-
, "9.2.3"
6865
, "9.0.2"
6966
, "8.10.7"
7067
]
7168
os: [ "ubuntu-latest"
7269
, "macOS-latest"
7370
, "windows-latest"
7471
]
75-
# don't build these versions
76-
# they are broken for good reasons, e.g. compiler is bugged
77-
# on that platform.
78-
exclude:
79-
# Exclude until https://github.com/haskell/actions/issues/129
80-
# is resolved.
81-
- os: windows-latest
82-
ghc: '9.4.3' # Excluded because github action cannot install it
83-
- os: windows-latest
84-
ghc: '9.2.5'
8572
# Mark which GHC versions on which platform we want to test.
8673
include:
8774
# only test supported ghc major versions
8875
- os: ubuntu-latest
89-
ghc: '9.4.3'
76+
ghc: '9.4.4'
9077
test: true
9178
- os: ubuntu-latest
9279
ghc: '9.2.5'
@@ -98,12 +85,10 @@ jobs:
9885
ghc: '8.10.7'
9986
test: true
10087
- os: windows-latest
101-
ghc: '9.4.2'
88+
ghc: '9.4.4'
10289
test: true
103-
# Test on 9.2.4 until https://github.com/haskell/actions/issues/129
104-
# is resolved. Then switch to 9.2.5
10590
- os: windows-latest
106-
ghc: '9.2.4'
91+
ghc: '9.2.5'
10792
test: true
10893
- os: windows-latest
10994
ghc: '9.0.2'
@@ -181,11 +166,11 @@ jobs:
181166
name: Test hls-pragmas-plugin
182167
run: cabal test hls-pragmas-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-pragmas-plugin --test-options="$TEST_OPTS"
183168

184-
- if: matrix.test && matrix.ghc != '9.4.2' && matrix.ghc != '9.4.3'
169+
- if: matrix.test && matrix.ghc != '9.4.4'
185170
name: Test hls-eval-plugin
186171
run: cabal test hls-eval-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-eval-plugin --test-options="$TEST_OPTS"
187172

188-
- if: matrix.test && matrix.ghc != '9.2.4' && matrix.ghc != '9.2.5' && matrix.ghc != '9.4.2' && matrix.ghc != '9.4.3'
173+
- if: matrix.test && matrix.ghc != '9.2.5' && matrix.ghc != '9.4.4'
189174
name: Test hls-haddock-comments-plugin
190175
run: cabal test hls-haddock-comments-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-haddock-comments-plugin --test-options="$TEST_OPTS"
191176

@@ -205,7 +190,7 @@ jobs:
205190
name: Test hls-fourmolu-plugin
206191
run: cabal test hls-fourmolu-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-fourmolu-plugin --test-options="$TEST_OPTS"
207192

208-
- if: matrix.test && matrix.ghc != '9.2.4' && matrix.ghc != '9.2.5' && matrix.ghc != '9.4.2' && matrix.ghc != '9.4.3'
193+
- if: matrix.test && matrix.ghc != '9.2.5' && matrix.ghc != '9.4.4'
209194
name: Test hls-tactics-plugin test suite
210195
run: cabal test hls-tactics-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-tactics-plugin --test-options="$TEST_OPTS"
211196

@@ -229,7 +214,7 @@ jobs:
229214
name: Test hls-hlint-plugin test suite
230215
run: cabal test hls-hlint-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-hlint-plugin --test-options="$TEST_OPTS"
231216

232-
- if: matrix.test && matrix.ghc != '9.0.1' && matrix.ghc != '9.0.2' && matrix.ghc != '9.2.4' && matrix.ghc != '9.2.5' && matrix.ghc != '9.4.2' && matrix.ghc != '9.4.3'
217+
- if: matrix.test && matrix.ghc != '9.0.2' && matrix.ghc != '9.2.5' && matrix.ghc != '9.4.4'
233218
name: Test hls-stan-plugin test suite
234219
run: cabal test hls-stan-plugin --test-options="$TEST_OPTS" || LSP_TEST_LOG_COLOR=0 LSP_TEST_LOG_MESSAGES=true LSP_TEST_LOG_STDERR=true cabal test hls-stan-plugin --test-options="$TEST_OPTS"
235220

.hlint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
within:
5656
- Development.IDE.Core.Shake
5757
- Development.IDE.GHC.Util
58+
- Development.IDE.Core.FileStore
5859
- Development.IDE.Plugin.CodeAction.Util
5960
- Development.IDE.Graph.Internal.Database
6061
- Development.IDE.Graph.Internal.Paths

ghcide/src/Development/IDE/Core/Compile.hs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import Data.Time (UTCTime (..))
7070
import Data.Tuple.Extra (dupe)
7171
import Data.Unique as Unique
7272
import Debug.Trace
73-
import Development.IDE.Core.FileStore (resetInterfaceStore)
73+
import Development.IDE.Core.FileStore (resetInterfaceStore, shareFilePath)
7474
import Development.IDE.Core.Preprocessor
7575
import Development.IDE.Core.RuleTypes
7676
import Development.IDE.Core.Shake
@@ -435,6 +435,30 @@ tcRnModule hsc_env tc_helpers pmod = do
435435
-- anywhere. So we zero it out.
436436
-- The field is not serialized or deserialised from disk, so we don't need to remove it
437437
-- while reading an iface from disk, only if we just generated an iface in memory
438+
--
439+
440+
441+
442+
-- | See https://github.com/haskell/haskell-language-server/issues/3450
443+
-- GHC's recompilation avoidance in the presense of TH is less precise than
444+
-- HLS. To avoid GHC from pessimising HLS, we filter out certain dependency information
445+
-- that we track ourselves. See also Note [Recompilation avoidance in the presence of TH]
446+
filterUsages :: [Usage] -> [Usage]
447+
#if MIN_VERSION_ghc(9,3,0)
448+
filterUsages = filter $ \case UsageHomeModuleInterface{} -> False
449+
_ -> True
450+
#else
451+
filterUsages = id
452+
#endif
453+
454+
-- | Mitigation for https://gitlab.haskell.org/ghc/ghc/-/issues/22744
455+
shareUsages :: ModIface -> ModIface
456+
shareUsages iface = iface {mi_usages = usages}
457+
where usages = map go (mi_usages iface)
458+
go usg@UsageFile{} = usg {usg_file_path = fp}
459+
where !fp = shareFilePath (usg_file_path usg)
460+
go usg = usg
461+
438462

439463
mkHiFileResultNoCompile :: HscEnv -> TcModuleResult -> IO HiFileResult
440464
mkHiFileResultNoCompile session tcm = do
@@ -444,7 +468,7 @@ mkHiFileResultNoCompile session tcm = do
444468
details <- makeSimpleDetails hsc_env_tmp tcGblEnv
445469
sf <- finalSafeMode (ms_hspp_opts ms) tcGblEnv
446470
iface' <- mkIfaceTc hsc_env_tmp sf details ms tcGblEnv
447-
let iface = iface' { mi_globals = Nothing } -- See Note [Clearing mi_globals after generating an iface]
471+
let iface = iface' { mi_globals = Nothing, mi_usages = filterUsages (mi_usages iface') } -- See Note [Clearing mi_globals after generating an iface]
448472
pure $! mkHiFileResult ms iface details (tmrRuntimeModules tcm) Nothing
449473

450474
mkHiFileResultCompile
@@ -486,7 +510,7 @@ mkHiFileResultCompile se session' tcm simplified_guts = catchErrs $ do
486510
let !partial_iface = force (mkPartialIface session details simplified_guts)
487511
final_iface' <- mkFullIface session partial_iface
488512
#endif
489-
let final_iface = final_iface' {mi_globals = Nothing} -- See Note [Clearing mi_globals after generating an iface]
513+
let final_iface = final_iface' {mi_globals = Nothing, mi_usages = filterUsages (mi_usages final_iface')} -- See Note [Clearing mi_globals after generating an iface]
490514

491515
-- Write the core file now
492516
core_file <- case mguts of
@@ -1440,7 +1464,8 @@ loadInterface session ms linkableNeeded RecompilationInfo{..} = do
14401464
regenerate linkableNeeded
14411465

14421466
case (mb_checked_iface, recomp_iface_reqd) of
1443-
(Just iface, UpToDate) -> do
1467+
(Just iface', UpToDate) -> do
1468+
let iface = shareUsages iface'
14441469
details <- liftIO $ mkDetailsFromIface sessionWithMsDynFlags iface
14451470
-- parse the runtime dependencies from the annotations
14461471
let runtime_deps

ghcide/src/Development/IDE/Core/FileStore.hs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module Development.IDE.Core.FileStore(
1818
getModTime,
1919
isWatchSupported,
2020
registerFileWatches,
21+
shareFilePath,
2122
Log(..)
2223
) where
2324

@@ -28,6 +29,8 @@ import Control.Exception
2829
import Control.Monad.Extra
2930
import Control.Monad.IO.Class
3031
import qualified Data.ByteString as BS
32+
import qualified Data.HashMap.Strict as HashMap
33+
import Data.IORef
3134
import qualified Data.Text as T
3235
import qualified Data.Text.Utf16.Rope as Rope
3336
import Data.Time
@@ -76,6 +79,7 @@ import qualified Language.LSP.Types as LSP
7679
import qualified Language.LSP.Types.Capabilities as LSP
7780
import Language.LSP.VFS
7881
import System.FilePath
82+
import System.IO.Unsafe
7983

8084
data Log
8185
= LogCouldNotIdentifyReverseDeps !NormalizedFilePath
@@ -297,3 +301,17 @@ isWatchSupported = do
297301
, Just True <- _dynamicRegistration
298302
-> True
299303
| otherwise -> False
304+
305+
filePathMap :: IORef (HashMap.HashMap FilePath FilePath)
306+
filePathMap = unsafePerformIO $ newIORef HashMap.empty
307+
{-# NOINLINE filePathMap #-}
308+
309+
shareFilePath :: FilePath -> FilePath
310+
shareFilePath k = unsafePerformIO $ do
311+
atomicModifyIORef' filePathMap $ \km ->
312+
let new_key = HashMap.lookup k km
313+
in case new_key of
314+
Just v -> (km, v)
315+
Nothing -> (HashMap.insert k k km, k)
316+
{-# NOINLINE shareFilePath #-}
317+

ghcide/src/Development/IDE/GHC/Compat.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ module Development.IDE.GHC.Compat(
4343
myCoreToStgExpr,
4444
#endif
4545

46+
Usage(..),
47+
4648
FastStringCompat,
4749
bytesFS,
4850
mkFastStringByteString,
@@ -168,9 +170,9 @@ import GHC.Runtime.Context (icInteractiveModule)
168170
import GHC.Unit.Home.ModInfo (HomePackageTable,
169171
lookupHpt)
170172
#if MIN_VERSION_ghc(9,3,0)
171-
import GHC.Unit.Module.Deps (Dependencies(dep_direct_mods))
173+
import GHC.Unit.Module.Deps (Dependencies(dep_direct_mods), Usage(..))
172174
#else
173-
import GHC.Unit.Module.Deps (Dependencies(dep_mods))
175+
import GHC.Unit.Module.Deps (Dependencies(dep_mods), Usage(..))
174176
#endif
175177
#else
176178
import GHC.CoreToByteCode (coreExprToBCOs)

hie-compat/hie-compat.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ library
3333
if flag(ghc-lib) && impl(ghc < 9)
3434
build-depends: ghc-lib < 9.0
3535
else
36-
build-depends: ghc, ghc-boot
36+
build-depends: ghc >= 8.10, ghc-boot
3737
if (impl(ghc >= 9.0) && impl(ghc < 9.1))
3838
ghc-options: -Wall -Wno-name-shadowing
3939
else

0 commit comments

Comments
 (0)