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

Fix build ways for foreign libs #10433

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
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
29 changes: 16 additions & 13 deletions Cabal/src/Distribution/Simple/GHC/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Distribution.Simple.Flag (Flag)
import Distribution.Simple.GHC.Build.ExtraSources
import Distribution.Simple.GHC.Build.Link
import Distribution.Simple.GHC.Build.Modules
import Distribution.Simple.GHC.Build.Utils (compilerBuildWay, isHaskell)
import Distribution.Simple.GHC.Build.Utils (compilerBuildWay, isHaskell, withDynFLib)
import Distribution.Simple.LocalBuildInfo
import Distribution.Simple.Program.Builtin (ghcProgram)
import Distribution.Simple.Program.Db (requireProgram)
Expand Down Expand Up @@ -113,21 +113,24 @@ build numJobs pkg_descr pbci = do
(ghcProg, _) <- liftIO $ requireProgram verbosity ghcProgram (withPrograms lbi)

-- Ways which are wanted from configuration flags
let wantedWays@(wantedLibWays, _, wantedExeWay) = buildWays lbi
let wantedWays@(wantedLibWays, wantedFLibWay, wantedExeWay) = buildWays lbi

-- Ways which are needed due to the compiler configuration
let doingTH = usesTemplateHaskellOrQQ bi
defaultGhcWay = compilerBuildWay (buildCompiler pbci)
wantedLibBuildWays =
if isLib
then wantedLibWays isIndef
else [wantedExeWay]
finalLibBuildWays =
wantedLibBuildWays
++ [defaultGhcWay | doingTH && defaultGhcWay `notElem` wantedLibBuildWays]

liftIO $ info verbosity ("Wanted build ways(" ++ show isLib ++ "): " ++ show wantedLibBuildWays)
liftIO $ info verbosity ("Final lib build ways(" ++ show isLib ++ "): " ++ show finalLibBuildWays)
wantedModBuildWays = case buildComponent pbci of
CLib _ -> wantedLibWays isIndef
CFLib fl -> [wantedFLibWay (withDynFLib fl)]
CExe _ -> [wantedExeWay]
CTest _ -> [wantedExeWay]
CBench _ -> [wantedExeWay]
finalModBuildWays =
wantedModBuildWays
++ [defaultGhcWay | doingTH && defaultGhcWay `notElem` wantedModBuildWays]
compNameStr = showComponentName $ componentName $ buildComponent pbci

liftIO $ info verbosity ("Wanted module build ways(" ++ compNameStr ++ "): " ++ show wantedModBuildWays)
liftIO $ info verbosity ("Final module build ways(" ++ compNameStr ++ "): " ++ show finalModBuildWays)
-- We need a separate build and link phase, and C sources must be compiled
-- after Haskell modules, because C sources may depend on stub headers
-- generated from compiling Haskell modules (#842, #3294).
Expand All @@ -141,7 +144,7 @@ build numJobs pkg_descr pbci = do
| otherwise ->
(Nothing, Just mainFile)
Nothing -> (Nothing, Nothing)
buildOpts <- buildHaskellModules numJobs ghcProg hsMainFile inputModules buildTargetDir finalLibBuildWays pbci
buildOpts <- buildHaskellModules numJobs ghcProg hsMainFile inputModules buildTargetDir finalModBuildWays pbci
extraSources <- buildAllExtraSources nonHsMainFile ghcProg buildTargetDir wantedWays pbci
linkOrLoadComponent
ghcProg
Expand Down
4 changes: 2 additions & 2 deletions cabal-testsuite/PackageTests/ProfShared/setup.test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ main = do

let ls = lines (resultOutput r)

library_prefix = "Wanted build ways(True): "
executable_prefix = "Wanted build ways(False): "
library_prefix = "Wanted module build ways(library): "
executable_prefix = "Wanted module build ways(executable 'Prof'): "

get_ways prefix = map (drop (length prefix)) (filter (prefix `isPrefixOf`) ls)
library_ways = read_ways (get_ways library_prefix)
Expand Down
Loading