diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-11-21 13:27:23 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2022-11-21 13:27:23 -0500 |
commit | 3a56337be36496ae4c11eb9afff092ebc0283256 (patch) | |
tree | a8b461b6f7ac334a3d7a4e391265c22bdee8aaae | |
parent | 451aeac3b07f171f148995717d0d9a1eefe08f0e (diff) | |
download | haskell-wip/drop-touch.tar.gz |
Drop dependence on `touch`wip/drop-touch
This drops GHC's dependence on the `touch` program, instead implementing
it within GHC. This eliminates an external dependency and means that we
have one fewer program to keep track of in the `configure` script
-rw-r--r-- | compiler/GHC/Driver/Main.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Driver/Pipeline/Execute.hs | 9 | ||||
-rw-r--r-- | compiler/GHC/Driver/Session.hs | 5 | ||||
-rw-r--r-- | compiler/GHC/Settings.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Settings/IO.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/SysTools/Tasks.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Utils/Touch.hs | 29 | ||||
-rw-r--r-- | compiler/ghc.cabal.in | 1 | ||||
-rw-r--r-- | hadrian/bindist/Makefile | 1 | ||||
-rw-r--r-- | hadrian/bindist/config.mk.in | 1 | ||||
-rw-r--r-- | hadrian/cfg/system.config.in | 1 | ||||
-rw-r--r-- | hadrian/src/Builder.hs | 2 | ||||
-rw-r--r-- | hadrian/src/Hadrian/Builder.hs | 4 | ||||
-rw-r--r-- | hadrian/src/Oracles/Setting.hs | 2 | ||||
-rw-r--r-- | hadrian/src/Packages.hs | 19 | ||||
-rw-r--r-- | hadrian/src/Rules/Generate.hs | 1 | ||||
-rw-r--r-- | hadrian/src/Rules/Program.hs | 2 | ||||
-rw-r--r-- | hadrian/src/Settings/Default.hs | 11 | ||||
-rw-r--r-- | m4/fp_settings.m4 | 8 | ||||
-rw-r--r-- | utils/touchy/Makefile | 37 | ||||
-rw-r--r-- | utils/touchy/touchy.c | 123 | ||||
-rw-r--r-- | utils/touchy/touchy.cabal | 15 |
22 files changed, 54 insertions, 230 deletions
diff --git a/compiler/GHC/Driver/Main.hs b/compiler/GHC/Driver/Main.hs index 5ca7487c27..8fcb687822 100644 --- a/compiler/GHC/Driver/Main.hs +++ b/compiler/GHC/Driver/Main.hs @@ -250,6 +250,7 @@ import GHC.Utils.Outputable import GHC.Utils.Misc import GHC.Utils.Logger import GHC.Utils.TmpFs +import GHC.Utils.Touch import GHC.Data.FastString import GHC.Data.Bag @@ -1263,7 +1264,7 @@ hscMaybeWriteIface logger dflags is_simple iface old_iface mod_location = do -- .hie files. let hie_file = ml_hie_file mod_location whenM (doesFileExist hie_file) $ - GHC.SysTools.touch logger dflags "Touching hie file" hie_file + GHC.Utils.Touch.touch hie_file else -- See Note [Strictness in ModIface] forceModIface iface diff --git a/compiler/GHC/Driver/Pipeline/Execute.hs b/compiler/GHC/Driver/Pipeline/Execute.hs index 2a1e877292..b1a9660647 100644 --- a/compiler/GHC/Driver/Pipeline/Execute.hs +++ b/compiler/GHC/Driver/Pipeline/Execute.hs @@ -74,6 +74,7 @@ import GHC.Linker.ExtraObj import GHC.Linker.Dynamic import Data.Version import GHC.Utils.Panic +import GHC.Utils.Touch import GHC.Unit.Module.Env import GHC.Driver.Env.KnotVars import GHC.Driver.Config.Finder @@ -529,7 +530,7 @@ runHscBackendPhase pipe_env hsc_env mod_name src_flavour location result = do -- In the case of hs-boot files, generate a dummy .o-boot -- stamp file for the benefit of Make - HsBootFile -> touchObjectFile logger dflags o_file + HsBootFile -> touchObjectFile o_file HsSrcFile -> panic "HscUpdate not relevant for HscSrcFile" return ([], iface, emptyHomeModInfoLinkable, o_file) @@ -1148,10 +1149,10 @@ generateMacros prefix name version = -touchObjectFile :: Logger -> DynFlags -> FilePath -> IO () -touchObjectFile logger dflags path = do +touchObjectFile :: FilePath -> IO () +touchObjectFile path = do createDirectoryIfMissing True $ takeDirectory path - GHC.SysTools.touch logger dflags "Touching object file" path + GHC.Utils.Touch.touch path -- Note [-fPIC for assembler] -- ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/compiler/GHC/Driver/Session.hs b/compiler/GHC/Driver/Session.hs index 3e205402e9..56a90d064d 100644 --- a/compiler/GHC/Driver/Session.hs +++ b/compiler/GHC/Driver/Session.hs @@ -95,7 +95,6 @@ module GHC.Driver.Session ( sPgm_l, sPgm_lm, sPgm_dll, - sPgm_T, sPgm_windres, sPgm_ar, sPgm_ranlib, @@ -129,7 +128,7 @@ module GHC.Driver.Session ( ghcUsagePath, ghciUsagePath, topDir, versionedAppDir, versionedFilePath, extraGccViaCFlags, globalPackageDatabasePath, - pgm_L, pgm_P, pgm_F, pgm_c, pgm_cxx, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_T, + pgm_L, pgm_P, pgm_F, pgm_c, pgm_cxx, pgm_a, pgm_l, pgm_lm, pgm_dll, pgm_windres, pgm_ar, pgm_otool, pgm_install_name_tool, pgm_ranlib, pgm_lo, pgm_lc, pgm_lcc, pgm_i, opt_L, opt_P, opt_F, opt_c, opt_cxx, opt_a, opt_l, opt_lm, opt_i, @@ -824,8 +823,6 @@ pgm_lm :: DynFlags -> Maybe (String,[Option]) pgm_lm dflags = toolSettings_pgm_lm $ toolSettings dflags pgm_dll :: DynFlags -> (String,[Option]) pgm_dll dflags = toolSettings_pgm_dll $ toolSettings dflags -pgm_T :: DynFlags -> String -pgm_T dflags = toolSettings_pgm_T $ toolSettings dflags pgm_windres :: DynFlags -> String pgm_windres dflags = toolSettings_pgm_windres $ toolSettings dflags pgm_lcc :: DynFlags -> (String,[Option]) diff --git a/compiler/GHC/Settings.hs b/compiler/GHC/Settings.hs index 291c77b860..37bbf8bad3 100644 --- a/compiler/GHC/Settings.hs +++ b/compiler/GHC/Settings.hs @@ -32,7 +32,6 @@ module GHC.Settings , sPgm_l , sPgm_lm , sPgm_dll - , sPgm_T , sPgm_windres , sPgm_ar , sPgm_otool @@ -105,7 +104,6 @@ data ToolSettings = ToolSettings -- merging, hence the 'Maybe'. See Note [Object merging] in -- "GHC.Driver.Pipeline.Execute" for details. , toolSettings_pgm_dll :: (String, [Option]) - , toolSettings_pgm_T :: String , toolSettings_pgm_windres :: String , toolSettings_pgm_ar :: String , toolSettings_pgm_otool :: String @@ -216,8 +214,6 @@ sPgm_lm :: Settings -> Maybe (String, [Option]) sPgm_lm = toolSettings_pgm_lm . sToolSettings sPgm_dll :: Settings -> (String, [Option]) sPgm_dll = toolSettings_pgm_dll . sToolSettings -sPgm_T :: Settings -> String -sPgm_T = toolSettings_pgm_T . sToolSettings sPgm_windres :: Settings -> String sPgm_windres = toolSettings_pgm_windres . sToolSettings sPgm_ar :: Settings -> String diff --git a/compiler/GHC/Settings/IO.hs b/compiler/GHC/Settings/IO.hs index 074b9a791c..4889bbcd31 100644 --- a/compiler/GHC/Settings/IO.hs +++ b/compiler/GHC/Settings/IO.hs @@ -112,8 +112,6 @@ initSettings top_dir = do install_name_tool_path <- getToolSetting "install_name_tool command" ranlib_path <- getToolSetting "ranlib command" - touch_path <- getToolSetting "touch command" - mkdll_prog <- getToolSetting "dllwrap command" let mkdll_args = [] @@ -177,7 +175,6 @@ initSettings top_dir = do , toolSettings_pgm_l = (ld_prog, ld_args) , toolSettings_pgm_lm = ld_r , toolSettings_pgm_dll = (mkdll_prog,mkdll_args) - , toolSettings_pgm_T = touch_path , toolSettings_pgm_windres = windres_path , toolSettings_pgm_ar = ar_path , toolSettings_pgm_otool = otool_path diff --git a/compiler/GHC/SysTools/Tasks.hs b/compiler/GHC/SysTools/Tasks.hs index a1846980a1..1fc82cad45 100644 --- a/compiler/GHC/SysTools/Tasks.hs +++ b/compiler/GHC/SysTools/Tasks.hs @@ -376,6 +376,3 @@ runWindres logger dflags args = traceSystoolCommand logger "windres" $ do mb_env <- getGccEnv cc_args runSomethingFiltered logger id "Windres" windres (opts ++ args) Nothing mb_env -touch :: Logger -> DynFlags -> String -> String -> IO () -touch logger dflags purpose arg = traceSystoolCommand logger "touch" $ - runSomething logger purpose (pgm_T dflags) [FileOption "" arg] diff --git a/compiler/GHC/Utils/Touch.hs b/compiler/GHC/Utils/Touch.hs new file mode 100644 index 0000000000..b6181584f0 --- /dev/null +++ b/compiler/GHC/Utils/Touch.hs @@ -0,0 +1,29 @@ +{-# LANGUAGE CPP #-} + +module GHC.Utils.Touch (touch) where + +import GHC.Prelude + +#if defined(mingw32_HOST_OS) +import System.Win32.File +import System.Win32.Time +#else +import System.Posix.Files +import System.Posix.IO +#endif + +-- | Set the mtime of the given file to the current time. +touch :: FilePath -> IO () +touch file = do +#if defined(mingw32_HOST_OS) + hdl <- createFile file gENERIC_WRITE fILE_SHARE_NONE Nothing oPEN_ALWAYS fILE_ATTRIBUTE_NORMAL Nothing + t <- getSystemTimeAsFileTime + setFileTime hdl Nothing Nothing (Just t) + closeHandle hdl +#else + let oflags = defaultFileFlags { noctty = True } + fd <- openFd file WriteOnly (Just 0o666) oflags + touchFd fd + closeFd fd +#endif + diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in index a867801951..2825bda8d6 100644 --- a/compiler/ghc.cabal.in +++ b/compiler/ghc.cabal.in @@ -814,6 +814,7 @@ Library GHC.Utils.Ppr GHC.Utils.Ppr.Colour GHC.Utils.TmpFs + GHC.Utils.Touch GHC.Utils.Trace GHC.Wasm.ControlFlow GHC.Wasm.ControlFlow.FromCmm diff --git a/hadrian/bindist/Makefile b/hadrian/bindist/Makefile index 215c2665d9..0dda9776b3 100644 --- a/hadrian/bindist/Makefile +++ b/hadrian/bindist/Makefile @@ -102,7 +102,6 @@ lib/settings : @echo ',("ranlib command", "$(SettingsRanlibCommand)")' >> $@ @echo ',("otool command", "$(SettingsOtoolCommand)")' >> $@ @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@ - @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@ @echo ',("dllwrap command", "$(SettingsDllWrapCommand)")' >> $@ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@ @echo ',("unlit command", "$$topdir/bin/unlit")' >> $@ diff --git a/hadrian/bindist/config.mk.in b/hadrian/bindist/config.mk.in index c76c1c9414..8bfedacf7c 100644 --- a/hadrian/bindist/config.mk.in +++ b/hadrian/bindist/config.mk.in @@ -273,7 +273,6 @@ SettingsRanlibCommand = @SettingsRanlibCommand@ SettingsDllWrapCommand = @SettingsDllWrapCommand@ SettingsWindresCommand = @SettingsWindresCommand@ SettingsLibtoolCommand = @SettingsLibtoolCommand@ -SettingsTouchCommand = @SettingsTouchCommand@ SettingsClangCommand = @SettingsClangCommand@ SettingsLlcCommand = @SettingsLlcCommand@ SettingsOptCommand = @SettingsOptCommand@ diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in index 0541d90138..ddf4975bff 100644 --- a/hadrian/cfg/system.config.in +++ b/hadrian/cfg/system.config.in @@ -159,7 +159,6 @@ settings-otool-command = @SettingsOtoolCommand@ settings-install_name_tool-command = @SettingsInstallNameToolCommand@ settings-dll-wrap-command = @SettingsDllWrapCommand@ settings-windres-command = @SettingsWindresCommand@ -settings-touch-command = @SettingsTouchCommand@ settings-clang-command = @SettingsClangCommand@ settings-llc-command = @SettingsLlcCommand@ settings-opt-command = @SettingsOptCommand@ diff --git a/hadrian/src/Builder.hs b/hadrian/src/Builder.hs index 5bc5cacc80..42cf5c8057 100644 --- a/hadrian/src/Builder.hs +++ b/hadrian/src/Builder.hs @@ -235,7 +235,6 @@ instance H.Builder Builder where pure [] Ghc _ stage -> do root <- buildRoot - touchyPath <- programPath (vanillaContext (Stage0 InTreeLibs) touchy) unlitPath <- builderPath Unlit -- GHC from the previous stage is used to build artifacts in the @@ -244,7 +243,6 @@ instance H.Builder Builder where return $ [ unlitPath ] ++ ghcdeps - ++ [ touchyPath | windowsHost ] ++ [ root -/- mingwStamp | windowsHost ] -- proxy for the entire mingw toolchain that -- we have in inplace/mingw initially, and then at diff --git a/hadrian/src/Hadrian/Builder.hs b/hadrian/src/Hadrian/Builder.hs index 630c58d603..682ac4d06b 100644 --- a/hadrian/src/Hadrian/Builder.hs +++ b/hadrian/src/Hadrian/Builder.hs @@ -49,8 +49,8 @@ class ShakeValue b => Builder b where -- capture the @stdout@ result and return it. askBuilderWith :: b -> BuildInfo -> Action String - -- | Runtime dependencies of a builder. For example, on Windows GHC requires - -- the utility @touchy.exe@ to be available on a specific path. + -- | Runtime dependencies of a builder. For example, GHC requires the + -- utility @unlit@ to be available on a specific path. runtimeDependencies :: b -> Action [FilePath] runtimeDependencies _ = return [] diff --git a/hadrian/src/Oracles/Setting.hs b/hadrian/src/Oracles/Setting.hs index dca0861869..e169c5fe9f 100644 --- a/hadrian/src/Oracles/Setting.hs +++ b/hadrian/src/Oracles/Setting.hs @@ -123,7 +123,6 @@ data SettingsFileSetting | SettingsFileSetting_InstallNameToolCommand | SettingsFileSetting_DllWrapCommand | SettingsFileSetting_WindresCommand - | SettingsFileSetting_TouchCommand | SettingsFileSetting_ClangCommand | SettingsFileSetting_LlcCommand | SettingsFileSetting_OptCommand @@ -220,7 +219,6 @@ settingsFileSetting key = lookupSystemConfig $ case key of SettingsFileSetting_InstallNameToolCommand -> "settings-install_name_tool-command" SettingsFileSetting_DllWrapCommand -> "settings-dll-wrap-command" SettingsFileSetting_WindresCommand -> "settings-windres-command" - SettingsFileSetting_TouchCommand -> "settings-touch-command" SettingsFileSetting_ClangCommand -> "settings-clang-command" SettingsFileSetting_LlcCommand -> "settings-llc-command" SettingsFileSetting_OptCommand -> "settings-opt-command" diff --git a/hadrian/src/Packages.hs b/hadrian/src/Packages.hs index 449004ed92..baf92e8df4 100644 --- a/hadrian/src/Packages.hs +++ b/hadrian/src/Packages.hs @@ -8,7 +8,7 @@ module Packages ( ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline, hsc2hs, hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy, libffi, libiserv, mtl, parsec, pretty, primitive, process, remoteIserv, rts, - runGhc, stm, templateHaskell, terminfo, text, time, timeout, touchy, + runGhc, stm, templateHaskell, terminfo, text, time, timeout, transformers, unlit, unix, win32, xhtml, lintersCommon, lintNotes, lintCommitMsg, lintSubmoduleRefs, lintWhitespace, ghcPackages, isGhcPackage, @@ -40,7 +40,7 @@ ghcPackages = , ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline, hsc2hs , hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, libffi, libiserv, mtl , parsec, pretty, process, rts, runGhc, stm, templateHaskell - , terminfo, text, time, touchy, transformers, unlit, unix, win32, xhtml + , terminfo, text, time, transformers, unlit, unix, win32, xhtml , timeout , lintersCommon , lintNotes, lintCommitMsg, lintSubmoduleRefs, lintWhitespace ] @@ -56,7 +56,7 @@ array, base, binary, bytestring, cabalSyntax, cabal, checkPpr, checkExact, count ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline, hsc2hs, hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy, remoteIserv, libffi, libiserv, mtl, parsec, pretty, primitive, process, rts, runGhc, stm, templateHaskell, - terminfo, text, time, touchy, transformers, unlit, unix, win32, xhtml, + terminfo, text, time, transformers, unlit, unix, win32, xhtml, timeout, lintersCommon, lintNotes, lintCommitMsg, lintSubmoduleRefs, lintWhitespace :: Package @@ -117,7 +117,6 @@ terminfo = lib "terminfo" text = lib "text" time = lib "time" timeout = util "timeout" `setPath` "testsuite/timeout" -touchy = util "touchy" transformers = lib "transformers" unlit = util "unlit" unix = lib "unix" @@ -192,12 +191,12 @@ programName Context {..} = do -- | The 'FilePath' to a program executable in a given 'Context'. programPath :: Context -> Action FilePath 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@. + -- TODO: The @iserv@ and @unlit@ utilities live 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 name <- programName context - path <- if package `elem` [iserv, touchy, unlit] + path <- if package `elem` [iserv, unlit] then stageLibPath stage <&> (-/- "bin") else stageBinPath stage return $ path -/- name <.> exe @@ -210,7 +209,7 @@ timeoutPath = "testsuite/timeout/install-inplace/bin/timeout" <.> exe -- TODO: Can we extract this information from Cabal files? -- | Some program packages should not be linked with Haskell main function. nonHsMainPackage :: Package -> Bool -nonHsMainPackage = (`elem` [hp2ps, iserv, touchy, unlit, ghciWrapper]) +nonHsMainPackage = (`elem` [hp2ps, iserv, unlit, ghciWrapper]) -- TODO: Combine this with 'programName'. -- | Path to the @autogen@ directory generated by 'buildAutogenFiles'. diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs index c41b6eed8f..93e3b1ac1d 100644 --- a/hadrian/src/Rules/Generate.hs +++ b/hadrian/src/Rules/Generate.hs @@ -325,7 +325,6 @@ generateSettings = do , ("ranlib command", expr $ settingsFileSetting SettingsFileSetting_RanlibCommand) , ("otool command", expr $ settingsFileSetting SettingsFileSetting_OtoolCommand) , ("install_name_tool command", expr $ settingsFileSetting SettingsFileSetting_InstallNameToolCommand) - , ("touch command", expr $ settingsFileSetting SettingsFileSetting_TouchCommand) , ("dllwrap command", expr $ settingsFileSetting SettingsFileSetting_DllWrapCommand) , ("windres command", expr $ settingsFileSetting SettingsFileSetting_WindresCommand) , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit }))) diff --git a/hadrian/src/Rules/Program.hs b/hadrian/src/Rules/Program.hs index 71cccd628f..b0f42b3eae 100644 --- a/hadrian/src/Rules/Program.hs +++ b/hadrian/src/Rules/Program.hs @@ -105,7 +105,7 @@ 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 + (False, s) | s > stage0InTree && (package `elem` [unlit]) -> do srcDir <- stageLibPath stage0InTree <&> (-/- "bin") copyFile (srcDir -/- takeFileName bin) bin _ -> buildBinary rs bin ctx diff --git a/hadrian/src/Settings/Default.hs b/hadrian/src/Settings/Default.hs index 312747141b..503d917981 100644 --- a/hadrian/src/Settings/Default.hs +++ b/hadrian/src/Settings/Default.hs @@ -105,7 +105,6 @@ stage0Packages = do ] ++ [ terminfo | not windowsHost, not cross ] ++ [ timeout | windowsHost ] - ++ [ touchy | windowsHost ] -- | Packages built in 'Stage1' by default. You can change this in "UserSettings". stage1Packages :: Action [Package] @@ -176,16 +175,14 @@ defaultLibraryWays = Set.fromList <$> defaultRtsWays :: Ways defaultRtsWays = Set.fromList <$> mconcat - [ pure [vanilla] + [ pure [vanilla, threaded] , notStage0 ? pure - [ profiling, debugProfiling - , debug + [ profiling, threadedProfiling, debugProfiling, threadedDebugProfiling + , debug, threadedDebug ] - , notStage0 ? targetSupportsThreadedRts ? pure [threaded, threadedProfiling, threadedDebugProfiling, threadedDebug] , notStage0 ? platformSupportsSharedLibs ? pure - [ dynamic, debugDynamic + [ dynamic, threadedDynamic, debugDynamic, threadedDebugDynamic ] - , notStage0 ? platformSupportsSharedLibs ? targetSupportsThreadedRts ? pure [ threadedDynamic, threadedDebugDynamic ] ] -- TODO: Move C source arguments here diff --git a/m4/fp_settings.m4 b/m4/fp_settings.m4 index 0b75cf8d35..6f7ae8da45 100644 --- a/m4/fp_settings.m4 +++ b/m4/fp_settings.m4 @@ -25,7 +25,6 @@ AC_DEFUN([FP_SETTINGS], SettingsRanlibCommand="${mingw_bin_prefix}llvm-ranlib.exe" SettingsDllWrapCommand="${mingw_bin_prefix}llvm-dllwrap.exe" SettingsWindresCommand="${mingw_bin_prefix}llvm-windres.exe" - SettingsTouchCommand='$$topdir/bin/touchy.exe' else # This case handles the "normal" platforms (e.g. not Windows) where we @@ -56,12 +55,6 @@ AC_DEFUN([FP_SETTINGS], SettingsWindresCommand="$WindresCmd" fi - if test "$HostOS" = "mingw32"; then - SettingsTouchCommand='$$topdir/bin/touchy.exe' - else - SettingsTouchCommand='touch' - fi - if test "$EnableDistroToolchain" = "YES"; then # If the user specified --enable-distro-toolchain then we just use the # executable names, not paths. @@ -123,7 +116,6 @@ AC_DEFUN([FP_SETTINGS], AC_SUBST(SettingsInstallNameToolCommand) AC_SUBST(SettingsDllWrapCommand) AC_SUBST(SettingsWindresCommand) - AC_SUBST(SettingsTouchCommand) AC_SUBST(SettingsClangCommand) AC_SUBST(SettingsLlcCommand) AC_SUBST(SettingsOptCommand) diff --git a/utils/touchy/Makefile b/utils/touchy/Makefile deleted file mode 100644 index c0eb696cc6..0000000000 --- a/utils/touchy/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# (c) 2009 The University of Glasgow -# -# This file is part of the GHC build system. -# -# To understand how the build system works and how to modify it, see -# https://gitlab.haskell.org/ghc/ghc/wikis/building/architecture -# https://gitlab.haskell.org/ghc/ghc/wikis/building/modifying -# -# ----------------------------------------------------------------------------- - -# -# Substitute for 'touch' on win32 platforms (without an Unix toolset installed). -# -TOP=../.. -include $(TOP)/mk/boilerplate.mk - -C_SRCS=touchy.c -C_PROG=touchy -SRC_CC_OPTS += -O - -# -# Install touchy in lib/.* -# -INSTALL_LIBEXECS += $(C_PROG) - -include $(TOP)/mk/target.mk - -# Get it over with! -boot :: all - -binary-dist: - $(INSTALL_DIR) $(BIN_DIST_DIR)/utils/touchy - $(INSTALL_DATA) Makefile $(BIN_DIST_DIR)/utils/touchy/ - $(INSTALL_PROGRAM) $(C_PROG) $(BIN_DIST_DIR)/utils/touchy/ - diff --git a/utils/touchy/touchy.c b/utils/touchy/touchy.c deleted file mode 100644 index dbcf71277c..0000000000 --- a/utils/touchy/touchy.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Simple 'touch' program for Windows - * - */ -#if !defined(_WIN32) -#error "Win32-only, the platform you're using is supposed to have 'touch' already." -#else -#include <stdio.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <fcntl.h> -#include <errno.h> -#include <utime.h> -#include <windows.h> - -/* -touch is used by GHC both during building and during compilation of -Haskell files. Unfortunately this means we need a 'touch' like program -in the GHC bindist. Since touch is not standard on Windows and msys2 -doesn't include a mingw-w64 build of coreutils we need touchy for now. - -With Windows 7 in a virtual box VM on OS X, some very odd things happen -with dates and time stamps when SSHing into cygwin. e.g. here the -"Change" time is in the past: - -$ date; touch foo; stat foo -Fri Dec 2 16:58:07 GMTST 2011 - File: `foo' - Size: 0 Blocks: 0 IO Block: 65536 regular -empty file -Device: 540aba0bh/1409989131d Inode: 562949953592977 Links: 1 -Access: (0644/-rw-r--r--) Uid: ( 1000/ ian) Gid: ( 513/ None) -Access: 2011-12-02 16:58:07.414457900 +0000 -Modify: 2011-12-02 16:58:07.414457900 +0000 -Change: 2011-12-02 16:58:03.495141800 +0000 - Birth: 2011-12-02 16:57:57.731469900 +0000 - -And if we copy such a file, then the copy is older (as determined by the -"Modify" time) than the original: - -$ date; touch foo; stat foo; cp foo bar; stat bar -Fri Dec 2 16:59:10 GMTST 2011 - File: `foo' - Size: 0 Blocks: 0 IO Block: 65536 regular -empty file -Device: 540aba0bh/1409989131d Inode: 1407374883725128 Links: 1 -Access: (0644/-rw-r--r--) Uid: ( 1000/ ian) Gid: ( 513/ None) -Access: 2011-12-02 16:59:10.118457900 +0000 -Modify: 2011-12-02 16:59:10.118457900 +0000 -Change: 2011-12-02 16:59:06.189477700 +0000 - Birth: 2011-12-02 16:57:57.731469900 +0000 - File: `bar' - Size: 0 Blocks: 0 IO Block: 65536 regular -empty file -Device: 540aba0bh/1409989131d Inode: 281474976882512 Links: 1 -Access: (0644/-rw-r--r--) Uid: ( 1000/ ian) Gid: ( 513/ None) -Access: 2011-12-02 16:59:06.394555800 +0000 -Modify: 2011-12-02 16:59:06.394555800 +0000 -Change: 2011-12-02 16:59:06.395532400 +0000 - Birth: 2011-12-02 16:58:40.921899600 +0000 - -This means that make thinks that things are out of date when it -shouldn't, so reinvokes itself repeatedly until the MAKE_RESTARTS -infinite-recursion test triggers. - -The touchy program, like most other programs, creates files with both -Modify and Change in the past, which is still a little odd, but is -consistent, so doesn't break make. - -We used to use _utime(argv[i],NULL)) to set the file modification times, -but after a BST -> GMT change this started giving files a modification -time an hour in the future: - -$ date; utils/touchy/dist/build/tmp/touchy testfile; stat testfile -Tue, Oct 30, 2012 11:33:06 PM - File: `testfile' - Size: 0 Blocks: 0 IO Block: 65536 regular empty file -Device: 540aba0bh/1409989131d Inode: 9851624184986293 Links: 1 -Access: (0755/-rwxr-xr-x) Uid: ( 1000/ ian) Gid: ( 513/ None) -Access: 2012-10-31 00:33:06.000000000 +0000 -Modify: 2012-10-31 00:33:06.000000000 +0000 -Change: 2012-10-30 23:33:06.769118900 +0000 - Birth: 2012-10-30 23:33:06.769118900 +0000 - -so now we use the Win32 functions GetSystemTimeAsFileTime and SetFileTime. -*/ - -int -main(int argc, char** argv) -{ - int i; - FILETIME ft; - BOOL b; - HANDLE hFile; - - if (argc == 1) { - fprintf(stderr, "Usage: %s <files>\n", argv[0]); - return 1; - } - - for (i = 1; i < argc; i++) { - hFile = CreateFile(argv[i], GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile == INVALID_HANDLE_VALUE) { - fprintf(stderr, "Unable to open %s\n", argv[i]); - exit(1); - } - GetSystemTimeAsFileTime(&ft); - b = SetFileTime(hFile, (LPFILETIME) NULL, (LPFILETIME) NULL, &ft); - if (b == 0) { - fprintf(stderr, "Unable to change mod. time for %s\n", argv[i]); - exit(1); - } - b = CloseHandle(hFile); - if (b == 0) { - fprintf(stderr, "Closing failed for %s\n", argv[i]); - exit(1); - } - } - - return 0; -} -#endif diff --git a/utils/touchy/touchy.cabal b/utils/touchy/touchy.cabal deleted file mode 100644 index 5c28c664fc..0000000000 --- a/utils/touchy/touchy.cabal +++ /dev/null @@ -1,15 +0,0 @@ -cabal-version: 2.2 -Name: touchy -Version: 0.1 -Copyright: XXX -License: BSD-3-Clause -Author: XXX -Maintainer: XXX -Synopsis: @touch@ for windows -Description: XXX -Category: Development -build-type: Simple - -Executable touchy - Default-Language: Haskell2010 - Main-Is: touchy.c |