From 4880c19ddde0443074bae0e071b37b6f36cbd19d Mon Sep 17 00:00:00 2001 From: Rodrigo Mesquita Date: Fri, 12 Jan 2024 19:14:41 +0000 Subject: [PATCH] worries.. about vanilla vs static Fix one more bug Vanilla being different from Static is kind of problematic --- Cabal/src/Distribution/Simple/GHC/Build.hs | 1 + Cabal/src/Distribution/Simple/GHC/Build/Link.hs | 4 +++- Cabal/src/Distribution/Simple/GHC/Build/Modules.hs | 7 ++++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Cabal/src/Distribution/Simple/GHC/Build.hs b/Cabal/src/Distribution/Simple/GHC/Build.hs index 9e3829803b0..48c10bc4097 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build.hs @@ -98,6 +98,7 @@ build numJobs pkg_descr = do let -- wantVanilla is underspecified, maybe we could deprecated it? (TODO) + -- wantVanilla vs wantStatic?? wantVanilla = if isLib then withVanillaLib lbi else False wantStatic = if isLib then withStaticLib lbi else withFullyStaticExe lbi wantDynamic = if isLib then withSharedLib lbi else withDynExe lbi diff --git a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs index 83ec70e0db3..aa940baf34b 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/Link.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/Link.hs @@ -411,7 +411,9 @@ linkExecutable (linkerOpts, rpaths) (wantedWays, buildOpts) targetDir targetName let baseOpts = buildOpts way linkOpts = (baseOpts `mappend` linkerOpts) - { ghcOptLinkNoHsMain = toFlag (ghcOptInputFiles baseOpts == mempty) + -- If there are no input Haskell files we pass -no-hs-main, and + -- assume there is a main function in another non-haskell object + { ghcOptLinkNoHsMain = toFlag (ghcOptInputFiles baseOpts == mempty && ghcOptInputScripts baseOpts == mempty) } & (if withDynExe lbi then \x -> x{ghcOptRPaths = rpaths} else id) comp = compiler lbi diff --git a/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs b/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs index 5aed06974e9..c292b8a6531 100644 --- a/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs +++ b/Cabal/src/Distribution/Simple/GHC/Build/Modules.hs @@ -255,8 +255,9 @@ buildHaskellModules numJobs ghcProg pkg_descr buildTargetDir wantedWays = do [buildStaticAndDynamicToo] ++ (runGhcProg . buildOpts <$> Set.toList neededWays \\ [StaticWay, VanillaWay, DynWay]) -- Otherwise, we need to ensure the defaultGhcWay is built first. + -- VanillaWay first otherwise (fromEnum lists vanilla first) | otherwise = - runGhcProg . buildOpts <$> sortOn (\w -> if w == defaultGhcWay then 0 else 1 :: Int) (Set.toList neededWays) + runGhcProg . buildOpts <$> sortOn (\w -> if w == defaultGhcWay then 0 else fromEnum w + 1) (Set.toList neededWays) buildStaticAndDynamicToo = do runGhcProg dynTooOpts @@ -275,8 +276,8 @@ buildHaskellModules numJobs ghcProg pkg_descr buildTargetDir wantedWays = do sequence_ orderedBuilds return buildOpts -data BuildWay = StaticWay | DynWay | ProfWay | VanillaWay - deriving (Eq, Ord, Show) +data BuildWay = VanillaWay | StaticWay | DynWay | ProfWay + deriving (Eq, Ord, Show, Enum) -- | Returns the object/interface extension prefix for the given build way (e.g. "dyn_" for 'DynWay') buildWayPrefix :: BuildWay -> String