[Git][ghc/ghc][master] ghc-toolchain: Don't leave stranded a.outs when testing for -g0

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Sep 3 17:17:05 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
b16605e7 by Arsen Arsenović at 2024-09-03T13:16:05-04:00
ghc-toolchain: Don't leave stranded a.outs when testing for -g0

This happened because, when ghc-toolchain tests for -g0, it does so by
compiling an empty program.  This compilation creates an a.out.

Since we create a temporary directory, lets place the test program
compilation in it also, so that it gets cleaned up.

Fixes: 25b0b40467d0a12601497117c0ad14e1fcab0b74
Closes: https://gitlab.haskell.org/ghc/ghc/-/issues/25203

- - - - -


1 changed file:

- utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs


Changes:

=====================================
utils/ghc-toolchain/src/GHC/Toolchain/Tools/Cpp.hs
=====================================
@@ -39,10 +39,10 @@ data CmmCpp = CmmCpp { cmmCppProgram :: Program
                      }
     deriving (Show, Read, Eq, Ord)
 
-checkFlag :: String -> Program -> String -> M ()
-checkFlag conftest cpp flag = checking ("for "++flag++" support") $
+checkFlag :: String -> Program -> String -> [String] ->  M ()
+checkFlag conftest cpp flag extra_args = checking ("for "++flag++" support") $
   -- Werror to ensure that unrecognized warnings result in an error
-  callProgram cpp ["-Werror", flag, conftest]
+  callProgram cpp $ ["-Werror", flag, conftest] ++ extra_args
 -- tryFlag :: String -> Program -> String -> M [String]
 -- tryFlag conftest cpp flag =
 --   ([flag] <$ checkFlag conftest cpp flag) <|> return []
@@ -167,7 +167,7 @@ findCmmCpp progOpt cc = checking "for a Cmm preprocessor" $ do
   cmmCppSupportsG0 <- withTempDir $ \dir -> do
     let conftest = dir </> "conftest.c"
     writeFile conftest "int main(void) {}"
-    True <$ checkFlag conftest cpp "-g0" <|> return False
+    True <$ checkFlag conftest cpp "-g0" ["-o", dir </> "conftest"] <|> return False
 
   -- Always add the -E flag to the CPP, regardless of the user options
   let cmmCppProgram = foldr addFlagIfNew cpp ["-E"]



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b16605e7c135f8cfd357a60c7f358132faec6a84

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b16605e7c135f8cfd357a60c7f358132faec6a84
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/20240903/47e121ca/attachment-0001.html>


More information about the ghc-commits mailing list