[Git][ghc/ghc][wip/libbin] hadrian: Build all executables in bin/ folder

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Thu Oct 5 15:53:12 UTC 2023



Matthew Pickering pushed to branch wip/libbin at Glasgow Haskell Compiler / GHC


Commits:
c19c47d2 by Matthew Pickering at 2023-10-05T16:52:30+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.

- - - - -


4 changed files:

- hadrian/bindist/Makefile
- hadrian/src/Packages.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Rules/Program.hs


Changes:

=====================================
hadrian/bindist/Makefile
=====================================
@@ -117,7 +117,7 @@ lib/settings : config.mk
 	@echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@
 	@echo ',("touch command", "$(SettingsTouchCommand)")' >> $@
 	@echo ',("windres command", "$(SettingsWindresCommand)")' >> $@
-	@echo ',("unlit command", "$$topdir/bin/$(CrossCompilePrefix)unlit")' >> $@
+	@echo ',("unlit command", "$$topdir/../bin/$(CrossCompilePrefix)unlit")' >> $@
 	@echo ',("cross compiling", "$(CrossCompiling)")' >> $@
 	@echo ',("target platform string", "$(TARGETPLATFORM)")' >> $@
 	@echo ',("target os", "$(HaskellTargetOs)")' >> $@


=====================================
hadrian/src/Packages.hs
=====================================
@@ -202,14 +202,8 @@ programName Context {..} = do
 -- | 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/Generate.hs
=====================================
@@ -469,7 +469,7 @@ generateSettings = do
         , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand)
         , ("touch command", expr $ settingsFileSetting ToolchainSetting_TouchCommand)
         , ("windres command", queryTarget (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 <$> flag CrossCompiling)
         , ("target platform string", queryTarget targetPlatformTriple)
         , ("target os",        queryTarget (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
@@ -105,9 +105,6 @@ buildProgram bin ctx@(Context{..}) rs = do
     (True, s) | s > stage0InTree -> do
         srcDir <- buildRoot <&> (-/- (stageString stage0InTree -/- "bin"))
         copyFile (srcDir -/- takeFileName bin) bin
-    (False, s) | s > stage0InTree && (package `elem` [touchy, unlit]) -> do
-        srcDir <- stageLibPath stage0InTree <&> (-/- "bin")
-        copyFile (srcDir -/- takeFileName bin) bin
     _ -> buildBinary rs bin ctx
 
 buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action ()



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c19c47d297000a73587c3f5c8ed2dc10fd54f58d

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c19c47d297000a73587c3f5c8ed2dc10fd54f58d
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/06278a1e/attachment-0001.html>


More information about the ghc-commits mailing list