+-- The _stub.c file is derived from the haskell source file (but stored
+-- in hscStubCOutName in the dflags for some reason, probably historical).
+-- Consequently, we derive the _stub.o filename from the haskell object
+-- filename.
+--
+-- This isn't necessarily the same as the object filename we
+-- would get if we just compiled the _stub.c file using the pipeline.
+-- For example:
+--
+-- ghc src/A.hs -odir obj
+--
+-- results in obj/A.o, and src/A_stub.c. If we compile src/A_stub.c with
+-- -odir obj, we would get obj/src/A_stub.o, which is wrong; we want
+-- obj/A_stub.o.
+
+compileStub dflags object_filename = do
+ let (o_base, o_ext) = splitFilename object_filename
+ stub_o = o_base ++ "_stub" `joinFileExt` o_ext
+