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

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Sat Dec 23 04:27:49 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
f7e21fab by Matthew Pickering at 2023-12-21T14:57:40+00: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.

- - - - -


7 changed files:

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


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
=====================================
@@ -118,7 +118,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)")' >> $@
@@ -189,7 +189,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/BinaryDist.hs
=====================================
@@ -125,6 +125,7 @@ installTo relocatable prefix = do
                 NotRelocatable -> []
     runBuilderWithCmdOptions env (Make bindistFilesDir) ["install"] [] []
 
+
 bindistRules :: Rules ()
 bindistRules = do
     root <- buildRootRules
@@ -188,7 +189,11 @@ bindistRules = do
             -- 2. Either make a symlink for the unversioned version or
             -- a wrapper script on platforms (windows) which don't support symlinks.
             if windowsHost
-              then createVersionWrapper pkg version_prog unversioned_install_path
+              then if pkg == unlit
+                      -- The unlit executable is a C executable already, wrapping it again causes
+                      -- paths to be double escaped, so we just copy this one as it is already small.
+                      then copyFile install_path unversioned_install_path
+                      else createVersionWrapper pkg version_prog unversioned_install_path
               else liftIO $ do
                 -- Use the IO versions rather than createFileLink because
                 -- we need to create a relative symlink.


=====================================
hadrian/src/Rules/Generate.hs
=====================================
@@ -387,7 +387,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
@@ -103,9 +103,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 ()


=====================================
m4/fp_settings.m4
=====================================
@@ -75,7 +75,7 @@ AC_DEFUN([FP_SETTINGS],
     fi
 
     if test "$HostOS" = "mingw32"; then
-        SettingsTouchCommand='$$topdir/bin/touchy.exe'
+        SettingsTouchCommand='$$topdir/../bin/touchy.exe'
     else
         SettingsTouchCommand='touch'
     fi
@@ -109,7 +109,7 @@ AC_DEFUN([FP_SETTINGS],
         SUBST_TOOLDIR([SettingsArCommand])
         SUBST_TOOLDIR([SettingsRanlibCommand])
         SUBST_TOOLDIR([SettingsWindresCommand])
-        SettingsTouchCommand='$$topdir/bin/touchy.exe'
+        SettingsTouchCommand='$$topdir/../bin/touchy.exe'
     fi
 
     # LLVM backend tools



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/f7e21fabffa1c61ce16687362fbb0b85921421a6
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/20231222/73419fdb/attachment-0001.html>


More information about the ghc-commits mailing list