From a0e288b1faa934b814cc367e51c1fa86b0d8da71 Mon Sep 17 00:00:00 2001 From: Matthew Pickering Date: Wed, 18 Aug 2021 16:41:02 +0100 Subject: hadrian: Use ghc version as suffix for all executables ``` [matt@nixos:~/ghc-unique-spin]$ ls _build/bindist/ghc-9.3.20210813-x86_64-unknown-linux/bin/ ghc haddock runghc ghc-9.3.20210813 haddock-ghc-9.3.20210813 runghc-9.3.20210813 ghc-iserv hp2ps runhaskell ghc-iserv-dyn hp2ps-ghc-9.3.20210813 runhaskell-9.3.20210813 ghc-iserv-dyn-ghc-9.3.20210813 hpc unlit ghc-iserv-ghc-9.3.20210813 hpc-ghc-9.3.20210813 unlit-ghc-9.3.20210813 ghc-pkg hsc2hs ghc-pkg-9.3.20210813 hsc2hs-ghc-9.3.20210813 [matt@nixos:~/ghc-unique-spin]$ ls _build/bindist/ghc-9.3.20210813-x86_64-unknown-linux/wrappers/ ghc ghc-pkg-9.3.20210813 hpc runghc-9.3.20210813 ghc-9.3.20210813 haddock hpc-ghc-9.3.20210813 runhaskell ghci haddock-ghc-9.3.20210813 hsc2hs runhaskell-9.3.20210813 ghci-9.3.20210813 hp2ps hsc2hs-ghc-9.3.20210813 ghc-pkg hp2ps-ghc-9.3.20210813 runghc ``` See the discussion on #19571 where we decided that it was most sensible to use the same version number as a suffix for all executables. For those whose version number is different to normal (for example, haddock as it's own versioning scheme) the additional "ghc" suffix is used. Cabal already knows to look for this suffix so should work nicely with existing tooling. --- hadrian/src/Rules/BinaryDist.hs | 38 ++++++++++++++++++++++++-------------- testsuite/driver/testlib.py | 2 ++ 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs index 8cd7923547..43a0f62f8c 100644 --- a/hadrian/src/Rules/BinaryDist.hs +++ b/hadrian/src/Rules/BinaryDist.hs @@ -15,8 +15,6 @@ import Target import Utilities import qualified System.Directory.Extra as IO import Data.Either -import Hadrian.Oracles.Cabal -import Hadrian.Haskell.Cabal.Type {- Note [Binary distributions] @@ -129,7 +127,7 @@ bindistRules = do (lib_targets, bin_targets) <- partitionEithers <$> mapM pkgTarget all_pkgs cross <- flag CrossCompiling iserv_targets <- if cross then pure [] else iservBins - need (lib_targets ++ (map (\(_, p, _) -> p) (bin_targets ++ iserv_targets))) + need (lib_targets ++ (map (\(_, p) -> p) (bin_targets ++ iserv_targets))) version <- setting ProjectVersion targetPlatform <- setting TargetPlatformFull @@ -148,10 +146,13 @@ bindistRules = do createDirectory (bindistFilesDir -/- "bin") createDirectory (bindistFilesDir -/- "lib") -- Also create wrappers with version suffixes (#20074) - forM_ (bin_targets ++ iserv_targets) $ \(pkg, prog_path, ver) -> do + forM_ (bin_targets ++ iserv_targets) $ \(pkg, prog_path) -> do let orig_filename = takeFileName prog_path (name, ext) = splitExtensions orig_filename - version_prog = name ++ "-" ++ ver ++ ext + suffix = if useGhcPrefix pkg + then "ghc-" ++ version + else version + version_prog = name ++ "-" ++ suffix ++ ext -- Install the actual executable with a version suffix install_path = bindistFilesDir -/- "bin" -/- version_prog -- The wrapper doesn't have a version @@ -176,7 +177,7 @@ bindistRules = do let unversioned_runhaskell_path = bindistFilesDir -/- "bin" -/- "runhaskell" ++ ext versioned_runhaskell_path = - bindistFilesDir -/- "bin" -/- "runhaskell" ++ "-" ++ ver ++ ext + bindistFilesDir -/- "bin" -/- "runhaskell" ++ "-" ++ version ++ ext if windowsHost then do createVersionWrapper version_prog unversioned_runhaskell_path @@ -229,12 +230,15 @@ bindistRules = do -- other machine. need $ map (bindistFilesDir -/-) (["configure", "Makefile"] ++ bindistInstallFiles) - forM_ bin_targets $ \(pkg, _, ver) -> do + forM_ bin_targets $ \(pkg, _) -> do needed_wrappers <- pkgToWrappers pkg forM_ needed_wrappers $ \wrapper_name -> do + let suffix = if useGhcPrefix pkg + then "ghc-" ++ version + else version wrapper_content <- wrapper wrapper_name let unversioned_wrapper_path = bindistFilesDir -/- "wrappers" -/- wrapper_name - versioned_wrapper = wrapper_name ++ "-" ++ ver + versioned_wrapper = wrapper_name ++ "-" ++ suffix versioned_wrapper_path = bindistFilesDir -/- "wrappers" -/- versioned_wrapper -- Write the wrapper to the versioned path writeFile' versioned_wrapper_path wrapper_content @@ -326,13 +330,20 @@ bindistInstallFiles = -- for all libraries and programs that are needed for a complete build. -- For libraries, it returns the path to the @.conf@ file in the package -- database. For programs, it returns the path to the compiled executable. -pkgTarget :: Package -> Action (Either FilePath (Package, FilePath, String)) +pkgTarget :: Package -> Action (Either FilePath (Package, FilePath)) pkgTarget pkg | isLibrary pkg = Left <$> pkgConfFile (vanillaContext Stage1 pkg) | otherwise = do path <- programPath =<< programContext Stage1 pkg - version <- version <$> readPackageData pkg - return (Right (pkg, path, version)) + return (Right (pkg, path)) + +useGhcPrefix :: Package -> Bool +useGhcPrefix pkg + | pkg == ghc = False + | pkg == runGhc = False + | pkg == ghcPkg = False + | pkg == ghciWrapper = False + | otherwise = True -- | Which wrappers point to a specific package @@ -403,11 +414,10 @@ ghciScriptWrapper = pure $ unlines -- the package to be built, since here we're generating 3 different -- executables out of just one package, so we need to specify all 3 contexts -- explicitly and 'need' the result of building them. -iservBins :: Action [(Package, FilePath, String)] +iservBins :: Action [(Package, FilePath)] iservBins = do rtsways <- interpretInContext (vanillaContext Stage1 ghc) getRtsWays - ver <- version <$> readPackageData iserv - traverse (fmap (\p -> (iserv, p, ver)) . programPath) + traverse (fmap (\p -> (iserv, p)) . programPath) [ Context Stage1 iserv w | w <- [vanilla, profiling, dynamic] , w `elem` rtsways diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index d776c12bb3..fba69533e0 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -2226,6 +2226,8 @@ def normalise_errmsg(s: str) -> str: s = re.sub('runghc-[0-9.]+', 'runghc', s) s = re.sub('hpc-[0-9.]+', 'hpc', s) s = re.sub('ghc-pkg-[0-9.]+', 'ghc-pkg', s) + # hpc executable is given ghc suffix + s = re.sub('hpc-ghc', 'hpc', s) # Error messages sometimes contain ghc-bignum implementation package s = re.sub('ghc-bignum-[0-9.]+', 'ghc-bignum-', s) -- cgit v1.2.1