summaryrefslogtreecommitdiff
path: root/compiler/GHC/Linker
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-09-30 11:12:10 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-10-19 03:30:16 -0400
commitdf419c1abd7daa3aa0231747582333357b8e9b85 (patch)
treea73aaf04830425c43afe525f22138ca58550301e /compiler/GHC/Linker
parent8144a92f5a73dd22c0d855d5b2bead930111511c (diff)
downloadhaskell-df419c1abd7daa3aa0231747582333357b8e9b85.tar.gz
driver: Cleanups related to ModLocation
ModLocation is the data type which tells you the locations of all the build products which can affect recompilation. It is now computed in one place and not modified through the pipeline. Important locations will now just consult ModLocation rather than construct the dynamic object path incorrectly. * Add paths for dynamic object and dynamic interface files to ModLocation. * Always use the paths from mod location when looking for where to find any interface or object file. * Always use the paths in a ModLocation when deciding where to write an interface and object file. * Remove `dynamicOutputFile` and `dynamicOutputHi` functions which *calculated* (incorrectly) the location of `dyn_o` and `dyn_hi` files. * Don't set `outputFile_` and so-on in `enableCodeGenWhen`, `-o` and hence `outputFile_` should not affect the location of object files in `--make` mode. It is now sufficient to just update the ModLocation with the temporary paths. * In `hscGenBackendPipeline` don't recompute the `ModLocation` to account for `-dynamic-too`, the paths are now accurate from the start of the run. * Rename `getLocation` to `mkOneShotModLocation`, as that's the only place it's used. Increase the locality of the definition by moving it close to the use-site. * Load the dynamic interface from ml_dyn_hi_file rather than attempting to reconstruct it in load_dynamic_too. * Add a variety of tests to check how -o -dyno etc interact with each other. Some other clean-ups * DeIOify mkHomeModLocation and friends, they are all pure functions. * Move FinderOpts into GHC.Driver.Config.Finder, next to initFinderOpts. * Be more precise about whether we mean outputFile or outputFile_: there were many places where outputFile was used but the result shouldn't have been affected by `-dyno` (for example the filename of the resulting executable). In these places dynamicNow would never be set but it's still more precise to not allow for this possibility. * Typo fixes suffices -> suffixes in the appropiate places.
Diffstat (limited to 'compiler/GHC/Linker')
-rw-r--r--compiler/GHC/Linker/Dynamic.hs2
-rw-r--r--compiler/GHC/Linker/Loader.hs4
-rw-r--r--compiler/GHC/Linker/Static.hs4
3 files changed, 5 insertions, 5 deletions
diff --git a/compiler/GHC/Linker/Dynamic.hs b/compiler/GHC/Linker/Dynamic.hs
index 3eca65c6cc..c62a6e2242 100644
--- a/compiler/GHC/Linker/Dynamic.hs
+++ b/compiler/GHC/Linker/Dynamic.hs
@@ -44,7 +44,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
= dflags0
verbFlags = getVerbFlags dflags
- o_file = outputFile dflags
+ o_file = outputFile_ dflags
pkgs_with_rts <- mayThrowUnitErr (preloadUnitsInfo' unit_env dep_packages)
diff --git a/compiler/GHC/Linker/Loader.hs b/compiler/GHC/Linker/Loader.hs
index 3cdee27863..2af6f4dfe1 100644
--- a/compiler/GHC/Linker/Loader.hs
+++ b/compiler/GHC/Linker/Loader.hs
@@ -615,7 +615,7 @@ checkNonStdWay dflags interp srcspan
-- Only if we are compiling with the same ways as GHC is built
-- with, can we dynamically load those object files. (see #3604)
- | objectSuf dflags == normalObjectSuffix && not (null targetFullWays)
+ | objectSuf_ dflags == normalObjectSuffix && not (null targetFullWays)
= failNonStd dflags srcspan
| otherwise = return (Just (hostWayTag ++ "o"))
@@ -663,7 +663,7 @@ failNonStd dflags srcspan = dieWith dflags srcspan $
getLinkDeps :: HscEnv -> HomePackageTable
-> LoaderState
- -> Maybe FilePath -- replace object suffices?
+ -> Maybe FilePath -- replace object suffixes?
-> SrcSpan -- for error messages
-> [Module] -- If you need these
-> IO ([Linkable], [Linkable], [UnitId]) -- ... then link these first
diff --git a/compiler/GHC/Linker/Static.hs b/compiler/GHC/Linker/Static.hs
index ed67daa347..d5e9147509 100644
--- a/compiler/GHC/Linker/Static.hs
+++ b/compiler/GHC/Linker/Static.hs
@@ -73,7 +73,7 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do
unit_state = ue_units unit_env
toolSettings' = toolSettings dflags
verbFlags = getVerbFlags dflags
- output_fn = exeFileName platform staticLink (outputFile dflags)
+ output_fn = exeFileName platform staticLink (outputFile_ dflags)
-- get the full list of packages to link with, by combining the
-- explicit packages with the auto packages and all of their
@@ -277,7 +277,7 @@ linkStaticLib logger dflags unit_env o_files dep_units = do
let platform = ue_platform unit_env
extra_ld_inputs = [ f | FileOption _ f <- ldInputs dflags ]
modules = o_files ++ extra_ld_inputs
- output_fn = exeFileName platform True (outputFile dflags)
+ output_fn = exeFileName platform True (outputFile_ dflags)
full_output_fn <- if isAbsolute output_fn
then return output_fn