From 0fac488cca04a07224926e35be9c45ee2d0e1631 Mon Sep 17 00:00:00 2001 From: Francesco Mazzoli Date: Tue, 7 Mar 2017 23:39:51 -0500 Subject: Allow compilation of C/C++/ObjC/ObjC++ files with module from TH The main goal is to easily allow the inline-c project (and similar projects such as inline-java) to emit C/C++ files to be compiled and linked with the current module. Moreover, `addCStub` is removed, since it's quite fragile. Most notably, the C stubs end up in the file generated by `CodeOutput.outputForeignStubs`, which is tuned towards generating a file for stubs coming from `capi` and Haskell-to-C exports. Reviewers: simonmar, austin, goldfire, facundominguez, dfeuer, bgamari Reviewed By: dfeuer, bgamari Subscribers: snowleopard, rwbarton, dfeuer, thomie, duncan, mboes Differential Revision: https://phabricator.haskell.org/D3280 --- compiler/main/PipelineMonad.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'compiler/main/PipelineMonad.hs') diff --git a/compiler/main/PipelineMonad.hs b/compiler/main/PipelineMonad.hs index 614c4fa30f..e0904b8ad3 100644 --- a/compiler/main/PipelineMonad.hs +++ b/compiler/main/PipelineMonad.hs @@ -6,7 +6,7 @@ module PipelineMonad ( CompPipeline(..), evalP , PhasePlus(..) , PipeEnv(..), PipeState(..), PipelineOutput(..) - , getPipeEnv, getPipeState, setDynFlags, setModLocation, setStubO + , getPipeEnv, getPipeState, setDynFlags, setModLocation, setForeignOs ) where import MonadUtils @@ -65,10 +65,10 @@ data PipeState = PipeState { maybe_loc :: Maybe ModLocation, -- ^ the ModLocation. This is discovered during compilation, -- in the Hsc phase where we read the module header. - maybe_stub_o :: Maybe FilePath - -- ^ the stub object. This is set by the Hsc phase if a stub - -- object was created. The stub object will be joined with - -- the main compilation object using "ld -r" at the end. + foreign_os :: [FilePath] + -- ^ additional object files resulting from compiling foreign + -- code. They come from two sources: foreign stubs, and + -- add{C,Cxx,Objc,Objcxx}File from template haskell } data PipelineOutput @@ -102,6 +102,6 @@ setModLocation :: ModLocation -> CompPipeline () setModLocation loc = P $ \_env state -> return (state{ maybe_loc = Just loc }, ()) -setStubO :: FilePath -> CompPipeline () -setStubO stub_o = P $ \_env state -> - return (state{ maybe_stub_o = Just stub_o }, ()) +setForeignOs :: [FilePath] -> CompPipeline () +setForeignOs os = P $ \_env state -> + return (state{ foreign_os = os }, ()) -- cgit v1.2.1