Skip to content

Commit

Permalink
FIXES
Browse files Browse the repository at this point in the history
  • Loading branch information
alt-romes committed Jan 17, 2024
1 parent 05925f5 commit 0187e2f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
10 changes: 7 additions & 3 deletions Cabal/src/Distribution/Simple/GHC/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@ build numJobs pkg_descr = do
-- See also Note [Building Haskell Modules accounting for TH] in Distribution.Simple.GHC.Build.Modules
wantedWays =
Set.fromList $
[StaticWay | wantStatic || wantVanilla ||
-- We build static by default if no other way is wanted
not (wantDynamic || wantProf)]
[ StaticWay
| wantStatic
|| wantVanilla
||
-- We build static by default if no other way is wanted
not (wantDynamic || wantProf)
]
<> [DynWay | wantDynamic]
<> [ProfWay | wantProf]

Expand Down
27 changes: 18 additions & 9 deletions Cabal/src/Distribution/Simple/GHC/Build/Link.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ linkOrLoadComponent ghcProg pkg_descr extraSources (buildTargetDir, targetDir) (
case what of
BuildRepl replFlags -> liftIO $ do
let
-- For repl we use the vanilla ghc options
-- For repl we use the vanilla (static) ghc options
staticOpts = buildOpts StaticWay
replOpts =
vanillaOpts
staticOpts
{ ghcOptExtra =
Internal.filterGhciFlags
(ghcOptExtra vanillaOpts)
(ghcOptExtra staticOpts)
<> replOptionsFlags (replReplOptions replFlags)
, ghcOptInputModules = replNoLoad (replReplOptions replFlags) (ghcOptInputModules vanillaOpts)
, ghcOptInputFiles = replNoLoad (replReplOptions replFlags) (ghcOptInputFiles vanillaOpts)
, ghcOptInputModules = replNoLoad (replReplOptions replFlags) (ghcOptInputModules staticOpts)
, ghcOptInputFiles = replNoLoad (replReplOptions replFlags) (ghcOptInputFiles staticOpts)
}
-- For a normal compile we do separate invocations of ghc for
-- compiling as for linking. But for repl we have to do just
Expand Down Expand Up @@ -409,8 +409,8 @@ linkFLib flib bi lbi (linkerOpts, rpaths) (wantedWays, buildOpts) targetDir runG
comp = compiler lbi

-- Instruct GHC to link against libHSrts.
rtsLinkOpts :: BuildWay -> GhcOptions
rtsLinkOpts way
rtsLinkOpts :: GhcOptions
rtsLinkOpts
| supportsFLinkRts =
mempty
{ ghcOptLinkRts = toFlag True
Expand All @@ -425,7 +425,7 @@ linkFLib flib bi lbi (linkerOpts, rpaths) (wantedWays, buildOpts) targetDir runG
supportsFLinkRts = compilerVersion comp >= mkVersion [9, 0]
rtsInfo = extractRtsInfo lbi
rtsOptLinkLibs =
[ if way == DynWay
[ if withDynFLib
then
if threaded
then dynRtsThreadedLib (rtsDynamicInfo rtsInfo)
Expand All @@ -435,13 +435,21 @@ linkFLib flib bi lbi (linkerOpts, rpaths) (wantedWays, buildOpts) targetDir runG
then statRtsThreadedLib (rtsStaticInfo rtsInfo)
else statRtsVanillaLib (rtsStaticInfo rtsInfo)
]
withDynFLib =
case foreignLibType flib of
ForeignLibNativeShared ->
ForeignLibStandalone `notElem` foreignLibOptions flib
ForeignLibNativeStatic ->
False
ForeignLibTypeUnknown ->
cabalBug "unknown foreign lib type"

linkOpts :: BuildWay -> GhcOptions
linkOpts way = case foreignLibType flib of
ForeignLibNativeShared ->
(buildOpts way)
`mappend` linkerOpts
`mappend` rtsLinkOpts way
`mappend` rtsLinkOpts
`mappend` mempty
{ ghcOptLinkNoHsMain = toFlag True
, ghcOptShared = toFlag True
Expand All @@ -460,6 +468,7 @@ linkFLib flib bi lbi (linkerOpts, rpaths) (wantedWays, buildOpts) targetDir runG
-- soname on supported platforms. See also the note for
-- @flibBuildName@.
let buildName = flibBuildName lbi flib
-- There should not be more than one wanted way when building an flib
assert (Set.size wantedWays == 1) $
forM_ wantedWays $ \way -> do
runGhcProg (linkOpts way){ghcOptOutputFile = toFlag (targetDir </> buildName)}
Expand Down

0 comments on commit 0187e2f

Please sign in to comment.