Opened 10 years ago

Closed 9 years ago

#3687 closed feature request (fixed)

Merge _stub.o files back in to the .o file

Reported by: NeilMitchell Owned by: simonmar
Priority: high Milestone: 7.4.1
Component: Compiler Version: 6.10.4
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking: #706
Related Tickets: Differential Rev(s):
Wiki Page:

Description

GHC sometimes generates _stub.o files. When it does, ghci doesn't work with compiled files (it forgets to include the _stub.o in the files to link against), and it complicates many building rules (including those inside GHC's makefile).

It would be far better if the _stub.o files were merged back in with the original. This is actually reasonably easy:

b <- doesFileExist stub
when b $ do
    let tmp = res <.> "tmp.o"
    mv obj tmp
    exec ["ld","-r","-o",obj,tmp,stub]
    rm stub
    rm tmp

While being mainly a feature request, this enhancement also fixes a bug with GHCi loading files with _stub's, so includes a bug fix for free.

Change History (13)

comment:1 Changed 10 years ago by igloo

See also #706

comment:2 Changed 10 years ago by simonmar

I like this idea better than the fix in #706.

Neil: I'm surprised that you say ghci forgets to link the _stub.o files, as far as I'm aware it should just pick up the _stub.o file if it exists (that's the #706 bug).

comment:3 Changed 10 years ago by NeilMitchell

I've got flags like hidir/odir and hisuf/osuf set, so my guess is it's not honouring one of those (probably osuf). I can figure out a test case for that, or if you're just going to merge the _stub.o, I won't need to.

comment:4 Changed 10 years ago by simonmar

I'd appreciate the test case - it may indicate a bug that we need to fix anyway. I'm surprised, since GHC uses the same code find files regardless of what mode it's running in, so the behaviour of -osuf etc. should be exactly the same with GHCi as it is with --make.

comment:5 Changed 10 years ago by NeilMitchell

I tracked down the bug. If you pass the same -osuf/-hisuf to GHCi as you do to when compiling the files then it works, so I guess this is a bug in the way I was invoking GHCi.

comment:6 Changed 10 years ago by igloo

Milestone: 6.12 branch

comment:7 Changed 10 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:8 Changed 10 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:9 Changed 9 years ago by igloo

Milestone: 7.0.17.0.2

comment:10 Changed 9 years ago by simonmar

Owner: set to simonmar
Priority: lowhigh

I've done this, will commit shortly.

comment:11 Changed 9 years ago by simonmar

Milestone: 7.0.27.2.1

comment:12 Changed 9 years ago by simonmar

Blocking: 706 added

comment:13 Changed 9 years ago by simonmar

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.