summaryrefslogtreecommitdiff
path: root/compiler/main/CodeOutput.hs
diff options
context:
space:
mode:
authorAlec Theriault <alec.theriault@gmail.com>2018-03-25 13:59:27 -0400
committerBen Gamari <ben@smart-cactus.org>2018-03-25 14:33:22 -0400
commitceb914771aece0aa6d87339227ce406c7179d1d1 (patch)
tree1b63f9af0e0c7e212c840e1ccd1e6add484774cf /compiler/main/CodeOutput.hs
parentaffdea82bb70e5a912b679a169c6e9a230e4c93e (diff)
downloadhaskell-ceb914771aece0aa6d87339227ce406c7179d1d1.tar.gz
Support adding objects from TH
The user facing TH interface changes are: * 'addForeignFile' is renamed to 'addForeignSource' * 'qAddForeignFile'/'addForeignFile' now expect 'FilePath's * 'RawObject' is now a constructor for 'ForeignSrcLang' * 'qAddTempFile'/'addTempFile' let you request a temporary file from the compiler. Test Plan: unsure about this, added a TH test Reviewers: goldfire, bgamari, angerman Reviewed By: bgamari, angerman Subscribers: hsyl20, mboes, carter, simonmar, bitonic, ljli, rwbarton, thomie GHC Trac Issues: #14298 Differential Revision: https://phabricator.haskell.org/D4217
Diffstat (limited to 'compiler/main/CodeOutput.hs')
-rw-r--r--compiler/main/CodeOutput.hs20
1 files changed, 2 insertions, 18 deletions
diff --git a/compiler/main/CodeOutput.hs b/compiler/main/CodeOutput.hs
index fc854e40b7..478de594ac 100644
--- a/compiler/main/CodeOutput.hs
+++ b/compiler/main/CodeOutput.hs
@@ -38,7 +38,6 @@ import Control.Exception
import System.Directory
import System.FilePath
import System.IO
-import Control.Monad (forM)
{-
************************************************************************
@@ -53,7 +52,7 @@ codeOutput :: DynFlags
-> FilePath
-> ModLocation
-> ForeignStubs
- -> [(ForeignSrcLang, String)]
+ -> [(ForeignSrcLang, FilePath)]
-- ^ additional files to be compiled with with the C compiler
-> [InstalledUnitId]
-> Stream IO RawCmmGroup () -- Compiled C--
@@ -61,7 +60,7 @@ codeOutput :: DynFlags
(Bool{-stub_h_exists-}, Maybe FilePath{-stub_c_exists-}),
[(ForeignSrcLang, FilePath)]{-foreign_fps-})
-codeOutput dflags this_mod filenm location foreign_stubs foreign_files pkg_deps
+codeOutput dflags this_mod filenm location foreign_stubs foreign_fps pkg_deps
cmm_stream
=
do {
@@ -89,10 +88,6 @@ codeOutput dflags this_mod filenm location foreign_stubs foreign_files pkg_deps
}
; stubs_exist <- outputForeignStubs dflags this_mod location foreign_stubs
- ; foreign_fps <- forM foreign_files $ \(lang, file_contents) -> do
- { fp <- outputForeignFile dflags lang file_contents;
- ; return (lang, fp);
- }
; case hscTarget dflags of {
HscAsm -> outputAsm dflags this_mod location filenm
linted_cmm_stream;
@@ -270,14 +265,3 @@ outputForeignStubs_help fname doc_str header footer
= do writeFile fname (header ++ doc_str ++ '\n':footer ++ "\n")
return True
-outputForeignFile :: DynFlags -> ForeignSrcLang -> String -> IO FilePath
-outputForeignFile dflags lang file_contents
- = do
- extension <- case lang of
- LangC -> return "c"
- LangCxx -> return "cpp"
- LangObjc -> return "m"
- LangObjcxx -> return "mm"
- fp <- newTempName dflags TFL_CurrentModule extension
- writeFile fp file_contents
- return fp