diff options
author | Tamar Christina <tamar@zhox.com> | 2017-06-17 01:05:52 +0100 |
---|---|---|
committer | Tamar Christina <tamar@zhox.com> | 2017-06-17 01:17:07 +0100 |
commit | d6cecde585b0980ed8e0050c5a1d315789fb6356 (patch) | |
tree | 6f8a7b515787652eedaeb1e18ee22ec7acde9a27 /compiler/main/SysTools.hs | |
parent | fda094d000cf2c2874a8205c8212cb83b52259ef (diff) | |
download | haskell-d6cecde585b0980ed8e0050c5a1d315789fb6356.tar.gz |
Remove the Windows GCC driver.
Summary:
This patch drops the GCC driver and instead moves
the only remaining path that we need to keep for
backwards compatibility to the settings file.
It also generalizes the code that expands `$TopDir`
so it can expand it within any location in the string
and also changes it so `$TopDir` is expanded only
after the words call because `$TopDir` can contains
spaces which would be horribly broken.
Test Plan: ./validate
Reviewers: austin, hvr, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie, erikd
GHC Trac Issues: #13709
Differential Revision: https://phabricator.haskell.org/D3592
Diffstat (limited to 'compiler/main/SysTools.hs')
-rw-r--r-- | compiler/main/SysTools.hs | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs index 0a19feb2ce..f2878b0e7b 100644 --- a/compiler/main/SysTools.hs +++ b/compiler/main/SysTools.hs @@ -202,17 +202,10 @@ initSysTools mbMinusB Nothing -> pgmError ("Can't parse " ++ show platformConstantsFile) - let getSetting key = case lookup key mySettings of - Just xs -> - return $ case stripPrefix "$topdir" xs of - Just [] -> - top_dir - Just xs'@(c:_) - | isPathSeparator c -> - top_dir ++ xs' - _ -> - xs - Nothing -> pgmError ("No entry for " ++ show key ++ " in " ++ show settingsFile) + let getSettingRaw key = case lookup key mySettings of + Just xs -> return xs + Nothing -> pgmError ("No entry for " ++ show key ++ " in " ++ show settingsFile) + getSetting key = resolveTopDir top_dir <$> getSettingRaw key getBooleanSetting key = case lookup key mySettings of Just "YES" -> return True Just "NO" -> return False @@ -239,7 +232,11 @@ initSysTools mbMinusB -- with the settings file, but it would be a little fiddly -- to make that possible, so for now you can't. gcc_prog <- getSetting "C compiler command" - gcc_args_str <- getSetting "C compiler flags" + -- TopDir can expand to something that contains spaces + -- for the argument string we apply words to the string in order to + -- break it up. So defer the expansion of $TopDir till after the words + -- call here. + gcc_args_str <- getSettingRaw "C compiler flags" gccSupportsNoPie <- getBooleanSetting "C compiler supports -no-pie" cpp_prog <- getSetting "Haskell CPP command" cpp_args_str <- getSetting "Haskell CPP flags" @@ -252,7 +249,7 @@ initSysTools mbMinusB = ["-DTABLES_NEXT_TO_CODE"] | otherwise = [] cpp_args= map Option (words cpp_args_str) - gcc_args = map Option (words gcc_args_str + gcc_args = map (Option . resolveTopDir top_dir) (words gcc_args_str ++ unreg_gcc_args ++ tntc_gcc_args) ldSupportsCompactUnwind <- getBooleanSetting "ld supports compact unwind" @@ -363,6 +360,21 @@ initSysTools mbMinusB sPlatformConstants = platformConstants } +-- | This function will replace any usage of $TopDir in the given string +-- regardless of it's location within the string. +resolveTopDir :: String -- ^ The value of $TopDir + -> String -- ^ The string to perform substitutions in + -> String -- ^ The resulting string with all subs done. +resolveTopDir top_dir str + = case break (=='$') str of + (_, []) -> str + (x, xs) -> let rst = case stripPrefix "$topdir" xs of + Just [] -> top_dir + Just xs'@(c:_) | isPathSeparator c + -> top_dir ++ xs' + _ -> xs + in x ++ resolveTopDir top_dir rst + -- returns a Unix-format path (relying on getBaseDir to do so too) findTopDir :: Maybe String -- Maybe TopDir path (without the '-B' prefix). -> IO String -- TopDir (in Unix format '/' separated) |