summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrkun <mrgutkun@gmail.com>2022-11-29 22:41:21 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-12-06 15:46:38 -0500
commita74225803dc4ec14e3aef96cfe5e17bdc5f0d2a7 (patch)
treeffbf13f75df32c01b0844be516c2d8fe2ef323ab
parent4e28f49e0a23f54a7b9b18a9010f19b0b15223db (diff)
downloadhaskell-a74225803dc4ec14e3aef96cfe5e17bdc5f0d2a7.tar.gz
Push DynFlags out of Linker.MacOS
-rw-r--r--compiler/GHC/Driver/Config/Linker.hs13
-rw-r--r--compiler/GHC/Linker/Config.hs13
-rw-r--r--compiler/GHC/Linker/Dynamic.hs3
-rw-r--r--compiler/GHC/Linker/MacOS.hs10
-rw-r--r--compiler/GHC/Linker/Static.hs3
-rw-r--r--compiler/ghc.cabal.in2
6 files changed, 38 insertions, 6 deletions
diff --git a/compiler/GHC/Driver/Config/Linker.hs b/compiler/GHC/Driver/Config/Linker.hs
new file mode 100644
index 0000000000..ed907d07a5
--- /dev/null
+++ b/compiler/GHC/Driver/Config/Linker.hs
@@ -0,0 +1,13 @@
+module GHC.Driver.Config.Linker
+ ( initFrameworkOpts
+ ) where
+
+import GHC.Linker.Config
+
+import GHC.Driver.Session
+
+initFrameworkOpts :: DynFlags -> FrameworkOpts
+initFrameworkOpts dflags = FrameworkOpts
+ { foFrameworkPaths = frameworkPaths dflags
+ , foCmdlineFrameworks = cmdlineFrameworks dflags
+ }
diff --git a/compiler/GHC/Linker/Config.hs b/compiler/GHC/Linker/Config.hs
new file mode 100644
index 0000000000..8fbb300caa
--- /dev/null
+++ b/compiler/GHC/Linker/Config.hs
@@ -0,0 +1,13 @@
+-- | Linker configuration
+
+module GHC.Linker.Config
+ ( FrameworkOpts(..)
+ ) where
+
+import GHC.Prelude
+
+-- used on darwin only
+data FrameworkOpts = FrameworkOpts
+ { foFrameworkPaths :: [String]
+ , foCmdlineFrameworks :: [String]
+ }
diff --git a/compiler/GHC/Linker/Dynamic.hs b/compiler/GHC/Linker/Dynamic.hs
index 175b5fb24a..171503d4d6 100644
--- a/compiler/GHC/Linker/Dynamic.hs
+++ b/compiler/GHC/Linker/Dynamic.hs
@@ -12,6 +12,7 @@ import GHC.Prelude
import GHC.Platform
import GHC.Platform.Ways
+import GHC.Driver.Config.Linker
import GHC.Driver.Session
import GHC.Unit.Env
@@ -95,7 +96,7 @@ linkDynLib logger tmpfs dflags0 unit_env o_files dep_packages
-- frameworks
pkg_framework_opts <- getUnitFrameworkOpts unit_env (map unitId pkgs)
- let framework_opts = getFrameworkOpts dflags platform
+ let framework_opts = getFrameworkOpts (initFrameworkOpts dflags) platform
case os of
OSMinGW32 -> do
diff --git a/compiler/GHC/Linker/MacOS.hs b/compiler/GHC/Linker/MacOS.hs
index d64a1075b2..a78e30e482 100644
--- a/compiler/GHC/Linker/MacOS.hs
+++ b/compiler/GHC/Linker/MacOS.hs
@@ -9,6 +9,8 @@ where
import GHC.Prelude
import GHC.Platform
+import GHC.Linker.Config
+
import GHC.Driver.Session
import GHC.Unit.Types
@@ -95,15 +97,15 @@ getUnitFrameworkOpts unit_env dep_packages
| otherwise = return []
-getFrameworkOpts :: DynFlags -> Platform -> [String]
-getFrameworkOpts dflags platform
+getFrameworkOpts :: FrameworkOpts -> Platform -> [String]
+getFrameworkOpts fwOpts platform
| platformUsesFrameworks platform = framework_path_opts ++ framework_opts
| otherwise = []
where
- framework_paths = frameworkPaths dflags
+ framework_paths = foFrameworkPaths fwOpts
framework_path_opts = map ("-F" ++) framework_paths
- frameworks = cmdlineFrameworks dflags
+ frameworks = foCmdlineFrameworks fwOpts
-- reverse because they're added in reverse order from the cmd line:
framework_opts = concat [ ["-framework", fw]
| fw <- reverse frameworks ]
diff --git a/compiler/GHC/Linker/Static.hs b/compiler/GHC/Linker/Static.hs
index baff075b08..99495d33fb 100644
--- a/compiler/GHC/Linker/Static.hs
+++ b/compiler/GHC/Linker/Static.hs
@@ -29,6 +29,7 @@ import GHC.Linker.ExtraObj
import GHC.Linker.Windows
import GHC.Linker.Static.Utils
+import GHC.Driver.Config.Linker
import GHC.Driver.Session
import System.FilePath
@@ -171,7 +172,7 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do
-- frameworks
pkg_framework_opts <- getUnitFrameworkOpts unit_env dep_units
- let framework_opts = getFrameworkOpts dflags platform
+ let framework_opts = getFrameworkOpts (initFrameworkOpts dflags) platform
-- probably _stub.o files
let extra_ld_inputs = ldInputs dflags
diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in
index 8b602133cf..34ccc26270 100644
--- a/compiler/ghc.cabal.in
+++ b/compiler/ghc.cabal.in
@@ -421,6 +421,7 @@ Library
GHC.Driver.Config.HsToCore
GHC.Driver.Config.HsToCore.Ticks
GHC.Driver.Config.HsToCore.Usage
+ GHC.Driver.Config.Linker
GHC.Driver.Config.Logger
GHC.Driver.Config.Parser
GHC.Driver.Config.Stg.Debug
@@ -529,6 +530,7 @@ Library
GHC.JS.Syntax
GHC.JS.Transform
GHC.Linker
+ GHC.Linker.Config
GHC.Linker.Dynamic
GHC.Linker.ExtraObj
GHC.Linker.Loader