@@ -520,7 +520,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
520
520
packageSetup (hieYaml, cfps, opts, libDir) = do
521
521
-- Parse DynFlags for the newly discovered component
522
522
hscEnv <- emptyHscEnv ideNc libDir
523
- newTargetDfs <- evalGhcEnv hscEnv $ setOptions' cfps opts (hsc_dflags hscEnv) rootDir
523
+ newTargetDfs <- evalGhcEnv hscEnv $ setOptions cfps opts (hsc_dflags hscEnv) rootDir
524
524
let deps = componentDependencies opts ++ maybeToList hieYaml
525
525
dep_info <- getDependencyInfo deps
526
526
-- Now lookup to see whether we are combining with an existing HscEnv
@@ -1184,13 +1184,13 @@ addUnit unit_str = liftEwM $ do
1184
1184
putCmdLineState (unit_str : units)
1185
1185
1186
1186
-- | Throws if package flags are unsatisfiable
1187
- setOptions' :: GhcMonad m
1187
+ setOptions :: GhcMonad m
1188
1188
=> [NormalizedFilePath ]
1189
1189
-> ComponentOptions
1190
1190
-> DynFlags
1191
1191
-> FilePath -- ^ root dir, see Note [Root Directory]
1192
1192
-> m (NonEmpty (DynFlags , [GHC. Target ]))
1193
- setOptions' cfps (ComponentOptions theOpts compRoot _) dflags rootDir = do
1193
+ setOptions cfps (ComponentOptions theOpts compRoot _) dflags rootDir = do
1194
1194
((theOpts',_errs,_warns),units) <- processCmdLineP unit_flags [] (map noLoc theOpts)
1195
1195
case NE. nonEmpty units of
1196
1196
Just us -> initMulti us
@@ -1257,79 +1257,6 @@ setOptions' cfps (ComponentOptions theOpts compRoot _) dflags rootDir = do
1257
1257
dflags''
1258
1258
return (dflags''', targets)
1259
1259
1260
- -- | Throws if package flags are unsatisfiable
1261
- setOptions :: GhcMonad m
1262
- => NormalizedFilePath
1263
- -> ComponentOptions
1264
- -> DynFlags
1265
- -> FilePath -- ^ root dir, see Note [Root Directory]
1266
- -> m (NonEmpty (DynFlags , [GHC. Target ]))
1267
- setOptions cfp (ComponentOptions theOpts compRoot _) dflags rootDir = do
1268
- ((theOpts',_errs,_warns),units) <- processCmdLineP unit_flags [] (map noLoc theOpts)
1269
- case NE. nonEmpty units of
1270
- Just us -> initMulti us
1271
- Nothing -> do
1272
- (df, targets) <- initOne (map unLoc theOpts')
1273
- -- A special target for the file which caused this wonderful
1274
- -- component to be created. In case the cradle doesn't list all the targets for
1275
- -- the component, in which case things will be horribly broken anyway.
1276
- --
1277
- -- When we have a singleComponent that is caused to be loaded due to a
1278
- -- file, we assume the file is part of that component. This is useful
1279
- -- for bare GHC sessions, such as many of the ones used in the testsuite
1280
- --
1281
- -- We don't do this when we have multiple components, because each
1282
- -- component better list all targets or there will be anarchy.
1283
- -- It is difficult to know which component to add our file to in
1284
- -- that case.
1285
- -- Multi unit arguments are likely to come from cabal, which
1286
- -- does list all targets.
1287
- --
1288
- -- If we don't end up with a target for the current file in the end, then
1289
- -- we will report it as an error for that file
1290
- let abs_fp = toAbsolute rootDir (fromNormalizedFilePath cfp)
1291
- let special_target = Compat. mkSimpleTarget df abs_fp
1292
- pure $ (df, special_target : targets) :| []
1293
- where
1294
- initMulti unitArgFiles =
1295
- forM unitArgFiles $ \ f -> do
1296
- args <- liftIO $ expandResponse [f]
1297
- initOne args
1298
- initOne this_opts = do
1299
- (dflags', targets') <- addCmdOpts this_opts dflags
1300
- let dflags'' =
1301
- case unitIdString (homeUnitId_ dflags') of
1302
- -- cabal uses main for the unit id of all executable packages
1303
- -- This makes multi-component sessions confused about what
1304
- -- options to use for that component.
1305
- -- Solution: hash the options and use that as part of the unit id
1306
- -- This works because there won't be any dependencies on the
1307
- -- executable unit.
1308
- " main" ->
1309
- let hash = B. unpack $ B16. encode $ H. finalize $ H. updates H. init (map B. pack this_opts)
1310
- hashed_uid = Compat. toUnitId (Compat. stringToUnit (" main-" ++ hash))
1311
- in setHomeUnitId_ hashed_uid dflags'
1312
- _ -> dflags'
1313
-
1314
- let targets = makeTargetsAbsolute root targets'
1315
- root = case workingDirectory dflags'' of
1316
- Nothing -> compRoot
1317
- Just wdir -> compRoot </> wdir
1318
- let dflags''' =
1319
- setWorkingDirectory root $
1320
- disableWarningsAsErrors $
1321
- -- disabled, generated directly by ghcide instead
1322
- flip gopt_unset Opt_WriteInterface $
1323
- -- disabled, generated directly by ghcide instead
1324
- -- also, it can confuse the interface stale check
1325
- dontWriteHieFiles $
1326
- setIgnoreInterfacePragmas $
1327
- setBytecodeLinkerOptions $
1328
- disableOptimisation $
1329
- Compat. setUpTypedHoles $
1330
- makeDynFlagsAbsolute compRoot -- makeDynFlagsAbsolute already accounts for workingDirectory
1331
- dflags''
1332
- return (dflags''', targets)
1333
1260
1334
1261
setIgnoreInterfacePragmas :: DynFlags -> DynFlags
1335
1262
setIgnoreInterfacePragmas df =
0 commit comments