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

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Fri Oct 6 11:11:18 UTC 2023



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


Commits:
f7d4a061 by Matthew Pickering at 2023-10-06T12:11:03+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.

- - - - -


5 changed files:

- compiler/GHC/Settings/IO.hs
- hadrian/bindist/Makefile
- hadrian/src/Packages.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Rules/Program.hs


Changes:

=====================================
compiler/GHC/Settings/IO.hs
=====================================
@@ -38,7 +38,7 @@ initSettings top_dir = do
   let installed :: FilePath -> FilePath
       installed file = top_dir </> file
       libexec :: FilePath -> FilePath
-      libexec file = top_dir </> "bin" </> file
+      libexec file = top_dir </> ".." </> "bin" </> file
       settingsFile = installed "settings"
 
       readFileSafe :: FilePath -> ExceptT SettingsError m String


=====================================
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)")' >> $@
@@ -188,7 +188,6 @@ install_lib: lib/settings
 		    $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \
 		esac; \
 	done; \
-	chmod ugo+rx "$$dest"/bin/*
 	# Work around #17418 on Darwin
 	if [ -e "${XATTR}" ]; then \
 		"${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \


=====================================
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/f7d4a06110babcb8113cf9ad9a23bc82ea76a2e3

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


More information about the ghc-commits mailing list