Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit e61670f

Browse files
committed
Strip RTS flags, since we cant honor them
Issue that caused it: #1725 the problem is that we cant honour the `+RTS` flags, since these need to be known when GHC is started. However, HIE is the compiler and is started before we load any component. Therefore, these options for the different component are unusable and we strip them here to avoid a bug. This commit is inspired by haskell/hie-bios#102
1 parent 78eb87b commit e61670f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

hie-plugin-api/Haskell/Ide/Engine/Cradle.hs

+11-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ cabalHelperAction proj env package root fp = do
543543
let fs' = getFlags comp
544544
let fs = map (fixImportDirs root) fs'
545545
let targets = getTargets comp relativeFp
546-
let ghcOptions = fs ++ targets
546+
let ghcOptions = removeRTS (fs ++ targets)
547547
debugm $ "Flags for \"" ++ fp ++ "\": " ++ show ghcOptions
548548
debugm $ "Component Infos: " ++ show comp
549549
return
@@ -556,6 +556,16 @@ cabalHelperAction proj env package root fp = do
556556
$ CradleError
557557
(ExitFailure 2)
558558
err
559+
where
560+
-- | Strip out any ["+RTS", ..., "-RTS"] sequences in the command string list.
561+
removeRTS :: [String] -> [String]
562+
removeRTS ("+RTS" : xs) =
563+
case dropWhile (/= "-RTS") xs of
564+
[] -> []
565+
(_ : ys) -> removeRTS ys
566+
removeRTS (y:ys) = y : removeRTS ys
567+
removeRTS [] = []
568+
559569

560570
-- | Fix occurrences of "-i." to "-i<cradle-root-dir>"
561571
-- Flags obtained from cabal-helper are relative to the package

0 commit comments

Comments
 (0)