Opened 4 years ago

Last modified 3 years ago

#8812 new feature request

Make *_stub.c files available again

Reported by: ralphb Owned by:
Priority: normal Milestone:
Component: Driver Version: 7.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


In our project we would like to link Haskell functions into C++ code. In principle this works fine using FFI.

An additional constraint, however, is that we need to generate and link the object files ourselves. Alas, ghc no longer keeps the *_stub.c files around. (And fishing for files in /tmp is not a viable solution.)

I would like to propose an additional command line switch to keep *_stub.c files, as previous compiler versions did by default.

(Note that there is an older, similar request #7463, but our use case is much broader than that and not limited to unregistered compilation.)

Change History (1)

comment:1 Changed 3 years ago by thomie

Component: CompilerDriver

For reference, the last major change to the handling of *_stub.c files was in:

commit 7b0ff1792d699ff02a604163c9ccf4a98a1ca3eb
Author: Simon Marlow <>
Date:   Mon Jan 31 10:32:24 2011 +0000

    Merge _stub.o files into the main .o file (Fixes #3687 and #706)
    Now GHC still generates the _stub.c files, but the object file is
    automatically merged into the main .o file for a module.  This means
    that build systems (including GHC's own) no longer need to worry about
    looking for _stub.o files and including them when linking.
    I had to do lots of refactoring in DriverPipeline to make this work;
    now there's a monad to carry around all the information, and
    everything is a lot tidier.
    The _stub.c is now created as a temporary file and removed after
    compilation (unless the -keep-tmp-files flag is on).
Note: See TracTickets for help on using tickets.