summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-09-29 10:48:57 -0400
committerBen Gamari <ben@smart-cactus.org>2021-09-29 10:56:17 -0400
commite3054217becfd4eb2904ba208b71ece665d90e81 (patch)
treeaea94784365ba28abb1f94913a56410f9d2e8f73
parentf66eaefd5d4a3e0c0822dd3678e5e55a7d972a0d (diff)
downloadhaskell-wip/drop-getEnvironment.tar.gz
compiler: Avoid unnecessary getEnvironment usagewip/drop-getEnvironment
In general getEnvironment can be quite expensive since it must decode the entire environment (which may be large) into a String. On non-Windows platforms Previously `GHC.SysTools.Process.getGccEnv`, which exists only to work around a toolchain bug on Windows (#1110), called `getEnvironment` on POSIX only to then pass the environment unmodified, incurring unnecessary cost. Don't do this.
-rw-r--r--compiler/GHC/SysTools/Process.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/GHC/SysTools/Process.hs b/compiler/GHC/SysTools/Process.hs
index 63ff2c8294..a2a684fe09 100644
--- a/compiler/GHC/SysTools/Process.hs
+++ b/compiler/GHC/SysTools/Process.hs
@@ -105,6 +105,7 @@ c_locale_env = ("LANGUAGE", "C")
-- a bug in gcc on Windows Vista where it can't find its auxiliary
-- binaries (see bug #1110).
getGccEnv :: [Option] -> IO (Maybe [(String,String)])
+#if defined(mingw32_HOST_OS)
getGccEnv opts =
if null b_dirs
then return Nothing
@@ -117,13 +118,12 @@ getGccEnv opts =
get_b_opt other = Right other
-- Work around #1110 on Windows only (lest we stumble into #17266).
-#if defined(mingw32_HOST_OS)
mangle_paths = map mangle_path
mangle_path (path,paths) | map toUpper path == "PATH"
= (path, '\"' : head b_dirs ++ "\";" ++ paths)
mangle_path other = other
#else
- mangle_paths = id
+getGccEnv _ = return Nothing
#endif