[Git][ghc/ghc][wip/ghc-toolchain-fixes] Don't use /dev/null
Matthew Pickering (@mpickering)
gitlab at gitlab.haskell.org
Tue Aug 8 12:45:08 UTC 2023
Matthew Pickering pushed to branch wip/ghc-toolchain-fixes at Glasgow Haskell Compiler / GHC
Commits:
23ddf127 by Matthew Pickering at 2023-08-08T13:44:59+01:00
Don't use /dev/null
- - - - -
1 changed file:
- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs
Changes:
=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs
=====================================
@@ -10,6 +10,7 @@ import GHC.Toolchain.Prelude
import GHC.Toolchain.Program
import GHC.Toolchain.Tools.Cc
+import GHC.Toolchain.Utils (withTempDir)
newtype Cpp = Cpp { cppProgram :: Program
}
@@ -35,9 +36,11 @@ findHsCpp progOpt cc = checking "for Haskell C preprocessor" $ do
-- | Given a C preprocessor, figure out how it should be invoked to preprocess
-- Haskell source.
findHsCppArgs :: Program -> M [String]
-findHsCppArgs cpp = do
+findHsCppArgs cpp = withTempDir $ \dir -> do
- (_, stdout0, stderr0) <- readProgram cpp ["-x", "c", "/dev/null", "-dM", "-E"]
+ let tmp_c = dir </> "tmp.c"
+ writeFile tmp_c ""
+ (_, stdout0, stderr0) <- readProgram cpp ["-x", "c", tmp_c, "-dM", "-E"]
logDebug stdout0
logDebug stderr0
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23ddf1278d56119e375bc090b1ce29ecf5991dc7
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/23ddf1278d56119e375bc090b1ce29ecf5991dc7
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/20230808/9f5baee3/attachment-0001.html>
More information about the ghc-commits
mailing list