|
generating proper filename for "*_stub.o" file: msg#00054lang.haskell.glasgow.bugs
Hello glasgow-haskell-bugs, GHC contains long-standing bug in generating proper filename for the "*_stub.o" file. If the corresponding module is already compiled and we need only to link it - name for this file is determined in "findLinkable" procedure from the name of main object file for this module by replacing ".o" with "_stub.o" But when corresponding module is compiled this algorithm is not used. Instead, execution goes through "compileStub" routine, which DON'T RECEIVE INFORMATION ABOUT NAME OF ".o" FILE OF MODULE ITSELF. Therefore, "genOutputFilenameFunc" called as part of stub file compilation, builds "*_stub.o" filename from name of "*_stub.c" file, that CAN'T BE DONE 100% PROPERLY JUST BECAUSE THERE IS NOT ENOUGH INFORMATION GHC 6.4.0 works improper when -odir was specified AND module was imported from subdirectory using hierarchical name ("import Subdir.Module"). i demonstrate this in attached ghc640bug.zip GHC 6.4.1 dropped call to replaceFilenameDirectory in genOutputFilenameFunc, that fixed the previous case, but resulted in improper work when -odir was specified AND module was imported from any directory specified by "-i" option. i demonstrate this in attached ghc641bug.zip i think that any auto-generated filenames, not only stub object files, may have this problems - if the execution falls to the line "| Just d <- odir = d ++ '/':persistent" in genOutputFilenameFunc, then filename, generated by this line, may differ with filename for the same file, generated in another program places, when abovementioned conditions are met to properly generate "*_stub.o" filenames i propose to do the following changes (modeled on 6.4.1 sources): 1) replace first call to compileStub with lines: let object_filename = ml_obj_file location maybe_stub_o <- compileStub dyn_flags' stub_c_exists (stubOFilename object_filename) 2) replace second call to compileStub with line: maybe_stub_o <- compileStub dflags' stub_c_exists (stubOFilename o_file) 3) define stubOFilename as: stubOFilename:: FilePath->FilePath stubOFilename obj_fn = case splitFilename3 obj_fn of (dir, base, ext) -> dir ++ "/" ++ base ++ "_stub.o" i also highly recommend to use this function in definition of "findLinkable" 4) add to compileStub using of stub_o_filename: compileStub dflags stub_c_exists stub_o_filename | not stub_c_exists = return Nothing | stub_c_exists = do -- compile the _stub.c file w/ gcc let stub_c = hscStubCOutName dflags (_, stub_o) <- runPipeline StopLn "stub-compile" dflags True{-persistent output-} (Just stub_o_filename) stub_c Nothing{-no ModLocation-} return (Just stub_o) This must make happy both cases i attached -- Best regards, Bulat mailto:bulatz@xxxxxxxxxx
Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@xxxxxxxxxxx http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: GHC Crash, Simon Peyton-Jones |
|---|---|
| Next by Date: | Bug in make of ghc 6.2.2, Larry Newman |
| Previous by Thread: | [ ghc-Bugs-1364839 ] ghc-pkg to build ghci libraries on install, SourceForge.net |
| Next by Thread: | Bug in make of ghc 6.2.2, Larry Newman |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |