Commit d880d6b2 authored by Artem Pelenitsyn's avatar Artem Pelenitsyn Committed by Marge Bot

Don't reload environment files on every setSessionDynFlags

Makes `interpretPackageEnv` (which loads envirinment files) a part of
`parseDynamicFlags` (parsing command-line arguments, which is typically
done once) instead of `setSessionDynFlags` (which is typically called
several times). Making several (transitive) calls to `interpretPackageEnv`,
as before, caused #18125 #16318, which should be fixed now.
parent d7e0b57f
......@@ -597,8 +597,7 @@ checkBrokenTablesNextToCode' dflags
setSessionDynFlags :: GhcMonad m => DynFlags -> m [UnitId]
setSessionDynFlags dflags = do
dflags' <- checkNewDynFlags dflags
dflags'' <- liftIO $ interpretPackageEnv dflags'
(dflags''', preload) <- liftIO $ initPackages dflags''
(dflags''', preload) <- liftIO $ initPackages dflags'
-- Interpreter
interp <- if gopt Opt_ExternalInterpreter dflags
......@@ -715,7 +714,11 @@ getInteractiveDynFlags = withSession $ \h -> return (ic_dflags (hsc_IC h))
parseDynamicFlags :: MonadIO m =>
DynFlags -> [Located String]
-> m (DynFlags, [Located String], [Warn])
parseDynamicFlags = parseDynamicFlagsCmdLine
parseDynamicFlags dflags cmdline = do
(dflags1, leftovers, warns) <- parseDynamicFlagsCmdLine dflags cmdline
dflags2 <- liftIO $ interpretPackageEnv dflags1
return (dflags2, leftovers, warns)
-- | Checks the set of new DynFlags for possibly erroneous option
-- combinations when invoking 'setSessionDynFlags' and friends, and if
......
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
test_pe = test-package-environment
T16318:
$(GHC_PKG) latest base > $(test_pe)
"$(TEST_HC)" $(TEST_HC_OPTS) -v1 -package-env $(test_pe) -e "putStrLn \"Hello\"" > out 2>&1
C=`cat out | grep "Loaded package environment" -c` ; \
if [ $$C != "1" ]; then false; fi
test('T16318', normal, makefile_test, [])
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
test_pe = test-package-environment
test_lib = containers
T18125:
$(GHC_PKG) latest base > $(test_pe)
$(GHC_PKG) latest $(test_lib) >> $(test_pe)
"$(TEST_HC)" $(TEST_HC_OPTS) -Wunused-packages -package-env $(test_pe) T18125.hs > out 2>&1
C=`cat out | grep "$(test_lib)" -c` ; \
if [ $$C != "1" ]; then false; fi
module Main where
main = putStrLn "hello world"
test('T18125', normal, makefile_test, [])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment