@@ -14,6 +14,7 @@ import qualified Data.List as L
1414import qualified Data.List.NonEmpty as NE
1515import Data.Maybe
1616import qualified Data.Text as T
17+import Distribution.Compiler (CompilerFlavor(..))
1718import Distribution.PackageDescription.Parsec (parseGenericPackageDescription)
1819import Distribution.Parsec.ParseResult (runParseResult)
1920import Distribution.Pretty
@@ -48,6 +49,8 @@ data CabalPackageInfo = CabalPackageInfo
4849 -- ^ List of globally enable extensions of the library component
4950 , _cabalPackageInfo_defaultLanguage :: Maybe Language
5051 -- ^ List of globally set languages of the library component
52+ , _cabalPackageInfo_compilerOptions :: [(CompilerFlavor, [String])]
53+ -- ^ List of compiler-specific options (e.g., the "ghc-options" field of the cabal file)
5154 }
5255
5356-- NOTE: `run` is not polymorphic like the rest because we use StaticPtr to invoke it.
@@ -143,6 +146,7 @@ parseCabalPackage dir = do
143146 defaultExtensions $ libBuildInfo lib
144147 , _cabalPackageInfo_defaultLanguage =
145148 defaultLanguage $ libBuildInfo lib
149+ , _cabalPackageInfo_compilerOptions = options $ libBuildInfo lib
146150 }
147151 Left (_, errors) -> do
148152 putLog Error $ T.pack $ "Failed to parse " <> cabalFp <> ":"
@@ -178,8 +182,12 @@ withGhciScript pkgs f = do
178182 extensionsLine = if extensions == mempty
179183 then ""
180184 else ":set " <> intercalate " " ((("-X" <>) . prettyShow) <$> extensions)
185+ ghcOptions = (":set " <>) $ intercalate " " $ concat $
186+ mapMaybe (\case (GHC, xs) -> Just xs; _ -> Nothing) $
187+ packageInfos >>= _cabalPackageInfo_compilerOptions
181188 dotGhci = unlines $
182189 [ ":set -i" <> intercalate ":" (packageInfos >>= rootedSourceDirs)
190+ , ghcOptions
183191 , extensionsLine
184192 , ":set " <> intercalate " " (("-X" <>) . prettyShow <$> language)
185193 , ":load Backend Frontend"