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

Commit 42192b5

Browse files
committed
Strip RTS flags, since we cant honor them
1 parent b7fd5fb commit 42192b5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
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)