Skip to content

Commit

Permalink
build: Don't forget to nub extra sources
Browse files Browse the repository at this point in the history
In the refactor in the previous commits we stopped nubbing the extra
build sources, resulting in accidentally passing the same object file
more than once in some invocations.

This patch resolves this by joining the extra build sources as nublists
again.
  • Loading branch information
alt-romes committed Jan 29, 2024
1 parent d40b103 commit b9e1d8e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Cabal/src/Distribution/Simple/GHC/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Distribution.Simple.Program
import Distribution.Simple.Utils
import Distribution.Types.ComponentLocalBuildInfo (componentIsIndefinite)
import Distribution.Types.ParStrat
import Distribution.Utils.NubList (fromNubListR)
import System.Directory hiding (exeExtension)
import System.FilePath

Expand Down Expand Up @@ -136,4 +137,4 @@ build numJobs pkg_descr pbci = do
-- generated from compiling Haskell modules (#842, #3294).
buildOpts <- buildHaskellModules numJobs ghcProg pkg_descr buildTargetDir_absolute wantedWays pbci
extraSources <- buildAllExtraSources ghcProg buildTargetDir pbci
linkOrLoadComponent ghcProg pkg_descr extraSources (buildTargetDir, targetDir_absolute) (wantedWays, buildOpts) pbci
linkOrLoadComponent ghcProg pkg_descr (fromNubListR extraSources) (buildTargetDir, targetDir_absolute) (wantedWays, buildOpts) pbci
28 changes: 15 additions & 13 deletions Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Distribution.Simple.Flag
import qualified Distribution.Simple.GHC.Internal as Internal
import Distribution.Simple.Program.GHC
import Distribution.Simple.Utils
import Distribution.Utils.NubList

import Distribution.Types.BuildInfo
import Distribution.Types.Component
Expand All @@ -34,15 +35,16 @@ buildAllExtraSources
-- ^ The build directory for this target
-> PreBuildComponentInputs
-- ^ The context and component being built in it.
-> IO [FilePath]
-- ^ Returns the list of extra sources that were built
buildAllExtraSources = mconcat
[ buildCSources
, buildCxxSources
, buildJsSources
, buildAsmSources
, buildCmmSources
]
-> IO (NubListR FilePath)
-- ^ Returns the (nubbed) list of extra sources that were built
buildAllExtraSources =
mconcat
[ buildCSources
, buildCxxSources
, buildJsSources
, buildAsmSources
, buildCmmSources
]

buildCSources
, buildCxxSources
Expand All @@ -55,7 +57,7 @@ buildCSources
-- ^ The build directory for this target
-> PreBuildComponentInputs
-- ^ The context and component being built in it.
-> IO [FilePath]
-> IO (NubListR FilePath)
-- ^ Returns the list of extra sources that were built
buildCSources =
buildExtraSources
Expand Down Expand Up @@ -137,7 +139,7 @@ buildExtraSources
-- ^ The build directory for this target
-> PreBuildComponentInputs
-- ^ The context and component being built in it.
-> IO [FilePath]
-> IO (NubListR FilePath)
-- ^ Returns the list of extra sources that were built
buildExtraSources description componentSourceGhcOptions wantDyn viewSources ghcProg buildTargetDir =
\PreBuildComponentInputs{buildingWhat, localBuildInfo = lbi, targetInfo} ->
Expand Down Expand Up @@ -233,8 +235,8 @@ buildExtraSources description componentSourceGhcOptions wantDyn viewSources ghcP
in
-- build any sources
if (null sources || componentIsIndefinite clbi)
then return []
then return mempty
else do
info verbosity ("Building " ++ description ++ "...")
traverse_ buildAction sources
return sources
return (toNubListR sources)
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/GHC/Build/Link.hs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ linkLibrary
:: FilePath
-- ^ The library target build directory
-> [FilePath]
-- ^ The list of extra lib dirs that exist (aka cleaned)
-- ^ The list of extra lib dirs that exist (aka "cleaned")
-> PackageDescription
-- ^ The package description containing this library
-> Verbosity
Expand Down

0 comments on commit b9e1d8e

Please sign in to comment.