Skip to content
Snippets Groups Projects
Commit f7e21fab authored by Matthew Pickering's avatar Matthew Pickering
Browse files

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.
parent f4b53538
No related branches found
No related tags found
No related merge requests found
...@@ -38,7 +38,7 @@ initSettings top_dir = do ...@@ -38,7 +38,7 @@ initSettings top_dir = do
let installed :: FilePath -> FilePath let installed :: FilePath -> FilePath
installed file = top_dir </> file installed file = top_dir </> file
libexec :: FilePath -> FilePath libexec :: FilePath -> FilePath
libexec file = top_dir </> "bin" </> file libexec file = top_dir </> ".." </> "bin" </> file
settingsFile = installed "settings" settingsFile = installed "settings"
readFileSafe :: FilePath -> ExceptT SettingsError m String readFileSafe :: FilePath -> ExceptT SettingsError m String
......
...@@ -118,7 +118,7 @@ lib/settings : config.mk ...@@ -118,7 +118,7 @@ lib/settings : config.mk
@echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@
@echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@
@echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@
@echo ',("unlit command", "$$topdir/bin/$(CrossCompilePrefix)unlit")' >> $@ @echo ',("unlit command", "$$topdir/../bin/$(CrossCompilePrefix)unlit")' >> $@
@echo ',("cross compiling", "$(CrossCompiling)")' >> $@ @echo ',("cross compiling", "$(CrossCompiling)")' >> $@
@echo ',("target platform string", "$(TARGETPLATFORM)")' >> $@ @echo ',("target platform string", "$(TARGETPLATFORM)")' >> $@
@echo ',("target os", "$(HaskellTargetOs)")' >> $@ @echo ',("target os", "$(HaskellTargetOs)")' >> $@
...@@ -189,7 +189,6 @@ install_lib: lib/settings ...@@ -189,7 +189,6 @@ install_lib: lib/settings
$(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \ $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ;; \
esac; \ esac; \
done; \ done; \
chmod ugo+rx "$$dest"/bin/*
# Work around #17418 on Darwin # Work around #17418 on Darwin
if [ -e "${XATTR}" ]; then \ if [ -e "${XATTR}" ]; then \
"${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \ "${XATTR}" -c -r "$(DESTDIR)$(ActualLibsDir)"; \
......
...@@ -202,14 +202,8 @@ programName Context {..} = do ...@@ -202,14 +202,8 @@ programName Context {..} = do
-- | The 'FilePath' to a program executable in a given 'Context'. -- | The 'FilePath' to a program executable in a given 'Context'.
programPath :: Context -> Action FilePath programPath :: Context -> Action FilePath
programPath context@Context {..} = do programPath context@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@.
name <- programName context name <- programName context
path <- if package `elem` [iserv, touchy, unlit] path <- stageBinPath stage
then stageLibPath stage <&> (-/- "bin")
else stageBinPath stage
return $ path -/- name <.> exe return $ path -/- name <.> exe
-- TODO: Move @timeout@ to the @util@ directory and build in a more standard -- TODO: Move @timeout@ to the @util@ directory and build in a more standard
......
...@@ -125,6 +125,7 @@ installTo relocatable prefix = do ...@@ -125,6 +125,7 @@ installTo relocatable prefix = do
NotRelocatable -> [] NotRelocatable -> []
runBuilderWithCmdOptions env (Make bindistFilesDir) ["install"] [] [] runBuilderWithCmdOptions env (Make bindistFilesDir) ["install"] [] []
bindistRules :: Rules () bindistRules :: Rules ()
bindistRules = do bindistRules = do
root <- buildRootRules root <- buildRootRules
...@@ -188,7 +189,11 @@ bindistRules = do ...@@ -188,7 +189,11 @@ bindistRules = do
-- 2. Either make a symlink for the unversioned version or -- 2. Either make a symlink for the unversioned version or
-- a wrapper script on platforms (windows) which don't support symlinks. -- a wrapper script on platforms (windows) which don't support symlinks.
if windowsHost 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 else liftIO $ do
-- Use the IO versions rather than createFileLink because -- Use the IO versions rather than createFileLink because
-- we need to create a relative symlink. -- we need to create a relative symlink.
......
...@@ -387,7 +387,7 @@ generateSettings = do ...@@ -387,7 +387,7 @@ generateSettings = do
, ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand) , ("install_name_tool command", expr $ settingsFileSetting ToolchainSetting_InstallNameToolCommand)
, ("touch command", expr $ settingsFileSetting ToolchainSetting_TouchCommand) , ("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. , ("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) , ("cross compiling", expr $ yesNo <$> flag CrossCompiling)
, ("target platform string", queryTarget targetPlatformTriple) , ("target platform string", queryTarget targetPlatformTriple)
, ("target os", queryTarget (show . archOS_OS . tgtArchOs)) , ("target os", queryTarget (show . archOS_OS . tgtArchOs))
......
...@@ -38,7 +38,7 @@ buildProgramRules rs = do ...@@ -38,7 +38,7 @@ buildProgramRules rs = do
-- Rules for programs that are actually built by hadrian. -- Rules for programs that are actually built by hadrian.
forM_ allStages $ \stage -> forM_ allStages $ \stage ->
[ root -/- stageString stage -/- "bin" -/- "*" [ root -/- stageString stage -/- "bin" -/- "*"
, root -/- stageString stage -/- "lib/bin" -/- "*" ] |%> \bin -> do ] |%> \bin -> do
programContexts <- getProgramContexts stage programContexts <- getProgramContexts stage
case lookupProgramContext bin programContexts of case lookupProgramContext bin programContexts of
Nothing -> error $ "Unknown program " ++ show bin Nothing -> error $ "Unknown program " ++ show bin
...@@ -103,9 +103,6 @@ buildProgram bin ctx@(Context{..}) rs = do ...@@ -103,9 +103,6 @@ buildProgram bin ctx@(Context{..}) rs = do
(True, s) | s > stage0InTree -> do (True, s) | s > stage0InTree -> do
srcDir <- buildRoot <&> (-/- (stageString stage0InTree -/- "bin")) srcDir <- buildRoot <&> (-/- (stageString stage0InTree -/- "bin"))
copyFile (srcDir -/- takeFileName bin) 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 rs bin ctx
buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action () buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action ()
......
...@@ -75,7 +75,7 @@ AC_DEFUN([FP_SETTINGS], ...@@ -75,7 +75,7 @@ AC_DEFUN([FP_SETTINGS],
fi fi
if test "$HostOS" = "mingw32"; then if test "$HostOS" = "mingw32"; then
SettingsTouchCommand='$$topdir/bin/touchy.exe' SettingsTouchCommand='$$topdir/../bin/touchy.exe'
else else
SettingsTouchCommand='touch' SettingsTouchCommand='touch'
fi fi
...@@ -109,7 +109,7 @@ AC_DEFUN([FP_SETTINGS], ...@@ -109,7 +109,7 @@ AC_DEFUN([FP_SETTINGS],
SUBST_TOOLDIR([SettingsArCommand]) SUBST_TOOLDIR([SettingsArCommand])
SUBST_TOOLDIR([SettingsRanlibCommand]) SUBST_TOOLDIR([SettingsRanlibCommand])
SUBST_TOOLDIR([SettingsWindresCommand]) SUBST_TOOLDIR([SettingsWindresCommand])
SettingsTouchCommand='$$topdir/bin/touchy.exe' SettingsTouchCommand='$$topdir/../bin/touchy.exe'
fi fi
# LLVM backend tools # LLVM backend tools
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment