From cd293cc8ef24d5014bdea150f7d315d43126d055 Mon Sep 17 00:00:00 2001 From: Daniel Gröber Date: Sun, 29 Dec 2019 15:55:20 +0100 Subject: ghc-session: Get GHC libdir from --print-libdir command Using ghc-paths bypasses cabal's rebuild checks though, for example, installing the compiler into a different directory will change the libdir but cabal won't recompile ghc-paths. --- tests/GhcSession.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/GhcSession.hs b/tests/GhcSession.hs index 58b3755..f9f4e04 100644 --- a/tests/GhcSession.hs +++ b/tests/GhcSession.hs @@ -10,7 +10,6 @@ module Main where import GHC import Config -import GHC.Paths (libdir) import Outputable import DynFlags @@ -38,7 +37,7 @@ import CabalHelper.Shared.Common import CabalHelper.Compiletime.Types (Env) import CabalHelper.Compiletime.Process (readProcess, callProcessStderr) import CabalHelper.Compiletime.Program.GHC - (GhcVersion(..), ghcVersion) + (GhcVersion(..), ghcVersion, ghcLibdir) import CabalHelper.Compiletime.Program.CabalInstall (CabalInstallVersion(..), cabalInstallVersion) @@ -295,6 +294,8 @@ test modProgs (psdImpl -> ProjSetupImpl{..}) topdir tmpdir projdir cabal_file let progs = modProgs (qePrograms qe') qe = qe' { qePrograms = progs } + ghc_libdir <- let ?progs = progs; ?verbose = const False in ghcLibdir + psiSdist progs topdir tmpdir cs <- concat <$> runQuery (allUnits (Map.elems . uiComponents)) qe @@ -318,7 +319,7 @@ test modProgs (psdImpl -> ProjSetupImpl{..}) topdir tmpdir projdir cabal_file putStrLn sopts hFlush stdout - tr <- compileModule pkgdir ciEntrypoints ciSourceDirs opts' + tr <- compileModule ghc_libdir pkgdir ciEntrypoints ciSourceDirs opts' return $ tr ciComponentName where formatArg x @@ -330,9 +331,9 @@ addCabalProject dir = do writeFile (dir "cabal.project") "packages: .\n" compileModule - :: FilePath -> ChEntrypoint -> [FilePath] -> [String] + :: FilePath -> FilePath -> ChEntrypoint -> [FilePath] -> [String] -> IO (ChComponentName -> FilePath -> String -> String -> TestResult) -compileModule pkgdir ep srcdirs opts = do +compileModule ghc_libdir pkgdir ep srcdirs opts = do cwd_before <- getCurrentDirectory setCurrentDirectory pkgdir flip E.finally (setCurrentDirectory cwd_before) $ do @@ -342,7 +343,7 @@ compileModule pkgdir ep srcdirs opts = do E.handle (\(ec :: ExitCode) -> print ec >> return (TestResult False)) $ do defaultErrorHandler defaultFatalMessager defaultFlushOut $ do - runGhc (Just libdir) $ do + runGhc (Just ghc_libdir) $ do let printGhcEx e = GHC.printException e >> return (TestResult False) handleSourceError printGhcEx $ do -- cgit v1.2.3