[Git][ghc/ghc][wip/hadrian-cross-stage2] 3 commits: Remove libbin copy

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Thu Oct 5 23:04:37 UTC 2023



Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC


Commits:
c555e89b by Matthew Pickering at 2023-10-06T00:03:38+01:00
Remove libbin copy

- - - - -
746b0cbc by Matthew Pickering at 2023-10-06T00:03:38+01:00
hadrian: Build all executables in bin/ folder

In the end the bindist creation logic copies them all into the bin
folder. There is no benefit to building a specific few binaries in the
lib/bin folder anymore.

This also removes the ad-hoc logic to copy the touchy and unlit
executables from stage0 into stage1. It takes <1s to build so we might
as well just build it.

- - - - -
5a8cfaa3 by Matthew Pickering at 2023-10-06T00:03:38+01:00
fix

- - - - -


4 changed files:

- hadrian/src/Packages.hs
- hadrian/src/Rules/BinaryDist.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Rules/Program.hs


Changes:

=====================================
hadrian/src/Packages.hs
=====================================
@@ -26,7 +26,6 @@ import Hadrian.Utilities
 import Base
 import Context
 import Oracles.Setting
-import GHC.Toolchain.Target (targetPlatformTriple)
 
 -- | These are all GHC packages we know about. Build rules will be generated for
 -- all of them. However, not all of these packages will be built. For example,
@@ -206,14 +205,8 @@ programBasename way package
 -- | The 'FilePath' to a program executable in a given 'Context'.
 programPath :: Context -> Action FilePath
 programPath context at Context {..} = do
-    -- TODO: The @touchy@ utility lives in the @lib/bin@ directory instead of
-    -- @bin@, which is likely just a historical accident that should be fixed.
-    -- See: https://github.com/snowleopard/hadrian/issues/570
-    -- Likewise for @iserv@ and @unlit at .
     name <- programName context
-    path <- if package `elem` [iserv, touchy, unlit]
-              then stageLibPath stage <&> (-/- "bin")
-              else stageBinPath stage
+    path <- stageBinPath stage
     return $ path -/- name <.> exe
 
 -- TODO: Move @timeout@ to the @util@ directory and build in a more standard


=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -171,7 +171,6 @@ buildBinDistDir root conf at BindistConfig{..} = do
     -- let rtsDir  = "rts"
 
     let ghcBuildDir      = root -/- stageString library_stage
-        ghcLibBinBuildDir = root -/- stageString executable_stage -/- "lib" -/- "bin"
         bindistFilesDir  = root -/- "bindist" -/- ghcVersionPretty
         ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform
         rtsIncludeDir    = ghcBuildDir -/- "lib" -/- distDir -/- rtsDir
@@ -229,9 +228,6 @@ buildBinDistDir root conf at BindistConfig{..} = do
               IO.createFileLink version_prog versioned_runhaskell_path
 
     copyDirectory (ghcBuildDir -/- "lib") bindistFilesDir
-    ld <- liftIO $ IO.listDirectory ghcLibBinBuildDir
-    traceShowM ld
-    copyDirectory ghcLibBinBuildDir bindistFilesDir
     copyDirectory (rtsIncludeDir)         bindistFilesDir
     when windowsHost $ createGhcii (bindistFilesDir -/- "bin")
 


=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -402,7 +402,7 @@ generateSettings = do
         , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand)
         , ("touch command", expr $ settingsFileSetting ToolchainSetting_TouchCommand)
         , ("windres command", queryTarget stage (maybe "/bin/false" prgPath . tgtWindres)) -- TODO: /bin/false is not available on many distributions by default, but we keep it as it were before the ghc-toolchain patch. Fix-me.
-        , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit })))
+        , ("unlit command", ("$topdir/../bin/" <>) <$> expr (programName (ctx { Context.package = unlit })))
         , ("cross compiling", expr $ yesNo <$> crossStage (predStage stage))
         , ("target platform string", queryTarget stage targetPlatformTriple)
         , ("target os",        queryTarget stage (show . archOS_OS . tgtArchOs))


=====================================
hadrian/src/Rules/Program.hs
=====================================
@@ -38,7 +38,7 @@ buildProgramRules rs = do
     -- Rules for programs that are actually built by hadrian.
     forM_ allStages $ \stage ->
         [ root -/- stageString stage -/- "bin"     -/- "*"
-        , root -/- stageString stage -/- "lib/bin" -/- "*" ] |%> \bin -> do
+        ] |%> \bin -> do
             programContexts <- getProgramContexts stage
             case lookupProgramContext bin programContexts of
                 Nothing  -> error $ "Unknown program " ++ show bin
@@ -97,13 +97,7 @@ buildProgram bin ctx@(Context{..}) rs = do
   -- so we use pkgRegisteredLibraryFile instead.
   registerPackages =<< contextDependencies ctx
 
-  cross <- flag CrossCompiling
-  case (cross, stage) of
-    -- MP: Why do we copy these? Seems like we should just build them again.
-    (False, s) | s > stage0InTree && (package `elem` [touchy, unlit]) -> do
-        srcDir <- stageLibPath stage0InTree <&> (-/- "bin")
-        copyFile (srcDir -/- takeFileName bin) bin
-    _ -> buildBinary rs bin ctx
+  buildBinary rs bin ctx
 
 buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action ()
 buildBinary rs bin context at Context {..} = do



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7770b1b84d77be3149f974efc12e09acc85f0f60...5a8cfaa30b12310321cd0db3086b5474d55255fa

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/7770b1b84d77be3149f974efc12e09acc85f0f60...5a8cfaa30b12310321cd0db3086b5474d55255fa
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20231005/8004e067/attachment-0001.html>


More information about the ghc-commits mailing list