Skip to content

Instantly share code, notes, and snippets.

@adinapoli
Created January 30, 2020 09:45
Show Gist options
  • Save adinapoli/06a1e6775bcd3d01d3980b29e9f5eb78 to your computer and use it in GitHub Desktop.
Save adinapoli/06a1e6775bcd3d01d3980b29e9f5eb78 to your computer and use it in GitHub Desktop.
configureDynFlags :: Config -> FilePath -> Ghc DynFlags
configureDynFlags cfg tmp = do
df <- getSessionDynFlags
(df',_,_) <- parseDynamicFlags df $ map noLoc $ ghcOptions cfg
loud <- liftIO isLoud
let df'' = df' { importPaths = nub $ idirs cfg ++ importPaths df'
, libraryPaths = nub $ idirs cfg ++ libraryPaths df'
, includePaths = updateIncludePaths df' (idirs cfg) -- addGlobalInclude (includePaths df') (idirs cfg)
, packageFlags = ExposePackage ""
(PackageArg "ghc-prim")
(ModRenaming True [])
: (packageFlags df')
, debugLevel = 1 -- insert SourceNotes
-- , profAuto = ProfAutoCalls
, ghcLink = LinkInMemory
, hscTarget = HscInterpreted
, ghcMode = CompManager
-- prevent GHC from printing anything, unless in Loud mode
, log_action = if loud
then defaultLogAction
else \_ _ _ _ _ _ -> return ()
-- redirect .hi/.o/etc files to temp directory
, objectDir = Just tmp
, hiDir = Just tmp
, stubDir = Just tmp
} `gopt_set` Opt_ImplicitImportQualified
`gopt_set` Opt_PIC
`gopt_set` Opt_DeferTypedHoles
`xopt_set` MagicHash
`xopt_set` DeriveGeneric
`xopt_set` StandaloneDeriving
_ <- setSessionDynFlags df''
return df''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment