Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass dynamic flag for dynamic GHC #287

Merged
merged 2 commits into from
Feb 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/HIE/Bios/Cradle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import qualified Data.Text as T
import qualified Data.HashMap.Strict as Map
import Data.Maybe (fromMaybe, maybeToList)
import GHC.Fingerprint (fingerprintString)
import DynFlags (dynamicGhc)

hie_bios_output :: String
hie_bios_output = "HIE_BIOS_OUTPUT"
Expand Down Expand Up @@ -172,6 +173,14 @@ readCradleConfig yamlHie = do
configFileName :: FilePath
configFileName = "hie.yaml"

-- | We need pass -dynamic flag when GHC is built with dynamic linking.
--
-- The flage is appended to options of 'defaultCradle' and 'directCradle',
-- because unlike the case of using build tools, which means -dynamic can be set via
-- .cabal or package.yaml, users have to create an explicit hie.yaml to pass this flag.
argDynamic :: [String]
argDynamic = ["-dynamic" | dynamicGhc]

---------------------------------------------------------------

isCabalCradle :: Cradle a -> Bool
Expand Down Expand Up @@ -225,7 +234,7 @@ defaultCradle cur_dir =
, cradleOptsProg = CradleAction
{ actionName = Types.Default
, runCradle = \_ _ ->
return (CradleSuccess (ComponentOptions [] cur_dir []))
return (CradleSuccess (ComponentOptions argDynamic cur_dir []))
, runGhcCmd = runGhcCmdOnPath cur_dir
}
}
Expand Down Expand Up @@ -334,7 +343,7 @@ directCradle wdir args =
, cradleOptsProg = CradleAction
{ actionName = Types.Direct
, runCradle = \_ _ ->
return (CradleSuccess (ComponentOptions args wdir []))
return (CradleSuccess (ComponentOptions (args ++ argDynamic) wdir []))
, runGhcCmd = runGhcCmdOnPath wdir
}
}
Expand Down