Skip to content

Commit

Permalink
Merge branch 'master' into soulomoon/wait-for-token-indexHieFile
Browse files Browse the repository at this point in the history
  • Loading branch information
soulomoon authored Jun 20, 2024
2 parents 0b3808f + 54f4108 commit 1405cb7
Show file tree
Hide file tree
Showing 65 changed files with 124 additions and 2,273 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/caching.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ jobs:
- ubuntu-latest
- macOS-latest
- windows-latest
exclude:
# We disable this this combo in test.yml due to long path issues, so we also need to disable it here
- os: windows-latest
ghc: "9.2"
steps:
- uses: actions/checkout@v3

Expand All @@ -105,7 +101,7 @@ jobs:
# Fetching from github cache is faster than doing it from hackage
# Sources does not change per ghc and ghc version son only doing it
# for one matrix job (it is arbitrary)
- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '9.2'
- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '9.6'
name: Download sources
run: |
cabal $cabalBuild --only-download --enable-benchmarks --enable-tests
Expand All @@ -120,7 +116,7 @@ jobs:
# We build ghcide with benchs and test enabled to include its dependencies in the cache
# (including shake-bench)
# Only for the same ghc and os used in the bench workflow, so we save cache space
- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '9.2'
- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '9.6'
name: Build ghcide benchmark
run: |
cabal $cabalBuild ghcide --enable-benchmarks --enable-tests
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: ./.github/actions/setup-build
with:
# select a stable GHC version
ghc: 9.2
ghc: 9.6
os: ${{ runner.os }}
shorten-hls: false

Expand Down
19 changes: 5 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ["9.10.1", "9.8.2", "9.6.5", "9.4.8", "9.2.8"]
ghc: ["9.10.1", "9.8.2", "9.6.5", "9.4.8"]
platform: [ { image: "debian:9"
, installCmd: "sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list && sed -i 's|security.debian.org|archive.debian.org/|g' /etc/apt/sources.list && sed -i /-updates/d /etc/apt/sources.list && apt-get update && apt-get install -y"
, toolRequirements: "libnuma-dev zlib1g-dev libgmp-dev libgmp10 libssl-dev liblzma-dev libbz2-dev git wget lsb-release software-properties-common gnupg2 apt-transport-https gcc autoconf automake build-essential curl ghc gzip libffi-dev libncurses-dev libncurses5 libtinfo5 patchelf"
Expand Down Expand Up @@ -118,15 +118,6 @@ jobs:
# Perhaps we can migrate *all* unknown linux builds to a uniform
# image.
include:
- ghc: 9.2.8
platform:
{ image: "rockylinux:8"
, installCmd: "yum -y install epel-release && yum install -y --allowerasing"
, toolRequirements: "autoconf automake binutils bzip2 coreutils curl elfutils-devel elfutils-libs findutils gcc gcc-c++ git gmp gmp-devel jq lbzip2 make ncurses ncurses-compat-libs ncurses-devel openssh-clients patch perl pxz python3 sqlite sudo wget which xz zlib-devel patchelf"
, DISTRO: "Unknown"
, ARTIFACT: "x86_64-linux-unknown"
, ADD_CABAL_ARGS: "--enable-split-sections"
}
- ghc: 9.4.8
platform:
{ image: "fedora:27"
Expand Down Expand Up @@ -222,7 +213,7 @@ jobs:
strategy:
fail-fast: true
matrix:
ghc: ["9.10.1", "9.8.2", "9.6.5", "9.4.8", "9.2.8" ]
ghc: ["9.10.1", "9.8.2", "9.6.5", "9.4.8"]
steps:
- uses: docker://arm64v8/ubuntu:focal
name: Cleanup (aarch64 linux)
Expand Down Expand Up @@ -282,7 +273,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ["9.10.1", "9.8.2", "9.6.5", "9.4.8", "9.2.8"]
ghc: ["9.10.1", "9.8.2", "9.6.5", "9.4.8"]
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -327,7 +318,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ["9.10.1", "9.8.2", "9.6.5", "9.4.8", "9.2.8"]
ghc: ["9.10.1", "9.8.2", "9.6.5", "9.4.8"]
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -372,7 +363,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ghc: ["9.10.1", "9.8.2", "9.6.5", "9.4.8", "9.2.8"]
ghc: ["9.10.1", "9.8.2", "9.6.5", "9.4.8"]
steps:
- name: install windows deps
shell: pwsh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/supported-ghc-versions.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["9.10", "9.8", "9.6", "9.4" , "9.2" ]
["9.10", "9.8", "9.6", "9.4"]
9 changes: 3 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ jobs:
- true
- false
exclude:
# Don't do anything for windows on 9.2, it has particularly bad long-path issues
- os: windows-latest
ghc: "9.2"
# Exclude the test configuration on macos, it's sufficiently similar to other OSs
# that it mostly just burns CI time. Buiding is still useful since it catches
# solver issues.
Expand Down Expand Up @@ -164,7 +161,7 @@ jobs:
run: cabal test hls-splice-plugin-tests || cabal test hls-splice-plugin-tests

# TODO enable when it supports 9.10
- if: matrix.test && matrix.ghc != '9.2' && matrix.ghc != '9.10'
- if: matrix.test && matrix.ghc != '9.10'
name: Test hls-stan-plugin
run: cabal test hls-stan-plugin-tests || cabal test hls-stan-plugin-tests

Expand Down Expand Up @@ -230,8 +227,8 @@ jobs:
name: Test hls-explicit-record-fields-plugin test suite
run: cabal test hls-explicit-record-fields-plugin-tests || cabal test hls-explicit-record-fields-plugin-tests

## version needs to be limited since the tests depend on cabal-fmt which only builds using specific ghc versions
- if: matrix.test && matrix.ghc == '9.2'
# versions need to be limited since the tests depend on cabal-fmt which only builds with ghc <9.10
- if: matrix.test && matrix.ghc != '9.10'
name: Test hls-cabal-fmt-plugin test suite
run: cabal test hls-cabal-fmt-plugin-tests --flag=isolateCabalfmtTests || cabal test hls-cabal-fmt-plugin-tests --flag=isolateCabalfmtTests

Expand Down
2 changes: 1 addition & 1 deletion docs/support/ghc-version-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Support status (see the support policy below for more details):
| 9.4.4 | [1.10.0.0](https://github.com/haskell/haskell-language-server/releases/tag/1.10.0.0) | deprecated |
| 9.4.3 | [1.9.1.0](https://github.com/haskell/haskell-language-server/releases/tag/1.9.1.0) | deprecated |
| 9.4.(1,2) | [1.8.0.0](https://github.com/haskell/haskell-language-server/releases/tag/1.8.0.0) | deprecated |
| 9.2.8 | [latest](https://github.com/haskell/haskell-language-server/releases/latest) | full support |
| 9.2.8 | [2.9.0.0](https://github.com/haskell/haskell-language-server/releases/tag/2.9.0.0) | deprecated |
| 9.2.7 | [2.0.0.1](https://github.com/haskell/haskell-language-server/releases/tag/2.0.0.1) | deprecated |
| 9.2.(5,6) | [1.9.1.0](https://github.com/haskell/haskell-language-server/releases/tag/1.9.1.0) | deprecated |
| 9.2.(3,4) | [1.8.0.0](https://github.com/haskell/haskell-language-server/releases/tag/1.8.0.0) | deprecated |
Expand Down
2 changes: 1 addition & 1 deletion docs/support/plugin-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ For example, a plugin to provide a formatter which has itself been abandoned has
| `hls-overloaded-record-dot-plugin` | 2 | |
| `hls-semantic-tokens-plugin` | 2 | |
| `hls-floskell-plugin` | 3 | 9.10.1 |
| `hls-stan-plugin` | 3 | 9.2.(4-8), 9.10.1 |
| `hls-stan-plugin` | 3 | 9.10.1 |
| `hls-retrie-plugin` | 3 | 9.10.1 |
| `hls-splice-plugin` | 3 | 9.10.1 |
2 changes: 1 addition & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ stack install haskell-language-server
You also can leverage `ghcup compile hls`:

```bash
ghcup compile hls -v 1.9.0.0 --ghc 9.2.5
ghcup compile hls -v 2.9.0.0 --ghc 9.6.5
```

### Preprocessors
Expand Down
2 changes: 1 addition & 1 deletion ghcide/ghcide.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ homepage:
https://github.com/haskell/haskell-language-server/tree/master/ghcide#readme

bug-reports: https://github.com/haskell/haskell-language-server/issues
tested-with: GHC ==9.10.1 || ==9.8.2 || ==9.6.5 || ==9.4.8 || ==9.2.8
tested-with: GHC ==9.10.1 || ==9.8.2 || ==9.6.5 || ==9.4.8
extra-source-files:
CHANGELOG.md
README.md
Expand Down
84 changes: 6 additions & 78 deletions ghcide/session-loader/Development/IDE/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ import Development.IDE.Graph (Action)
import qualified Development.IDE.Session.Implicit as GhcIde
import Development.IDE.Types.Diagnostics
import Development.IDE.Types.Exports
import Development.IDE.Types.HscEnvEq (HscEnvEq, newHscEnvEq,
newHscEnvEqPreserveImportPaths)
import Development.IDE.Types.HscEnvEq (HscEnvEq, newHscEnvEq)
import Development.IDE.Types.Location
import Development.IDE.Types.Options
import GHC.ResponseFile
Expand Down Expand Up @@ -120,7 +119,6 @@ import Text.ParserCombinators.ReadP (readP_to_S)

-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]

#if MIN_VERSION_ghc(9,3,0)
import qualified Data.Set as OS
import qualified Development.IDE.GHC.Compat.Util as Compat
import GHC.Data.Graph.Directed
Expand All @@ -131,7 +129,6 @@ import GHC.Driver.Errors.Types
import GHC.Types.Error (errMsgDiagnostic,
singleMessage)
import GHC.Unit.State
#endif

data Log
= LogSettingInitialDynFlags
Expand Down Expand Up @@ -245,13 +242,6 @@ data SessionLoadingOptions = SessionLoadingOptions
, getCacheDirs :: String -> [String] -> IO CacheDirs
-- | Return the GHC lib dir to use for the 'unsafeGlobalDynFlags'
, getInitialGhcLibDir :: Recorder (WithPriority Log) -> FilePath -> IO (Maybe LibDir)
#if !MIN_VERSION_ghc(9,3,0)
, fakeUid :: UnitId
-- ^ unit id used to tag the internal component built by ghcide
-- To reuse external interface files the unit ids must match,
-- thus make sure to build them with `--this-unit-id` set to the
-- same value as the ghcide fake uid
#endif
}

instance Default SessionLoadingOptions where
Expand All @@ -260,9 +250,6 @@ instance Default SessionLoadingOptions where
,loadCradle = loadWithImplicitCradle
,getCacheDirs = getCacheDirsDefault
,getInitialGhcLibDir = getInitialGhcLibDirDefault
#if !MIN_VERSION_ghc(9,3,0)
,fakeUid = Compat.toUnitId (Compat.stringToUnit "main")
#endif
}

-- | Find the cradle for a given 'hie.yaml' configuration.
Expand Down Expand Up @@ -542,11 +529,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
all_deps' <- forM all_deps $ \RawComponentInfo{..} -> do
-- Remove all inplace dependencies from package flags for
-- components in this HscEnv
#if MIN_VERSION_ghc(9,3,0)
let (df2, uids) = (rawComponentDynFlags, [])
#else
let (df2, uids) = _removeInplacePackages fakeUid _inplace rawComponentDynFlags
#endif
let prefix = show rawComponentUnitId
-- See Note [Avoiding bad interface files]
let hscComponents = sort $ map show uids
Expand Down Expand Up @@ -585,8 +568,8 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
-- For GHC's supporting multi component sessions, we create a shared
-- HscEnv but set the active component accordingly
hscEnv <- emptyHscEnv ideNc _libDir
let new_cache = newComponentCache recorder optExtensions hieYaml _cfp hscEnv
all_target_details <- new_cache old_deps new_deps rootDir
let new_cache = newComponentCache recorder optExtensions _cfp hscEnv
all_target_details <- new_cache old_deps new_deps

this_dep_info <- getDependencyInfo $ maybeToList hieYaml
let (all_targets, this_flags_map, this_options)
Expand Down Expand Up @@ -771,24 +754,13 @@ cradleToOptsAndLibDir recorder loadConfig cradle file old_fps = do
PreferSingleComponentLoading -> LoadFile
PreferMultiComponentLoading -> LoadWithContext old_fps

#if MIN_VERSION_ghc(9,3,0)
emptyHscEnv :: NameCache -> FilePath -> IO HscEnv
#else
emptyHscEnv :: IORef NameCache -> FilePath -> IO HscEnv
#endif
emptyHscEnv nc libDir = do
-- We call setSessionDynFlags so that the loader is initialised
-- We need to do this before we call initUnits.
env <- runGhc (Just libDir) $
getSessionDynFlags >>= setSessionDynFlags >> getSession
-- On GHC 9.2 calling setSessionDynFlags caches the unit databases
-- for an empty environment. This prevents us from reading the
-- package database subsequently. So clear the unit db cache in
-- hsc_unit_dbs
pure $ setNameCache nc (hscSetFlags ((hsc_dflags env){useUnicode = True }) env)
#if !MIN_VERSION_ghc(9,3,0)
{hsc_unit_dbs = Nothing}
#endif

data TargetDetails = TargetDetails
{
Expand Down Expand Up @@ -826,14 +798,9 @@ toFlagsMap TargetDetails{..} =
[ (l, (targetEnv, targetDepends)) | l <- targetLocations]


#if MIN_VERSION_ghc(9,3,0)
setNameCache :: NameCache -> HscEnv -> HscEnv
#else
setNameCache :: IORef NameCache -> HscEnv -> HscEnv
#endif
setNameCache nc hsc = hsc { hsc_NC = nc }

#if MIN_VERSION_ghc(9,3,0)
-- This function checks the important property that if both p and q are home units
-- then any dependency of p, which transitively depends on q is also a home unit.
-- GHC had an implementation of this function, but it was horribly inefficient
Expand Down Expand Up @@ -890,7 +857,6 @@ checkHomeUnitsClosed' ue home_id_set
Just depends ->
let todo'' = (depends OS.\\ done) `OS.union` todo'
in DigraphNode uid uid (OS.toList depends) : go (OS.insert uid done) todo''
#endif

-- | Create a mapping from FilePaths to HscEnvEqs
-- This combines all the components we know about into
Expand All @@ -899,14 +865,12 @@ checkHomeUnitsClosed' ue home_id_set
newComponentCache
:: Recorder (WithPriority Log)
-> [String] -- ^ File extensions to consider
-> Maybe FilePath -- ^ Path to cradle
-> NormalizedFilePath -- ^ Path to file that caused the creation of this component
-> HscEnv -- ^ An empty HscEnv
-> [ComponentInfo] -- ^ New components to be loaded
-> [ComponentInfo] -- ^ old, already existing components
-> FilePath -- ^ root dir, see Note [Root Directory]
-> IO [ [TargetDetails] ]
newComponentCache recorder exts cradlePath _cfp hsc_env old_cis new_cis dir = do
newComponentCache recorder exts _cfp hsc_env old_cis new_cis = do
let cis = Map.unionWith unionCIs (mkMap new_cis) (mkMap old_cis)
-- When we have multiple components with the same uid,
-- prefer the new one over the old.
Expand All @@ -920,18 +884,13 @@ newComponentCache recorder exts cradlePath _cfp hsc_env old_cis new_cis dir = do
hscEnv' <- -- Set up a multi component session with the other units on GHC 9.4
Compat.initUnits dfs hsc_env

#if MIN_VERSION_ghc(9,3,0)
let closure_errs = checkHomeUnitsClosed' (hsc_unit_env hscEnv') (hsc_all_home_unit_ids hscEnv')
multi_errs = map (ideErrorWithSource (Just "cradle") (Just DiagnosticSeverity_Warning) _cfp . T.pack . Compat.printWithoutUniques) closure_errs
bad_units = OS.fromList $ concat $ do
x <- bagToList $ mapBag errMsgDiagnostic $ unionManyBags $ map Compat.getMessages closure_errs
DriverHomePackagesNotClosed us <- pure x
pure us
isBad ci = (homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units

Check warning on line 893 in ghcide/session-loader/Development/IDE/Session.hs

View workflow job for this annotation

GitHub Actions / Hlint check run

Suggestion in newComponentCache in module Development.IDE.Session: Redundant bracket ▫︎ Found: "(homeUnitId_ (componentDynFlags ci)) `OS.member` bad_units" ▫︎ Perhaps: "homeUnitId_ (componentDynFlags ci) `OS.member` bad_units"
#else
let isBad = const False
multi_errs = []
#endif
-- Whenever we spin up a session on Linux, dynamically load libm.so.6
-- in. We need this in case the binary is statically linked, in which
-- case the interactive session will fail when trying to load
Expand All @@ -951,26 +910,12 @@ newComponentCache recorder exts cradlePath _cfp hsc_env old_cis new_cis dir = do

forM (Map.elems cis) $ \ci -> do
let df = componentDynFlags ci
let createHscEnvEq = maybe newHscEnvEqPreserveImportPaths (newHscEnvEq dir) cradlePath
thisEnv <- do
#if MIN_VERSION_ghc(9,3,0)
-- In GHC 9.4 we have multi component support, and we have initialised all the units
-- above.
-- We just need to set the current unit here
pure $ hscSetActiveUnitId (homeUnitId_ df) hscEnv'
#else
-- This initializes the units for GHC 9.2
-- Add the options for the current component to the HscEnv
-- We want to call `setSessionDynFlags` instead of `hscSetFlags`
-- because `setSessionDynFlags` also initializes the package database,
-- which we need for any changes to the package flags in the dynflags
-- to be visible.
-- See #2693
evalGhcEnv hscEnv' $ do
_ <- setSessionDynFlags df
getSession
#endif
henv <- createHscEnvEq thisEnv (zip uids dfs)
henv <- newHscEnvEq thisEnv
let targetEnv = (if isBad ci then multi_errs else [], Just henv)
targetDepends = componentDependencyInfo ci
logWith recorder Debug $ LogNewComponentCache (targetEnv, targetDepends)
Expand Down Expand Up @@ -1201,7 +1146,6 @@ setOptions cfp (ComponentOptions theOpts compRoot _) dflags rootDir = do
initOne this_opts = do
(dflags', targets') <- addCmdOpts this_opts dflags
let dflags'' =
#if MIN_VERSION_ghc(9,3,0)
case unitIdString (homeUnitId_ dflags') of
-- cabal uses main for the unit id of all executable packages
-- This makes multi-component sessions confused about what
Expand All @@ -1214,9 +1158,6 @@ setOptions cfp (ComponentOptions theOpts compRoot _) dflags rootDir = do
hashed_uid = Compat.toUnitId (Compat.stringToUnit ("main-"++hash))
in setHomeUnitId_ hashed_uid dflags'
_ -> dflags'
#else
dflags'
#endif

let targets = makeTargetsAbsolute root targets'
root = case workingDirectory dflags'' of
Expand All @@ -1236,14 +1177,7 @@ setOptions cfp (ComponentOptions theOpts compRoot _) dflags rootDir = do
Compat.setUpTypedHoles $
makeDynFlagsAbsolute compRoot -- makeDynFlagsAbsolute already accounts for workingDirectory
dflags''
-- initPackages parses the -package flags and
-- sets up the visibility for each component.
-- Throws if a -package flag cannot be satisfied.
-- This only works for GHC <9.2
-- For GHC >= 9.2, we need to modify the unit env in the hsc_dflags, which
-- is done later in newComponentCache
final_flags <- liftIO $ wrapPackageSetupException $ Compat.oldInitUnits dflags'''
return (final_flags, targets)
return (dflags''', targets)

setIgnoreInterfacePragmas :: DynFlags -> DynFlags
setIgnoreInterfacePragmas df =
Expand Down Expand Up @@ -1289,12 +1223,6 @@ data PackageSetupException

instance Exception PackageSetupException

-- | Wrap any exception as a 'PackageSetupException'
wrapPackageSetupException :: IO a -> IO a
wrapPackageSetupException = handleAny $ \case
e | Just (pkgE :: PackageSetupException) <- fromException e -> throwIO pkgE
e -> (throwIO . PackageSetupException . show) e

showPackageSetupException :: PackageSetupException -> String
showPackageSetupException GhcVersionMismatch{..} = unwords
["ghcide compiled against GHC"
Expand Down
Loading

0 comments on commit 1405cb7

Please sign in to comment.